r bookdown::pdf_book fails to parse book.bib file with natbib - r

we are trying to write a bookdown publication hosted at https://github.com/guilhermejacob/context/
i've tried removing different entries from my book.bib and each time get the error below. the bookdown::tufte_html_book command works without issue, only the bookdown::pdf_book dies for me despite what appears to be nothing wrong with my book.bib citation file?
https://github.com/guilhermejacob/context/blob/master/book.bib
i've googled around and all of the tex questions point to things like missing author= or year= or title= tags while each of my entries has all of them.
i get the same error when i have an empty book.bib file, so something else in the folder must be configured improperly? but i have no idea where to look because the natbib seems to have a issue with book.bib? i'd appreciate any pointers about what to try..thanks
Latexmk, John Collins, 5 Sep. 2016. Version 4.48
! Package natbib Error: Bibliography not compatible with author-year citations.
Error: Failed to compile context.tex. See context.log for more info.
In addition: Warning messages:
1: running command '"C:\Users\AnthonyD\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\latexmk.exe" -v' had status 1
2: The LaTeX package latexmk was not correctly installed.
3: running command '"C:\Users\AnthonyD\AppData\Local\Programs\MIKTEX~1.9\miktex\bin\latexmk.exe" -v' had status 1
4: running command '"xelatex" -halt-on-error -interaction=batchmode "context.tex"' had status 1
Execution halted

i deleted the .aux file as suggested here. solved the problem. no clue why.
http://arhetoric.blogspot.com/2011/10/natlibs-usage-fixing-some-errors.html?showComment=1338381839988

Related

Running R tikzDevice with tinytex: Help troubleshooting `! LaTeX Error: File `tikz.sty' not found`

