tomduck / pandoc-tablenos

A pandoc filter for numbering tables and table references.
GNU General Public License v3.0
107 stars 8 forks source link

How to use table numbering but link a .png file as a table. #30

Open PhilKohn opened 3 years ago

PhilKohn commented 3 years ago

I have large regression tables that I would like to include. I have to label them as "table" but i can't link a png file to the #tbl:1 reference. That can, as far as I can see, only be done with the #fig:1 reference. but then It obviously says figure. not table, and also shows in the figures table at the front of my document. is there a known workaround?

henricombrink commented 3 years ago

I have exactly the same problem. I workaround/fix for this would be very much appreciated.

PhilKohn commented 3 years ago

Hey, so doesn’t seem to work unfortunately. I solved it with latex commands you can include a latex table from a different .Tex file by writing \input{file path} or with \include{file path}. Have a look here:

https://tex.stackexchange.com/questions/246/when-should-i-use-input-vs-include

so what i did was make a Latex table and Input it in my markdown file. You can use \label{tbl:reference} in your Tex file and xnos will recognize it as a table. It’ll be the same as doing {#tbl:reference}.

Another solution I haven’t tried yet is to include a png through latex syntax and use \label{tbl:reference} as you would in the first solution. Don’t know if that works, I just had that idea and might try it myself. I think the important part is to somehow use \label{tbl:reference} to specify that it is a table and not a figure.

henricombrink commented 3 years ago

Thanks @PhilKohn for your response.

I normally use rmarkdown to generate my latex/pdf documents. I however battle with collaborators who are not willing to move away from word, so working in this format is challenging when I need to work with others. I recently discovered https://manubot.org/, which is a great tool for collaborative writing. Unfortunately, it parses to html first. I have complex statistical summaries, which I just can not get to give me well formatted tables using markdown or html syntax. This is where I though I would just generate a image of the formatted table and include that. Manubot uses the pandoc-tablenos filter, hence me needing a solution.

Apologies if I am stating the obvious, but have you tried using rmarkdown with the bookdown package? The combination should be able to solve your problem if you do not mind working in Rstudio (you could also use the command line). You can either generate your table in a code chuck within R or use the code chunk preamble to load an existing file and then generate the .tex file if you use another statistical coding language. Bookdown's figure/table captioning is excellent.