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

\subtitle undefined with LaTeX default template #4675

Closed
maccadia opened this issue May 26, 2018 · 2 comments
Closed

\subtitle undefined with LaTeX default template #4675

maccadia opened this issue May 26, 2018 · 2 comments

Comments

@maccadia
Copy link

Hi,

When I override \maketitle using header-include with this code :

---
title:  "De la possibilité et de la réalité de l'introspection"
subtitle: "Une exploration intérieure"
author: "Archibald Dulapin"
header-includes:
  - |
    ```{=latex}
    \makeatletter
    \renewcommand{\maketitle}{%
        \@title

        \@author
        
        \@subtitle
    }
    \makeatother
    ```
...

I get the following error with pandoc 2.2.1:

$ pandoc test.yml -o test.pdf
Error producing PDF.
! Undefined control sequence.
\maketitle ...title \par \@author \par \@subtitle 
                                                  
l.73 \maketitle

It works if I use a modified default.latex template with :

\makeatletter
\providecommand\subtitle[1]{\renewcommand\@subtitle{#1}}
\providecommand\@subtitle{\@latex@error{No \noexpand\subtitle given}\@ehc}
\makeatother
\subtitle{$subtitle$}

I don't know if this code could have any side effect ; I don't understand it well enough. I got it from here.

As for a workaround, putting the \providecommands in header-include works.

@mb21
Copy link
Collaborator

mb21 commented May 27, 2018

Please ask questions this on pandoc-discuss. This tracker is for issues only.

(btw, not sure what you're asking anyway... seems like you got it working somehow)

@mb21 mb21 closed this as completed May 27, 2018
@maccadia
Copy link
Author

Hi, sorry if I wasn't clear.

My point is that the default.latex template could be improved with :

$if(subtitle)$
\makeatletter
\providecommand\subtitle[1]{\renewcommand\@subtitle{#1}}
\providecommand\@subtitle{\@latex@error{No \noexpand\subtitle given}\@ehc}
\makeatother
\subtitle{$subtitle$}
$endif$

instead of

$if(subtitle)$
\providecommand{\subtitle}[1]{}
\subtitle{$subtitle$}
$endif$

jgm pushed a commit that referenced this issue Jan 11, 2019
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants