Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Printing issue for JSS style #132

benkeser opened this issue Aug 10, 2017 · 5 comments

Printing issue for JSS style #132

benkeser opened this issue Aug 10, 2017 · 5 comments


Copy link

@benkeser benkeser commented Aug 10, 2017

I'm running into a situation where printing certain objects does not render to .tex properly. I can't sort out what is causing the error and I'm not certain whether this is an issue with rticles or with pandoc. Here's a MWE:

RMD document:


  • name: A girl has no name
    affiliation: An affiliation
    address: >
    An address
    email: \email{}
    formatted: '\pkg{apackage}'
    plain: 'apackage'
    short: 'apacakge'
    abstract: >
    blah blah blah
    formatted: [key1]
    plain: [key2]
    documentclass: jss
    classoption: article
    output: rticles::jss_article


if(!("SuperLearner" %in% row.names(installed.packages()))){

This non-exported function prints fine.


This one does not.


When I build, the relevant part of the .tex file looks like

This one does not.


R> SuperLearner:::predict.SL.glm

\textbackslash{}begin\{CodeOutput\} function (object, newdata, \ldots{})
\{ if (is.matrix(newdata)) \{ newdata = \} pred
\textless{}- predict(object = object\$object, newdata = newdata, type =
``response'') pred \} \textless{}environment:
namespace:SuperLearner\textgreater{} \textbackslash{}end\{CodeOutput\}


Any guesses as to why the \textbackslash{} is being introduced?


This comment has been minimized.

Copy link

@yihui yihui commented Aug 10, 2017

Yes, it is caused by the dollar sign. It is a known issue (see #10 and #49), but no one seems to have time to fix it. Technical background: jgm/pandoc#2493


This comment has been minimized.

Copy link

@JanMarvin JanMarvin commented Nov 14, 2017

Could we add a latex raw attribute to hook_chunks like: ```{=latex} if not using kable? Added that in jss_article, but it breaks if a chunk uses cache=TRUE. This should fix the problem above and new a behavior of pandoc 2.0 which treats underscores similar to the dollar sign:

# test.Rmd
pandoc test.Rmd -f markdown+raw_tex -t native
[Para [Str "\\begin{foo}",SoftBreak,Str "a_b",SoftBreak,Str "\\end{foo}"]]


pandoc test.Rmd -f markdown+raw_tex -t native
[RawBlock (Format "latex") "\\begin{foo}\na_b\n\\end{foo}"]

This comment has been minimized.

Copy link

@yihui yihui commented Nov 14, 2017

@JanMarvin Thanks! The new raw attributes in Pandoc 2.0 sounds like the right way to go.


This comment has been minimized.

Copy link

@jimvine jimvine commented Dec 5, 2017

Until the Pandoc 2.0 solution comes in, this worked for me as a workaround, where I had one CodeOutput CodeChunk that had unbalanced $ signs. I added, immediately after it, a CodeChunk with just one dollar sign in it:

  # $

This gets placed after the r code block, in a normal markdown area.

That does leave a spurious $ on the page, but at least with the # if someone tries to paste it into R it won't do anything! It is, of course, pretty hack-ish, but if I could turn the manual code block white I would almost be happy with this!

With this forcing the desired CodeChunk to be correctly converted into valid LaTeX, I have then been able to use the retained .tex version, strip out this manual hack, and re-compile that to PDF to get a 'clean' version. For some reason, opening the .tex version in RStudio and clicking "Compile PDF" did not work for me, so I called texi2pdf from the console:


One other oddity: this threw an error about the bibliography file, saying "BibTeX errors:
I couldn't open database file myfile.bib.bib". The solution to that was to find the bibliography definition at the end of the .tex version and change it from:




This comment has been minimized.

Copy link

@yihui yihui commented Jul 3, 2018

Fixed. Please try devtools::install_github('rstudio/rticles'). Note that it will require Pandoc 2.2.1. You can use the Preview version of RStudio if you do not want to install Pandoc separately:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
4 participants
You can’t perform that action at this time.