Unable to knit pdf, receiving tinytex error with failed tlmgr search

若如初见. 提交于 2020-12-13 01:22:19

问题


Using - RStudio Version 1.2.1335 - R version

I am able to knit the R markdown file to HTML and Word, but fail with PDF. I keep receiving the same error message telling me that it is unable to locate the "Palatino" font.

The file is successfully processed (all chunks run).

I have tried re-installing and resetting Miktex and Tinytex, as well as R itself. I am pretty new to this, so I am unsure how to proceed. Should I install TexLive?

This is the header of the file I am trying to run:

--
title: "Assignment 1"
fontsize: 11pt
header-includes: \usepackage{fancyhdr}
geometry: "left=.5in,right=.5in,top=1in,bottom=1in"
output:
  pdf_document:
    latex_engine: xelatex
    md_extensions: +inline_notes
    number_sections: no
  word_document: default
mathfont: Palatino
monofont: Courier
mainfont: Palatino
sansfont: Helvetica
subtitle: \textbf{Due Wednesday, 11 September 2019 (beginning of class)}
fontfamily: mathpazo
---

And this is the error I continue to receive, without rendering of a PDF file:

output file: PBHLTH252-Assignment-1_post.knit.md

"C:/Program Files/RStudio/bin/pandoc/pandoc" +RTS -K512m -RTS PBHLTH252-Assignment-1_post.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash+inline_notes --output PBHLTH252-Assignment-1_post.tex --template "C:\Users\UYser\Documents\R\win-library\3.6\rmarkdown\rmd\latex\default-1.17.0.2.tex" --highlight-style tango --pdf-engine xelatex --variable graphics=yes --lua-filter "C:/Users/UYser/Documents/R/win-library/3.6/rmarkdown/rmd/lua/pagebreak.lua" --variable "compact-title:yes" tlmgr search --file --global "/Palatino." ! Package fontspec Error: The font "Palatino" cannot be found.

! kpathsea: Running mktextfm Palatino

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

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

Error: Failed to compile PBHLTH252-Assignment-1_post.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See PBHLTH252-Assignment-1_post.log for more info. In addition: Warning message: In parse_packages(logfile, quiet = c(TRUE, FALSE, FALSE)) : Failed to find a package that contains Palatino. Execution halted

I tried following this thread, https://github.com/yihui/tinytex/issues/81, with no success:

  1. Running this suggested code
tinytex::tlmgr_search("/Palatino[.](tfm|afm|mf|otf)")

results in:

package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable)

  1. Running this one
tinytex::tlmgr_install("multirow") 

gives me the following error:

tlmgr install Palatino. 'afm' is not recognized as an internal or external command, operable program or batch file. tlmgr update --self tlmgr.pl: package repository http://ctan.math.illinois.edu/systems/texlive/tlnet (not verified: gpg unavailable) tlmgr.pl: no self-updates for tlmgr available. tlmgr install Palatino. 'afm' is not recognized as an internal or external command, operable program or batch file.

Any help is appreciated!


回答1:


It looks like you got the template from a Mac user while you are on Windows. The fontnames are different there. Instead of Palatino you could use Palatino Linotype. I am not sure if Helvetica and Courier will work. If not, you could use Arial and Courier New.

However, that sounds like a rather ugly font combination. Palatino is a very fine font, but neither Helvertica/Arial nor Courier (New) fit well. Besides, I don't think that normal Palatino fonts are set-up to be used for math. You could use Asana Math instead, which comes with MikTeX/TinyTeX.




回答2:


I used to have similar problems. My solution sounds naive (or silly), but it worked perfectly for me. Instead of debugging, in RStudio:

  1. install rticles package
  2. start a new R Markdown file
  3. choose one of journal article templates such as PNAS Journal Article, Springer Journal Article, or Elsevier Journal Article...
  4. knit the template.

Then, it will be trying to automatically install missing LaTeX packages...

You may want to try a few journal templates. It worked for me, and I hope this will solve your problem as well. Enjoy it!



来源:https://stackoverflow.com/questions/57829865/unable-to-knit-pdf-receiving-tinytex-error-with-failed-tlmgr-search

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!