I have your set up and can reproduce the problem, but with the cryptocode.sty file before it gets to pkg.sty.
title: "LaTeX headers"
author: "Richard Careaga"
date: "8/31/2019"
output:
pdf_document:
includes:
in_header: totp_preamble.tex
This is a vanilla LaTeX document with the include in the working directory.
It first fails because cryptocode.sty is not installed (and I need to update my repository to 2019). TexLive purports to do the repository update, but the same message occurs. So, I re-install MacTex, using the package installer. As usual, it's a slow, 20-minute download from Tug and the install takes about 10 minutes after that.
While I'm waiting I try from the terminal
tlmgr search --file --global '/cryptocode.sty'
and get the same error message.
If you are still on 2018, this would explain the inability to find pkg.sty
.
In the RMarkdown tab, do you get the following message?
> ==> rmarkdown::render('/Users/rc/projects/demo/latexheader.Rmd', encoding = 'UTF-8'); |.................................................................| 100% ordinary text without R code /usr/local/bin/pandoc +RTS -K512m -RTS latexheader.utf8.md --to latex --from markdown+autolink_bare_uris+ascii_identifiers+tex_math_single_backslash --output latexheader.tex --template /Users/rc/Library/R/3.6/library/rmarkdown/rmd/latex/default-1.17.0.2.tex --highlight-style tango --pdf-engine pdflatex --include-in-header totp_preamble.tex --variable graphics=yes --variable 'geometry:margin=1in' --variable 'compact-title:yes' processing file: latexheader.Rmd output file: latexheader.knit.md tlmgr search --file --global '/cryptocode.sty' tlmgr: Remote repository is newer than local (2018 < 2019) Cross release updates are only supported with update-tlmgr-latest(.sh/.exe) --update Please see https://tug.org/texlive/upgrade.html for details. ! LaTeX Error: File `cryptocode.sty' not found. ! Emergency stop. Error: Failed to compile latexheader.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See latexheader.log for more info. In addition: Warning message: In system2("tlmgr", args, ...) : running command ''tlmgr' search --file --global '/cryptocode.sty'' had status 1 Execution halted
I'll report back when I'm finished with the update.