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

Matrices in subsection titles fails (md -> PDF) #3932

Open
avonmoll opened this issue Sep 22, 2017 · 6 comments
Open

Matrices in subsection titles fails (md -> PDF) #3932

avonmoll opened this issue Sep 22, 2017 · 6 comments

Comments

@avonmoll
Copy link

Version: 1.16.0.2

Files:
mwe.md

## $\begin{bmatrix}0 &0 &0\end{bmatrix}$

header

\usepackage{amsmath}

Output:

$ pandoc mwe.md -o test.pdf -H header`
! Argument of \@sect has an extra }.
<inserted text>
                \par
l.56 ...}0 \&0 \&0\textbackslash{}end\{bmatrix\}}}

pandoc.exe: Error producing PDF

My expected output is a PDF with a subsection heading with this matrix:
image

@jgm
Copy link
Owner

jgm commented Sep 22, 2017

Reproduced in dev version.

@jgm
Copy link
Owner

jgm commented Sep 23, 2017

Current output:

\subsection{\texorpdfstring{\(\begin{bmatrix}0 &0 &0\end{bmatrix}\)}{\textbackslash{}begin\{bmatrix\}0 \&0 \&0\textbackslash{}end\{bmatrix\}}}\label{beginbmatrix0-0-0endbmatrix}}

Note that this works fine:

\subsection[foo]{\texorpdfstring{\(\begin{bmatrix}0 &0 &0\end{bmatrix}\)}{\textbackslash{}begin\{bmatrix\}0 \&0 \&0\textbackslash{}end\{bmatrix\}}}\label{beginbmatrix0-0-0endbmatrix}}

@jgm
Copy link
Owner

jgm commented Sep 23, 2017

There's an approach here:
https://tex.stackexchange.com/questions/228274/matrix-in-section-heading
but it would be cumbersome to implement automatically.

@jgm
Copy link
Owner

jgm commented Sep 23, 2017

Adding \protect before \begin and \end worked for me:

\subsection{\texorpdfstring{\(\protect\begin{bmatrix}0 &0 &0\protect\end{bmatrix}\)}{\textbackslash{}begin\{bmatrix\}0 \&0 \&0\textbackslash{}end\{bmatrix\}}

@jgm
Copy link
Owner

jgm commented Sep 23, 2017

Adding the \protect to the Markdown source also works (and doesn't require changes to pandoc):

## $\protect\begin{bmatrix}0 &0 &0\protect\end{bmatrix}$

@jgm
Copy link
Owner

jgm commented Sep 23, 2017

Looks like adding \protect before each \begin and \end in math in a section heading would do the trick.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants