LaTeX template: Render \subtitle (#5213)

Addresses closed issues #4675, #3896, #1327.

This renders `\subtitle` using the `etoolbox` package if `\subtitle` is not already
defined by the documentclass (as it is in beamer, KOMA, memoir classes).

 Based on an example from Enrico Gregorio, <https://tex.stackexchange.com/a/50186>.

Update list of LaTeX packages.

Note that `etoolbox` must be loaded outside the command definition.
Putting it inside causes an error if `\title` is placed after `\begin{document}`.
It's already loaded on LuaLaTeX/XeLaTeX in any case.
This commit is contained in:
Andrew Dunning 2019-01-11 14:17:53 -05:00 committed by John MacFarlane
parent 24a0d613a8
commit fd222b811b
2 changed files with 42 additions and 47 deletions

View file

@ -166,47 +166,46 @@ pandoc does not require them to be present:
[`parskip`] (for better inter-paragraph spaces),
[`xurl`] (for better line breaks in URLs),
[`bookmark`] (for better PDF bookmarks),
[`footnote`] (to fix footnotes in tables).
and [`footnote`] (to fix footnotes in tables).
[TeX Live]: http://www.tug.org/texlive/
[`amsfonts`]: https://ctan.org/pkg/amsfonts
[`amsmath`]: https://ctan.org/pkg/amsmath
[`lm`]: https://ctan.org/pkg/lm
[`ifxetex`]: https://ctan.org/pkg/ifxetex
[`ifluatex`]: https://ctan.org/pkg/ifluatex
[`listings`]: https://ctan.org/pkg/listings
[`fancyvrb`]: https://ctan.org/pkg/fancyvrb
[`longtable`]: https://ctan.org/pkg/longtable
[`booktabs`]: https://ctan.org/pkg/booktabs
[`graphicx`]: https://ctan.org/pkg/graphicx
[`grffile`]: https://ctan.org/pkg/grffile
[`geometry`]: https://ctan.org/pkg/geometry
[`setspace`]: https://ctan.org/pkg/setspace
[`xecjk`]: https://ctan.org/pkg/xecjk
[`hyperref`]: https://ctan.org/pkg/hyperref
[`ulem`]: https://ctan.org/pkg/ulem
[`babel`]: https://ctan.org/pkg/babel
[`bidi`]: https://ctan.org/pkg/bidi
[`mathspec`]: https://ctan.org/pkg/mathspec
[`unicode-math`]: https://ctan.org/pkg/unicode-math
[`polyglossia`]: https://ctan.org/pkg/polyglossia
[`fontspec`]: https://ctan.org/pkg/fontspec
[`upquote`]: https://ctan.org/pkg/upquote
[`microtype`]: https://ctan.org/pkg/microtype
[`csquotes`]: https://ctan.org/pkg/csquotes
[`natbib`]: https://ctan.org/pkg/natbib
[`biber`]: https://ctan.org/pkg/biber
[`biblatex`]: https://ctan.org/pkg/biblatex
[`bibtex`]: https://ctan.org/pkg/bibtex
[`biber`]: https://ctan.org/pkg/biber
[TeX Live]: http://www.tug.org/texlive/
[`wkhtmltopdf`]: https://wkhtmltopdf.org
[`weasyprint`]: http://weasyprint.org
[`prince`]: https://www.princexml.com/
[`upquote`]: https://ctan.org/pkg/upquote
[`microtype`]: https://ctan.org/pkg/microtype
[`parskip`]: https://ctan.org/pkg/parskip
[`xurl`]: https://ctan.org/pkg/xurl
[`bidi`]: https://ctan.org/pkg/bidi
[`bookmark`]: https://ctan.org/pkg/bookmark
[`booktabs`]: https://ctan.org/pkg/booktabs
[`csquotes`]: https://ctan.org/pkg/csquotes
[`fancyvrb`]: https://ctan.org/pkg/fancyvrb
[`fontspec`]: https://ctan.org/pkg/fontspec
[`footnote`]: https://ctan.org/pkg/footnote
[`geometry`]: https://ctan.org/pkg/geometry
[`graphicx`]: https://ctan.org/pkg/graphicx
[`grffile`]: https://ctan.org/pkg/grffile
[`hyperref`]: https://ctan.org/pkg/hyperref
[`ifluatex`]: https://ctan.org/pkg/ifluatex
[`ifxetex`]: https://ctan.org/pkg/ifxetex
[`listings`]: https://ctan.org/pkg/listings
[`lm`]: https://ctan.org/pkg/lm
[`longtable`]: https://ctan.org/pkg/longtable
[`mathspec`]: https://ctan.org/pkg/mathspec
[`microtype`]: https://ctan.org/pkg/microtype
[`natbib`]: https://ctan.org/pkg/natbib
[`parskip`]: https://ctan.org/pkg/parskip
[`polyglossia`]: https://ctan.org/pkg/polyglossia
[`prince`]: https://www.princexml.com/
[`setspace`]: https://ctan.org/pkg/setspace
[`ulem`]: https://ctan.org/pkg/ulem
[`unicode-math`]: https://ctan.org/pkg/unicode-math
[`upquote`]: https://ctan.org/pkg/upquote
[`weasyprint`]: http://weasyprint.org
[`wkhtmltopdf`]: https://wkhtmltopdf.org
[`xecjk`]: https://ctan.org/pkg/xecjk
[`xurl`]: https://ctan.org/pkg/xurl
Reading from the Web
@ -1361,10 +1360,7 @@ depending on the output format, but include the following:
...
`subtitle`
: document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and Word docx;
renders in LaTeX only when using a document class that supports
`\subtitle`, such as `beamer` or the [KOMA-Script] series (`scrartcl`,
`scrreprt`, `scrbook`).[^subtitle]
: document subtitle, included in HTML, EPUB, LaTeX, ConTeXt, and Word docx
`institute`
: author affiliations (in LaTeX and Beamer only). Can be a
@ -1403,15 +1399,6 @@ depending on the output format, but include the following:
: JSON representation of all of the document's metadata. Field
values are transformed to the selected output format.
[^subtitle]: To make `subtitle` work with other LaTeX
document classes, you can add the following to `header-includes`:
\providecommand{\subtitle}[1]{%
\usepackage{titling}
\posttitle{%
\par\large#1\end{center}}
}
Language variables
------------------

View file

@ -350,7 +350,15 @@ $if(title)$
\title{$title$$if(thanks)$\thanks{$thanks$}$endif$}
$endif$
$if(subtitle)$
\providecommand{\subtitle}[1]{}
$if(beamer)$
$else$
\usepackage{etoolbox}
\makeatletter
\providecommand{\subtitle}[1]{% add subtitle to \maketitle
\apptocmd{\@title}{\par {\large #1}}{}{}
}
\makeatother
$endif$
\subtitle{$subtitle$}
$endif$
$if(author)$