Referencing inline-Latex tables in Pandoc Markdown

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

• Please add some code, an example that demonstrate, what you have tried so far...
– DG'
Apr 26, 2020 at 12:03
• @DG' Good idea. I will do that. Apr 27, 2020 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, 2020 at 10:14
• @DG' Done! I've also added the pandoc command that I use to convert the markdown to Latex. Apr 29, 2020 at 6:57

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:

---
---

# 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


You can ignore the warning:

It just means, that you haven't defined the label in pandoc-tablenos-syntax
• 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. Apr 29, 2020 at 7:03