-
Notifications
You must be signed in to change notification settings - Fork 4
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
error while using knitr with papeR #35
Comments
It seems you are using markdown to produce a PDF. With markdown you cannot use LaTeX syntax and hence cannot use Does this solve your problem? I realized that the part on |
yes I'm using rmarkdown, and the code generated by xtable works just fine if I copy/paste it (after generating it with results="tex" to get it instead of using results="asis") in fact, since you don't really use the booktabs option for anything else than printing this latex comment, using the following code is a workaround: then I can use those xtable commands it seems (I've just figured this out) NB: but of course in my rmarkdown header I'm adding, just in case:
So I'm confused about why you think I cannot use rmarkdown for LaTeX. (rmarkdown != markdown) |
Ok, I see. That is great. I wasn't aware that one can combine markdown and latex by using rmarkdown. Funny enough, however, that all LaTeX commands are ignored if one switches to another output... I'll try to fix your issue [> easy way should be to remove one %]. Actually, it might even make more sense to issue a note in R in some way. However, these can be suppressed in knitr... Of note, one also has to switch Finally, don't you think this is actually a bug in rmarkdown? Why would one want to escape |
I have no clue, hence my "obscure reason" comment about rmarkdown escaping %%. Given how quickly you answered, I guess I did make the right choice ;-) side note: rmarkdown is actually quite pleasant apart from this bug, it helps generating "LaTeX" papers quite nicely without the hassle of LaTeX's syntax (well it isn't really a hassle when you are used to programming, but markdown texts are way easier to (naturally) read than LaTeX's). One of the only things missing in rmarkdown (imho) is that they didn't port complex table syntax yet, hence you're back to LaTeX code for complex tables (unless you can use xtable or alike of course). With rmarkdown you can generate also html, or presentation etc. But yes, if you include specific codes (LaTeX code or html code), it gets ignored if you switch the output, but I guess that's ok for now. I hardly ever use specific language code, and more and more packages now support both generating html and LaTeX code. |
Ok, changing the output to a However, any message regarding booktabs might be nonsense in knitr as knitr would print all messages and warnings in the PDF but cannot do this as the PDF cannot be created without |
Hello,
I have compiling error while trying to use knitr and papeR to produce a pdf (through LaTeX).
The latex comments such as
%% Output requires \usepackage
seem to be escaped to %% during the rmardown/knitr processing, and LaTeX therefore fails to compile. I cannot see any option in your code to prevent such comments from being generated, and I fail to understand/find how to prevent those % to be escaped.
with the following code:
here is the part where LaTeX fails during pandoc generation:
! LaTeX Error: Can be used only in preamble.
See the LaTeX manual or LaTeX Companion for explanation.
Type H for immediate help.
...
l.122 %% Output requires \usepackage
pandoc: Error producing PDF
I'm using RStudio 1.0.143, rmarkdown 1.5, knitr 1.15.1, R 3.3.2 on a Mac OS X 10.10.5
The text was updated successfully, but these errors were encountered: