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

Correctly consume the longtable environment in LaTeX input #2411

Closed
HalosGhost opened this issue Sep 23, 2015 · 1 comment
Closed

Correctly consume the longtable environment in LaTeX input #2411

HalosGhost opened this issue Sep 23, 2015 · 1 comment

Comments

@HalosGhost
Copy link

In working with pandoc, I have stumbled on an annoying asymmetry. Using pandoc to convert rst to latex, pandoc uses the longtable environment. E.g.:

======= =====
example table
======= =====
stuff   other
random  junk
======= =====
\begin{longtable}[c]{@{}ll@{}}
\toprule
example & table\tabularnewline
\midrule
\endhead
stuff & other\tabularnewline
random & junk\tabularnewline
\bottomrule
\end{longtable}

However, if you attempt to feed pandoc a longtable in latex input and convert it to something else, it will be garbage:

\begin{longtable}[c]{@{}ll@{}}
\toprule
example & table\tabularnewline
\midrule
\endhead
stuff & other\tabularnewline
random & junk\tabularnewline
\bottomrule
\end{longtable}
<p>[c]<span>@ll@</span> example &amp; tablestuff &amp; otherrandom &amp; junk</p>

(Note that the above example actually fed the LaTeX output from pandoc directly back into itself, but that any use of the longtable environment fails to be parsed).

In fact, it seems that pandoc only supports the tabular environment for tables (for latex input). However, the tabular environment does not span pages in PDF output. Resultingly, the only way to have a latex source file for pandoc that will also be used for PDF output that uses tables is to do something like the following:

\usepackage{ifxetex,longtable}
\begin{document}
\ifxetex\let\tabular\longtable\let\endtabular\endlongtable\fi
\begin{tabular}[h]{l|l|l}
…
\end{tabular}
\end{document}

The main line of note in the snippet above is the use of an if command (which is specific to the output engine) that conditionally redefines tabular to be longtable. If Pandoc were to, instead of needing this shockingly ugly workaround, simply consume the longtable environment (which does not seem too far out-of-scope since pandoc itself generates longtable environments), this whole situation could be made much simpler.

@jgm jgm closed this as completed in 72e71a1 Sep 23, 2015
@jgm
Copy link
Owner

jgm commented Sep 23, 2015 via email

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