Install R (R i386 4.0.5, R x64 4.0.5), RStudio (1.4.1106), MiKTeX 2.9 and TinyTeX in a virtual machine on Window 10 x64 based environment.
Run .rmd program and - \usepackage{fancyhdr} statement on the header-includes section; the report generating pdf output failed. Message on R Markdown tab:
Can't locate Win32/API.pm in @INC (you may need to install the Win32::API module) (@INC contains: C:/Users/nli/AppData/Roaming/TinyTeX/texmf-dist/scripts/texlive C:/Users/nli/AppData/Roaming/TinyTeX/tlpkg C:\Users\nli\AppData\Roaming\TinyTeX\tlpkg\tlperl\lib C:/Users/nli/AppData/Roaming/TinyTeX/tlpkg/tlperl/site/lib C:/Users/nli/AppData/Roaming/TinyTeX/tlpkg/tlperl/lib) at C:/Users/nli/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLWinGoo.pm line 129.
BEGIN failed--compilation aborted at C:/Users/nli/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLWinGoo.pm line 143.
Compilation failed in require at C:/Users/nli/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLPDB.pm line 103.
BEGIN failed--compilation aborted at C:/Users/nli/AppData/Roaming/TinyTeX/tlpkg/TeXLive/TLPDB.pm line 103.
Compilation failed in require at C:\Users\nli\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl line 91.
BEGIN failed--compilation aborted at C:\Users\nli\AppData\Roaming\TinyTeX\texmf-dist\scripts\texlive\tlmgr.pl line 91.
! LaTeX Error: File `fancyhdr.sty' not found.
Does anyone know how to solve this problem? Thanks in advance.
I don't use Windows but the Latex error suggests that the fancyhdr package needs to be installed. Tinytex is as it says tiny and it is unlikely to have fancyhdr.
No idea how to install a latex package in Windows but I think it is covered in yihui's Rmarkdown book
A MiKTeX installation should do it but can you check for sure that fancyhdr is there?
IIRC, it is not in the standard TeXLive installation and while I have it now, on my original installation 6--7 years ago I had to install it separately. Now, when setting up a new computer, I say the heck with diskspace and download everything.
Do you still have Tinytex installed? If so, can you be sure that you are compiling with MiXText? I am a Linux user so I have no idea how Windows will handle things.
The other thing, you could post a cut-down copy of your .rmd file and someone can have a shot at running it. I can give it a try but even better would be another Windows user.
I've installed basic-miktex-21.2-x64 application; it seems like RStudio can't find MiKTex for some reason. I don't know how to install and check fancyhdr package installed .
---
title: "try"
header-includes:
- \usepackage{fancyhdr}
- \addtolength{\headheight}{1.0cm}
- \pagestyle{fancyplain}
- \lhead{\includegraphics[height=1.2cm]{L:/Statunit/Dashboard Reports/Common Functions/TJC_logo_color.png}}
- \renewcommand{\headrulewidth}{0pt}
- \usepackage{comment}
- \usepackage{float}
geometry: margin=2cm
output:
pdf_document:
latex_engine: xelatex
html_document: default
word_document: default
urlcolor: blue
classoption: landscape
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
## R Markdown
This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see <http://rmarkdown.rstudio.com>.
It might be worth posting on a Windows forum for help with Win32::API. Someone here will know but a lot of us are Mac or Linux and you should get a faster answer on a Windows forum
Thank you so much. Same .rmd file runs as expected and generate pdf report in my laptop. Now we are migrating R/RStudio to virtual machine (remote desk) - on server maybe?? That may cause the problem. Not sure laptop and server using same version of R/RStudio.