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

Parsing with multiple documentclasses #1180

Closed
ekstroem opened this issue Mar 12, 2016 · 2 comments
Closed

Parsing with multiple documentclasses #1180

ekstroem opened this issue Mar 12, 2016 · 2 comments
Labels
bug Bugs
Milestone

Comments

@ekstroem
Copy link

Hi,

(I asked this question on SO as well but after digging more into it I think a more appropriate question may be here).

I have a problem similar to #713 but I cannot just change the order of my documentclass lines. I'd like to include an example of complete LaTeX code inside an Rnw document that is parsed using knitr.

My .Rnw file is shown here (I really want to include a bunch of R code as well but this minimal example shows my problem)

\documentclass{article}

\begin{document}    
Recursiveness, see     
\begin{verbatim}
\documentclass{article}
\begin{document}
Recursiveness
\end{document}
\end{verbatim}

\end{document}

When I run knitr test.Rnw I get a .tex file where the second documentclass is replaced (see below, where the top of the .tex file is shown). I'm pretty sure that this is knitr that replaces the litaral string \documentclass with its own macro that and it does not realize that it shouldn't be parsen when inside the verbatim environment.

\documentclass{article}
\IfFileExists{upquote.sty}{\usepackage{upquote}}{}
\begin{document}

Recursiveness, see 

\begin{verbatim}
\documentclass{article}\usepackage[]{graphicx}\usepackage[]{color}
%% maxwidth is the original width if it is less than linewidth
%% otherwise use linewidth (to make sure the graphics do not exceed the margin)
\makeatletter
\def\maxwidth{ %
  \ifdim\Gin@nat@width>\linewidth
    \linewidth
  \else
    \Gin@nat@width
  \fi
}
\makeatother

Is it possible to circumvent this? I tried to insert a zero-width space character in the middle of documentclass but that gave me a bunch of headaches with the parsing.

@yihui yihui added the bug Bugs label Mar 14, 2016
@yihui yihui added this to the v1.13 milestone Mar 14, 2016
@yihui yihui closed this as completed in 7d0f080 Mar 14, 2016
@ekstroem
Copy link
Author

Cheers!

@github-actions
Copy link

This old thread has been automatically locked. If you think you have found something related to this, please open a new issue by following the issue guide (https://yihui.org/issue/), and link to this old issue if necessary.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bugs
Projects
None yet
Development

No branches or pull requests

2 participants