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

Use new LaTeX templates from Pandoc #1510

Closed
adunning opened this issue Jan 10, 2019 · 11 comments · Fixed by #1563
Closed

Use new LaTeX templates from Pandoc #1510

adunning opened this issue Jan 10, 2019 · 11 comments · Fixed by #1563

Comments

@adunning
Copy link
Contributor

This is following on the discussion from #1509. The default-1.17.0.2.tex template is based is on the version at https://github.com/jgm/pandoc-templates/blob/fea830fcd27b4df2a337ac774daa7d4bbca00866/default.latex, which shows that the differences boil down to the following sections:

The last bit is the only significant difference in the repository's template. I think the intent of this was to fix the problem that Pandoc doesn't render \subtitle by default. This could be done more efficiently by adding the following via header-includes:

% Render \subtitle in \maketitle
\usepackage{titling}
\providecommand{\subtitle}[1]{%
  \posttitle{%
    \par\end{center}
    \begin{center}\large#1\end{center}
  }%
}

This should be fixed upstream; I'll take care of it.

@adunning
Copy link
Contributor Author

adunning commented Jan 11, 2019

Simpler code, submitted in jgm/pandoc#5213:

\usepackage{etoolbox}
\makeatletter
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
  \apptocmd{\@title}{\par {\large #1 \par}}{}{}
}
\makeatother

@adunning
Copy link
Contributor Author

The subtitle fix is now in the upstream template. I still don't entirely understand what the footnote protection is intended to achieve, but I think we can assume it's unnecessary, because this certainly works:

pandoc -o test.pdf << EOT

---
title: "Test^[test]"
---

test

EOT

@adunning
Copy link
Contributor Author

The subtitle fix (and other improvements) will be in the Pandoc 2.6, which will be out soon. For earlier versions, you could simply add my etoolbox solution above through header-includes without having to maintain separate templates.

If you also want to retain the compression of \maketitle (I don't think its appearance is desirable, but putting that aside), I could come up with something that could also be inserted this way.

@yihui
Copy link
Member

yihui commented Mar 13, 2019

Yes, as I said in #1509 (comment), I'm all for dropping our homemade LaTeX template if there is a more elegant way through header-includes. Thank you!

BTW, RStudio 1.2.x (not officially released yet) has bundled Pandoc 2.6 on Windows only. For *nix platforms, the Pandoc version is still 2.3.1. For RStudio 1.1.x, it is still Pandoc 1.9.x. When you patch the default template, you'll need to consider these information.

@adunning
Copy link
Contributor Author

That's excellent. Allowing each version of Pandoc to use its built-in template will fix the problems that the custom templates were attempting to solve.

If you're concerned about the subtitle not appearing for users of Pandoc 1.16 (when the problem first appeared) through 2.5, you could add the etoolbox code from above through header-includes if the version of Pandoc is less than 2.6. That will avoid potential conflicts with the titling package while changing the appearance minimally. This is completely backwards-compatible; adding the code through header-includes in versions before Pandoc 1.16 won't do any harm.

@yihui
Copy link
Member

yihui commented Mar 14, 2019

Sounds great! I guess I won't have time for this in the next few months, but I'd welcome a pull request!

@jemus42
Copy link

jemus42 commented Apr 4, 2019

Quick question as I found this issue through searching before I submit a different issue:

Am I understanding correctly that this is related to my surprise given that subtitle: my subtitle in the YAML header of document to be rendered through pdf_document actually gives be a subtitle even though as of now that is not a documented argument in pdf_document() (which also does not have ...)?

I compared this to html_document() which at least has ... and says it passes those to html_document_base() – I'm since trying to figure out how pdf_document knows about the subtitle: YAML option and doesn't throw an error due to an unknown argument.

(For completeness: I'm on pandoc ‘2.7.1’)

@adunning
Copy link
Contributor Author

adunning commented Apr 4, 2019

Right – the subtitle variable is covered through the LaTeX template. There are a number of similar things not in the Rmarkdown documentation; see the Pandoc manual.

yihui pushed a commit that referenced this issue Nov 25, 2019
…s too hard to maintain (#1563)

* Patch pandoc LaTeX template

Patch the pandoc LaTeX template to include the document subtitle (unnecessary with pandoc 2.6 onwards) using `--include-in-header` rather than overwriting its built-in template, avoiding compability problems with newer versions of pandoc. Closes #1510.

* Missing quotes

* Fix changelog typo

* Ensure self-contained is set for LaTeX

* Less verbose graphics setting

* move news of #1563 to v1.18

* cosmetic

* force --self-contained regardless of the template

* factor out pandoc_path_arg(rmarkdown_system_file(...)) to system_file_arg()

* support compact titles via a header include compact-title.tex

I didn't consider ef41eb4. I think it is a relatively minor issue and not worth the effort (if we have to bring it back, we need to test has_yaml_parameter(, 'author') and has_yaml_parameter(, 'date'), and conditionally include more titling hacks)

* mention the PR #252 which introduced the titling hacks

* cosmetic

* shouldn't change the value of the `template` argument when it is `default`

* add Andrew Dunning to the list of contributors

* also closes #1649
@yihui
Copy link
Member

yihui commented Nov 25, 2019

I have finished tweaking the PR #1563 and merged it. Thanks a lot for your contribution! I'm really happy about the outcome!

@adunning
Copy link
Contributor Author

Thank you for the revisions and all your work on this!

@github-actions
Copy link

github-actions bot commented Nov 3, 2020

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 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants