I find that when use pandoc --listings
, to render code chunk with latex listings package, it will change character, as github says, it is a bug. So pandoc had introduced \passthrough
to process it.
I decide to update my pandoc to 2.2.1 version, the newest current. But it pops error like this,
! Undefined control sequence.
<recently read> \passthrough
I thought it may be because of listings
package too old without \passthrough
. so I update to texlive 2018. it still had this problem. I submit this problem in https://github.com/rstudio/bookdown/issues/591
I had searched some result as,
but none can solve. Any suggestion? Thank you.
I think I should add this command by myself. texupdate too slow.
This issue is not relevant to your LaTeX distribution, so there is no need to reinstall or update LaTeX.
Pandoc 2.x puts verbatim text in \passthrough{}
defined at
https://github.com/jgm/pandoc-templates/blob/052428151/default.latex#L169
if the --listings
flag is used in the command line.
$ echo '`text`' | pandoc -f markdown -t latex --listings
\passthrough{\lstinline!text!}
A few possible solutions (from the easiest to hardest):
Set the option template
to null
in bookdown::pdf_book
, i.e.,
bookdown::pdf_book:
template: null
This means using Pandoc's built-in Pandoc template, which has defined \passthrough
.
Install the development version of rmarkdown: devtools::install_github('rstudio/rmarkdown')
, in which I have added the command.
Define the command \passthrough
in a custom Pandoc LaTeX template (https://bookdown.org/yihui/bookdown/templates.html), and use the custom template via the template
option of bookdown::pdf_book()
.