0

Markdown tables can be limiting for some purposes (no merged cells, no custom placement of horizontal lines)... More complex tables can be created using other tools. I am looking to insert different content, but provide it with a Quarto markdown Table caption, which is correctly being numbered and can be cross referenced as a table.

What I tried:

  • Quarto only seems to pick up a markdown Table caption, e.g.

    Table: Table caption {#tbl-label}
    
    \begin{longtable}{| p{.20\textwidth} | p{.80\textwidth} |} 
    \hline
    foo & bar \\ \hline 
    foo & bar \\ \hline
    \caption{Your caption here}
    \label{tab:myfirstlongtable}
    \end{longtable}
    
    

    as a numbered Table caption if it is followed by something that looks like table markdown. Otherwise, it is just printed literally.

  • I experimented with a div, which can be used to combine multiple tables under one heading:

    ::: {#tbl-label layout-ncol=1}
    
    \begin{longtable}{| p{.20\textwidth} | p{.80\textwidth} |} 
    \hline
    foo & bar \\ \hline 
    foo & bar \\ \hline
    \caption{Your caption here}
    \label{tab:myfirstlongtable}
    \end{longtable}
    
    Table caption
    :::
    

    This works (almost) perfectly where the Main Table caption is generated. However, Quarto keeps inserting an (a) below the main title, i.e. a place holder for a subtitle.

What I achieved:

  • I got it to "work" for raw Latex as in this anser. Such table, however, must be cross referenced with raw latex as well. Moreover, this output does not carry over to html.

I am therefore looking for a way where the table becomes cross referenceable in markdown. I would also favor a possibility to render the table through a graphic, because that could also transfer to HTML output.

For experimenting, I include a working code snippet here:

Table: Latex table with Quarto caption {#tbl-label1}

\begin{longtable}{| p{.20\textwidth} | p{.80\textwidth} |} 
\hline
foo & bar \\ \hline 
foo & bar \\ \hline
\end{longtable}

::: {#tbl-label2 layout-ncol=1}
    
\begin{longtable}{| p{.20\textwidth} | p{.80\textwidth} |} 
\hline
foo & bar \\ \hline 
foo & bar \\ \hline
\end{longtable}

Latex table within div with Quarto Caption

:::
 
\begin{longtable}{| p{.20\textwidth} | p{.80\textwidth} |} 
\hline
foo & bar \\ \hline 
foo & bar \\ \hline
\caption{Latex table with Latex caption}
\label{tbl-label3}
\end{longtable}

Table @tbl-label1 is an attempt to assign a Quatro caption to a Latex table. If `Table:` is not followed by table markdown, the caption is interpreted and printed as literal text, however.

Table @tbl-label2 encloses a latex table in a a quarto div with a single column. A numbered Table caption is provided, however, an empty table subtitle (a) is included even though none was specified. In addition, the latex table is counted as an extra table.

Table \ref{tbl-label3} inserts both table and caption as raw latex. Such table must be referred to using raw latex code as well (`\ref{tbl-label3}`).
vanadium
  • 178
  • 5

0 Answers0