0

I have resorted to defining a table using inline-Latex in a Pandoc Markdown document. The reason is that I need to group table rows (using a horizontal line only between certain rows).

I'm trying to get pandoc-tablenos to work with this inline-Latex table, by doing the following:

  • Adding Table: Caption. {#tbl:id} below the table (with a single newline between this text and the last line of the inline Latex) (as described here)
    • Result: the verbatim text Table: Caption. {#tbl:id} is present in the output PDF (below the table) and tbl:id is not recognized as a valid ID

Example Pandoc markdown document with inline Latex table:

# Expressions

Test 123. Table:

\begin{footnotesize}
   \begin{tabular}{ | l l l | } \hline
      \textbf{Expression}        & \textbf{Meaning}            & \textbf{Associativity}     \\ \hline
      \texttt{e1 grouped by e2}  & Add a group to a grouping   & left    \\
      \texttt{e1 where e2}       & Filter a grouping           & left    \\ \hline
   \end{tabular}
\end{footnotesize}

Some more text. *I would like to reference the table here.*

I execute pandoc as follows to build a Latex document:

pandoc --standalone --from markdown -F pandoc-tablenos --pdf-engine=xelatex <input-file>.md -o <output-file>.tex
4
  • Please add some code, an example that demonstrate, what you have tried so far... – DG' Apr 26 '20 at 12:03
  • @DG' Good idea. I will do that. – runeks Apr 27 '20 at 9:51
  • Please add a small working pandoc document with an inline latex table. I suspect that you need to add the lable with \lable{tbl:id} but this is only a guess without the actual code – DG' Apr 27 '20 at 10:14
  • @DG' Done! I've also added the pandoc command that I use to convert the markdown to Latex. – runeks Apr 29 '20 at 6:57
1

You need to add the caption and table id within the latex table. Since you are using tabular and no floating environment, you have to use \captionof from the package caption. You can load that in the yaml-header:

---
header-includes: \usepackage{caption}
---

# Expressions

Test 123. Table:

\begin{footnotesize}
  \captionof{table}{A \LaTeX-table. \label{tbl:latex}}
  \begin{tabular}{ | l l l | } \hline
    \textbf{Expression}        & \textbf{Meaning}            & \textbf{Associativity} \\ \hline
    \texttt{e1 grouped by e2}  & Add a group to a grouping   & left                   \\
    \texttt{e1 where e2}       & Filter a grouping           & left                   \\ \hline
  \end{tabular}
\end{footnotesize}

Some more text. See table @tbl:latex

enter image description here

You can ignore the warning:

pandoc-tablenos: Bad reference: @tbl:latex.

It just means, that you haven't defined the label in pandoc-tablenos-syntax

2
  • Trying to reference a table labeled this way using @tbl:id in the Markdown document results in an error from pandoc-tablenos (Bad reference: @tbl:id.) when I try to convert using pandoc. – runeks Apr 29 '20 at 7:03
  • @runeks - You can ignore the warning – DG' May 11 '20 at 8:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.