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

Latex reader fails parse nested tables #4746

Closed
krobelus opened this issue Jun 29, 2018 · 7 comments
Closed

Latex reader fails parse nested tables #4746

krobelus opened this issue Jun 29, 2018 · 7 comments

Comments

@krobelus
Copy link

This should be valid latex, however it fails to parse with pandoc compiled from today's master branch. I'm looking into the latex reader, maybe someone can give me pointers where this can be fixed

input: tables.tex

\begin{tabular}{c c}
  \begin{tabular}{c} a \\ \end{tabular}
  &
  \\
\end{tabular}

Executing pandoc tables.tex gives me this error:

Error at "source" (line 5, column 1):
unexpected Tok "source" (line 5, column 1) (CtrlSeq "end") "\\end"
expecting end of input
\end{tabular}
^

pandoc 2.2.1
Compiled with pandoc-types 1.17.5, texmath 0.11, skylighting 0.7.2

@mb21
Copy link
Collaborator

mb21 commented Jun 29, 2018

maybe someone can give me pointers where this can be fixed

Should be around parseTableRow .

@krobelus
Copy link
Author

krobelus commented Jul 1, 2018

Should be around parseTableRow.

Thanks, I created this fix: e91b74c

Right now there are two problems I'm facing with this.

Firstly, I don't know how to add the column prefixes and suffixes to each cell (as in e91b74c#diff-1c5206ea07dccd86de1ea3be10ff30d9L2632). I'm not sure how to get the tokens from an already parsed table cell. Alternatively one could somehow insert the prefix and suffix tokens into the token stream. I don't see how this is possible currently.

Secondly, we would need to settle on which characters to treat as LaTeX control characters (and not parse as strings in inline - see
e91b74c#diff-1c5206ea07dccd86de1ea3be10ff30d9R1907). Right now I only do it for '&'.
Maybe it should be all of Readers.LaTeX.specialChars but I guess if we don't, the reader is more permissive in the sense that it automatically escapes some special characters if they don't make sense otherwise.

@mb21
Copy link
Collaborator

mb21 commented Jul 3, 2018

I guess @jgm is more familiar with the LaTeX reader...

@aronfiechter
Copy link

I'm facing the same issue right now using pandoc 2.9.2.1.

My table has a header that is a tabular to make it multiline and right aligned:

\begin{table}[ht]
    \begin{tabular}{@{}lr@{}}
        \toprule
        \textbf{Simple header} & \textbf{\begin{tabular}[c]{@{}r@{}}Multiline\\ header \\ right aligned\end{tabular}} \\
        \midrule
        Foo     &  123 \\
        Bar     &  456 \\
        \bottomrule
    \end{tabular}
\end{table}

Are there plans to fix this? Or is there perhaps an extension that can circumvent or solve this problem in the meantime?

@leenamurgai
Copy link

You might not need to have a nested tabular to achieve what you want, here's an example of side by side tables:
https://tex.stackexchange.com/questions/2832/how-can-i-have-two-tables-side-by-side

@aronfiechter
Copy link

You might not need to have a nested tabular to achieve what you want, here's an example of side by side tables:
https://tex.stackexchange.com/questions/2832/how-can-i-have-two-tables-side-by-side

I agree!

However in my specific case I use pandoc for parsing third party LaTeX source in a text analysis pipeline (to extract document data for research purposes).
So I have no control on the LaTeX source in parsing.

@gussmith23
Copy link

Just ran into this as well!

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

5 participants