phd_thesis_markdown icon indicating copy to clipboard operation
phd_thesis_markdown copied to clipboard

Table short-captions workaround

Open maawoo opened this issue 3 years ago • 0 comments

Hi all! Thought I should share my solution to include short-captions for tables as this is a known issue. The solution feels a bit hacky, but - for me at least - so does pretty much everything else in LaTeX.

First, I exclude the pandoc-tablenos filter so in my Makefile I use the --filter=pandoc-fignos and --filter=pandoc-secnos filters separately instead of --filter=pandoc-xnos, which includes all by default. In my text, I then include Markdown tables as usual but handle the caption and in-text references with LaTeX notation directly, hence the exclusion of tablenos. In text it looks like this:

\begin{table}[h]
\caption[This is a short caption that is automatically listed in the List of Tables.]{\label{table:my_table}This is a very 
long caption and appears in the text above the table.}
\end{table}

-----------------------------------------------------------
**Column 1**                                  **Column 2**                      
------------------------------------------ ----------------
Entry 1                                         'valid'                             

Entry 2                                         'clear'                             

Entry 3                                          False                             
-----------------------------------------------------------

So basically, it just creates an empty LaTeX table above the actual Markdown table. In the PDF it looks pretty much the same as how the caption would normally be printed and I haven't noticed any major problems. The LoT lists all short-captions as expected, which was my goal. Referencing tables in the text has to be done with LaTeX notation: \ref{table:my_table}

One issue is the numbering because both the empty LaTeX table and the Markdown table get counted. So for the next table I'd include the following line before the table to adjust the counting: \setcounter{table}{1}

Additionally, I'm using a prefix in the appendix. Figures are listed as Figure A-1, Figure A-2 and so on for Appendix A and with a different prefix for Appendix B of course. This works very well with the tag feature of pandoc-fignos. In case of my hacky table solution, I'm adding the following before my appendix table to change the prefix to "A-" and reset the counter.

\renewcommand{\thetable}{A-\arabic{table}}
\setcounter{table}{0}

Maybe this can help someone else!

Cheers, Marco

maawoo avatar Jun 09 '21 14:06 maawoo