I am trying to generate a tikz plot using R/ggplot2 via the tikzDevice package. I've had to wade through many errors as I figured out how to install R and tinytex on my docker image, but I've run into the following error which has simply stumped me.
When I run the code that generates my plot, this is the error I get:
Error in getMetricsFromLatex(TeXMetrics, verbose = verbose) :
TeX was unable to calculate metrics for:
\char77
Run the following commands for diagnosis:
tikzTest()
tikzTest("\\char77")
Common reasons for failure include:
* The string contains a character which is special to LaTeX unless
escaped properly, such as % or $.
* The string makes use of LaTeX commands provided by a package and
the tikzDevice was not told to load the package.
The TeX and log files used for the calculation can help diagnose the
problem. If these files are missing, rerun the plot and make sure to
keep the R session open.
TeX file: tikzStringWidthCalc.tex
Log file: tikzStringWidthCalc.log
Calls: <Anonymous> ... descentDetails.text -> grid.Call -> <Anonymous> -> getMetricsFromLatex
Execution halted
And the output of tikzDevice::tikzTest() is as follows:
Active compiler:
/home/jovyan/.TinyTeX/bin/x86_64-linux/pdflatex
pdfTeX 3.141592653-2.6-1.40.23 (TeX Live 2021)
kpathsea version 6.3.3
Measuring dimensions of: A
Running command: '/home/jovyan/.TinyTeX/bin/x86_64-linux/pdflatex' -interaction=batchmode -halt-on-error -output-directory '/tmp/RtmpLhckyy/tikzDevice29a5e00452e' 'tikzStringWidthCalc.tex'
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=pdflatex)
restricted \write18 enabled.
entering extended mode
TeX was unable to calculate metrics for:
A
Contents of TeX file tikzStringWidthCalc.tex:
\documentclass[10pt]{article}
\usepackage{tikz}
\usepackage[active,tightpage,psfixbb]{preview}
\PreviewEnvironment{pgfpicture}
\setlength\PreviewBorder{0pt}
\usepackage{tikz}
\usepackage[T1]{fontenc}
\usetikzlibrary{calc}
\batchmode
\begin{document}
\begin{tikzpicture}
\node[inner sep=0pt, outer sep=0pt, scale=1] (TeX) {A};
\path let \p1 = ($(TeX.east) - (TeX.west)$),
\n1 = {veclen(\x1,\y1)} in (TeX.east) -- (TeX.west)
node{ \typeout{tikzTeXWidth=\n1} };
\end{tikzpicture}
\end{document}
Contents of log file tikzStringWidthCalc.log:
This is pdfTeX, Version 3.141592653-2.6-1.40.23 (TeX Live 2021) (preloaded format=pdflatex 2022.3.16) 16 MAR 2022 23:30
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**tikzStringWidthCalc.tex
(/tmp/RtmpLhckyy/tikzDevice29a5e00452e/tikzStringWidthCalc.tex
LaTeX2e <2021-11-15> patch level 1
L3 programming layer <2022-02-24> (/home/jovyan/.TinyTeX/texmf-dist/tex/latex/base/article.cls
Document Class: article 2021/10/04 v1.4n Standard LaTeX document class
(/home/jovyan/.TinyTeX/texmf-dist/tex/latex/base/size10.clo
File: size10.clo 2021/10/04 v1.4n Standard LaTeX file (size option)
)
\c#part=\count185
\c#section=\count186
\c#subsection=\count187
\c#subsubsection=\count188
\c#paragraph=\count189
\c#subparagraph=\count190
\c#figure=\count191
\c#table=\count192
\abovecaptionskip=\skip47
\belowcaptionskip=\skip48
\bibindent=\dimen138
)
! LaTeX Error: File `tikz.sty' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)
Enter file name:
! Emergency stop.
<read *>
l.4 ^^M
Here is how much of TeX's memory you used:
235 strings out of 480236
3181 string characters out of 5895451
287032 words of memory out of 5000000
18278 multiletter control sequences out of 15000+600000
469259 words of font info for 28 fonts, out of 8000000 for 9000
14 hyphenation exceptions out of 8191
34i,0n,38p,138b,36s stack positions out of 5000i,500n,10000p,200000b,80000s
! ==> Fatal error occurred, no output PDF file produced!
As you can see I am using tinytex, but I have installed the recommended packages for this setup as described in the tinytex documentation (i.e., I've already ran tlmgr install pgf preview xcolor).
I've read every post I could possibly find on this subject but am coming up empty. Any tips to help me troubleshoot this problem would be greatly appreciated.
it would help if you had a minimum reproducible example to check on our end.
This said, the message LaTeX Error: File `tikz.sty' not found. suggests that a possible solution would be for you to throw:
library(tinytex)
tlmgr_search('/tikz.sty') # search for tikz.sty
tlmgr_install('pgf') # install the psnfss package
tlmgr_update() # update everything
since tlmgr_search('/tikz.sty') gives you
tlmgr search --file --global "/tikz.sty"
tlmgr.pl: package repository https://ctan.mirror.garr.it/mirrors/ctan/systems/texlive/tlnet
pgf:
texmf-dist/tex/latex/pgf/frontendlayer/tikz.sty
but then you already installed pgf... that's where tikz.sty lives.

I can't knit my documents into PDF in RStudio

I have to use RStudio to knit a report in PDF but when I try to knit the document with the packages required in a chunk in Rmarkdown it shows me this error:
tlmgr search --file --global '/multirow.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 `multirow.sty' not found.
! Emergency stop.
<read *>
Errore: Failed to compile questionario_sulla_responsabilita_222222.tex. See https://yihui.name/tinytex/r/#debugging for debugging tips. See questionario_sulla_responsabilita_222222.log for more info.
Inoltre: Warning message:
In system2("tlmgr", args, ...) :
running command ''tlmgr' search --file --global '/multirow.sty'' had status 1
Execution interrupted
how can I fix this? I am using a MacBook Pro
I tried to updated everything I can and I've tried to install everything from the beginning but it jeeps showing me the same error message
To wrap the comments to the question up and following the solution at Yihui Xie's page - see also here for a discussion.
In short ...
tinytex::reinstall_tinytex()
... should do the trick.
Explanation: It seems that {tinytex}/Texlive is using a rolling package repository that moves to a new version each year while the local installment does not. The reinstallation does move the local installment forward.
An alternative solution: There seems to be an alternative solution that involves making the TexLive package repo un-rolling - i.e. using a fixed version - which might help: link

Failed to compile test.tex after successful TinyTeX installation via tinytex

I am trying to install TinyTeX via the convenient tinytex-package for R.
After having had a few issues with getting the installation to run smoothly on MacOS, the install_tinytex() function now executes properly and ends with the statement:
TinyTeX installed to /Users/X/Library/TinyTeX
However, when trying to execute pdflatex('test.tex') to test the installation, the console instead returns:
Error: Failed to compile test.tex
Apparently the installation did not execute properly. Am I missing something or isn't this supposed to work after a successful TinyTeX installation via tinytex?
The texput.log displays the following error message:
This is pdfTeX, Version 3.14159265-2.6-1.40.19 (TeX Live 2018) (preloaded format=pdflatex 2018.11.2) 2 NOV 2018 14:47
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**test.tex
! Emergency stop.
<*> test.tex
Here is how much of TeX's memory you used: 3 strings out of 494585
99 string characters out of 6174649 51539 words of memory out of
5000000 3743 multiletter control sequences out of 15000+600000 3640
words of font info for 14 fonts, out of 8000000 for 9000 14
hyphenation exceptions out of 8191 0i,0n,0p,1b,6s stack positions out
of 5000i,500n,10000p,200000b,80000s
! ==> Fatal error occurred, no output PDF file produced!
The quoted error message indicates that there is no file test.tex in your current working directory. Either create a sample LaTeX file or use an existing file. If you do not have any LaTeX file available, you can try
pdflatex('sample2e.tex')
This will translate smaple2e.tex, which should be part of every LaTeX distribution.

Trouble with Pandoc installation on Ubuntu 14.04LTS for using with R Markdown

This question is a corollary of my attempts to get some experience with creating reproducible reports from R Markdown documents via knitr and rmarkdown R packages. While it seems that .Rmd => HTML conversion is automated from within RStudio (Knit HTML button), my attempt to do the same outside of RStudio (Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")') failed due to, according to the message, lack of pandoc on my system. This is most likely false, since RStudio somehow managed to perform the conversion. Therefore, it is most likely an access and/or path issue.
Without knowledge of where RStudio maintains pandoc and details about the access, I have decided to install pandoc myself. Unfortunately, sudo apt-get install pandoc has not been very helpful, due to the fact that current version of pandoc in Ubuntu's trusty repository (14.04LTS) is 1.12.2.1. According to rmarkdown's message, version 1.12.3 or higher is required. "Not a big deal", I have thought, and followed instructions on installing pandoc in case of too old version in repository (http://johnmacfarlane.net/pandoc/installing.html). That requires installing the Haskell platform, which is pretty big and which output is rather verbose. After some time, I finally has been greeted with the following failure message:
[ 6 of 57] Compiling Text.Pandoc.Readers.TeXMath ( src/Text/Pandoc/Readers/TeXMath.hs, dist/build/Text/Pandoc/Readers/TeXMath.o )
src/Text/Pandoc/Readers/TeXMath.hs:30:38:
Ambiguous occurrence `readTeXMath'
It could refer to either `Text.Pandoc.Readers.TeXMath.readTeXMath',
defined at src/Text/Pandoc/Readers/TeXMath.hs:56:1
or `Text.TeXMath.readTeXMath',
imported from `Text.TeXMath' at src/Text/Pandoc/Readers/TeXMath.hs:33:1-19
(and originally defined in `Text.TeXMath.Parser')
Failed to install pandoc-1.12.4.2
cabal: Error: some packages failed to install:
pandoc-1.12.4.2 failed during the building phase. The exception was:
ExitFailure 1
pandoc-citeproc-0.3.1 depends on pandoc-1.12.4.2 which failed to install.
Firstly, I'm not sure how to fix it. Secondly, I very much suspect that there should be an easier way to enjoy generating reproducible reports with rmarkdown and pandoc than this. Your advice will be appreciated!
UPDATE (see comments):
Rscript -e 'library(rmarkdown); render("knitr-example-slides-1.Rmd")'
processing file: knitr-example-slides-1.Rmd
|....... | 11%
ordinary text without R code
|.............. | 22%
label: setup (with options)
List of 1
$ include: logi FALSE
Quitting from lines 6-8 (knitr-example-slides-1.Rmd)
Error in eval(expr, envir, enclos) : object 'opts_chunk' not found
Calls: render ... handle -> withCallingHandlers -> withVisible -> eval -> eval
Execution halted
Basically, #daroczig answered this question in his comment above, so I will repeat it here, plus will add an answer to the relevant minor question on the issue, appeared after the main question's issue fix.
1) "A binary compiled version of Pandoc is already shipped with RStudio, so you can simply create a symlink, so that you could easily use that outside of the RStudio eco-system: https://github.com/rstudio/rmarkdown/blob/master/PANDOC.md#newer-systems-debianubuntufedora";
2) I have fixed the error, experienced after applying the advice above (see my comment), by calling opts_chunk() using explicit package reference: knitr::opts_chunk(), following guidelines here: http://rmarkdown.rstudio.com/authoring_migrating_from_v1.html (thanks to #Yihui for pointing me to this document in a different question: Transitioning research project to knitr-based setup).

Error with knitr on texmaker

I am trying for the first time to get knitr running on texmaker, I followed this documentation and I am on Windows 7. However, when I compile, I get the following error stack:
Process started
Error in readLines(if (is.character(input2)) { : cannot open the connection Calls: <Anonymous> -> knit -> readLines
In addition: Warning message: In readLines(if (is.character(input2)) { : cannot open file 'try_easy.Rnw': No such file or directory
Execution halted
Process exited with error(s)
I tried to google it, but only found references to linux/unix, which were not helpful for my case. Following is my short test document:
\documentclass[a4paper]{article}
\begin{document}
<<a>>=
x=rnorm(100)
<<b>>=
<<a>>
mean(x)
#
\end{document}
It's my first time on stackoverflow, so please tell me if you need more information or I did something wrong. Thank you very much.
Update
Hello everyone,
I managed to find out my mistake. For the sake of future google-searchers, I had saved the file as a .tex instead as .rnw. Saving as rnw solved it. Since I cannot answer my own questions, I edit it here.
This error happens when the file is saved as a .tex instead of a .Rnw, as the compiler does not know that he should "knitr-compile" files that have the .tex handle, unless you specifically set him up like that.

Resources