-
Notifications
You must be signed in to change notification settings - Fork 524
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
Text wrapping can mess up latex templaes #490
Comments
The So this may be something else. I can't reproduce with current template any line wrapping for articles when putting very long title. Can you provide a reproducible example ? |
I think this might work. I created an elsevier journal article with the current CRAN version of rticles. I changed the title to a long string. In the .tex file the title is wrapped in line 122-124 \title{Short PaperShort PaperShort PaperShort PaperShort PaperShort
PaperShort PaperShort PaperShort PaperShort PaperShort PaperShort
PaperShort PaperShort PaperShort PaperShort PaperShort PaperShort Paper} (weirdly, it is not wrapped inline 46, no idea why) In this second example, I extracted the elsevier template and modified it to add a latex comment in line 189 % $title$ % In the resulting .tex file, the comment is interpolated and broken in lines 119 - 122 % Short PaperShort PaperShort PaperShort PaperShort PaperShort
PaperShort PaperShort PaperShort PaperShort PaperShort PaperShort
PaperShort PaperShort PaperShort PaperShort PaperShort PaperShort
Paper % Amusingly, the rendered PDF shows these lines in the text 🤣 |
I can reproduce what you see with older Pandoc version like 2.7.3 or 2.10 I believe Going to new line in a LaTeX command is something allowed I believed and I don't think it has ever caused an issue in the passed (@yihui do you remember something ?) Doing something like
is pretty specific as the Pandoc's variable will be field in a commented line. Pandoc's does not seem to account to that, and so the wrapping will happen and cause issue because the new line won't have comment. I would think this is a Pandoc limitation. We could tweak our If you want to comment a line in a Pandoc's template so that it does not apply during rendering, there is a specific syntax for that BTW https://pandoc.org/MANUAL.html#comments:
Is this causing any specific issue or did you just report because you were surprised by the behavior (which is awesome too) ? |
It is allowed.
I'd strongly recommend using the template comment syntax instead of LaTeX comment. The latter can generate unpredictable results that are not necessarily comments. The former is guaranteed to work. |
Yes, it is a relatively niche and specific failure case, but it is realistic, as I encountered this live when teaching LaTeX templating and a student had commented out a couple of template lines that didn't quite work. As it's usual for LaTeX, the error messages were obscure and it took us a while to understand what was going on. So it's possible to get this during development process if one is not aware of pandoc-style comments. My vote would be to add |
Commenting out lines in a Pandoc's template as part of development process seems a usual practice, but comment syntax for templates is
It seems to me that changing to |
The (new?) default pandoc behaviour of wrapping long lines can cause issues in templates if there are comments.
For example, if the template has something like this
% \title{$title$}
and if
title
is long enough to reach the line-wrap character length, then this gets interpolated into something like% \title{This is a very long title that pandoc will wrap into a new line}
This can create all sorts of errors that are very hard to debug. I encountered this issue during a tutorial on creating LaTeX templates and a student was trying different things and commenting out some of them.
Auto wrap also caused issues in bookdown and distill and was solved by adding
--wrap=preserve
to pandoc arguments.By filing an issue to this repo, I promise that
xfun::session_info('rticles')
. I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version:remotes::install_github('rstudio/rticles')
.I understand that my issue may be closed if I don't fulfill my promises.
The text was updated successfully, but these errors were encountered: