svmiller / stevetemplates

My collection of R Markdown templates, as an R package.
http://svmiller.com/stevetemplates
128 stars 22 forks source link

2nd manuscript template knit error #5

Closed pherephobia closed 3 years ago

pherephobia commented 3 years ago

Hi, I encountered an error when I knit stevetemplates::articles2

! Package fontspec Error: The font "cochineal" cannot be found.

! name = cochineal, rootname = cochineal, pointsize = ! mktexmf: empty or non-existent rootfile!

! mktexmf: empty or non-existent rootfile!

! kpathsea: Running mktexmf cochineal.mf

! The command name is C:\Users\phere\AppData\Roaming\TinyTeX\bin\win32\mktexmf ! Cannot find cochineal.mf.

! Cannot find cochineal.mf.

! kpathsea: Running mktextfm cochineal

! The command name is C:\Users\phere\AppData\Roaming\TinyTeX\bin\win32\mktextfm

! kpathsea: Appending font creation commands to missfont.log.

I do not know why the misfont error occurs even though I import the template via Rstudio-rmarkdown. I am using TexLive2021 and installed tinytex.

svmiller commented 3 years ago

Looks like a {tinytex} issue. My understanding is {tinytex} will install the bare minimum in order to knit documents, and that anything else extra you may want you'll have to install yourself.

I'll note that I don't use {tinytex}, so I don't know exactly how this should go. But try this:

tinytex::tlmgr_install("cochineal")

Hopefully that will work.

svmiller commented 3 years ago

Closing this as a {tinytex} issue, which it almost assuredly is.

MikkoVihtakari commented 2 years ago

I have the same issue (on Mac) when installing stevetemplates from GitHub (also from CRAN) and using the 2nd manuscript template without modifications. I also have MacTeX and Live Utitility. When I run the code you suggested above and try to compile the Rmd, I get

output file: test2.knit.md

! Undefined control sequence. l.42 \urlstyle {same} % disable monospaced font for URLs

Error: LaTeX failed to compile test2.tex. See https://yihui.org/tinytex/r/#debugging for debugging tips. See test2.log for more info. Execution halted

Any suggestions? I tried to replace mainfont by something else but always get error about missing font.

When I typeset the .tex file knitted by Rstudio in TexShop, the compilation works.

svmiller commented 2 years ago

Almost assuredly related. This would be a LaTeX error and not a template error, per se, and very likely one that comes by way of {tinytex}.

https://github.com/svmiller/stevetemplates/issues/1#issuecomment-805020598

MikkoVihtakari commented 2 years ago

Thanks. Yes, it works. One needs to do manual installation of both, the font and URL package, in R console

tinytex::tlmgr_install("cochineal")
tinytex::tlmgr_install("xurl")