Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Pandoc allows referencing images via inline Latex commands. However, it seems it does not work for tables. I'm aware of several workarounds, including manipulating a resulting TeX file manually, but is there a way, for example via inline Latex, to get pandoc to output Latex/PDF/... with automatic table references, like the following (which does not work):

See table \ref{example}.

----------
my  table
--- ------
a   1
b   2
----------
Table \label{example}: An example that does not work.
share|improve this question

1 Answer 1

See table \ref{my_table}.

Table: (table title) \label{my_table}

-----------------------
Header1 Header2 Header3
------- ------- -------
item1   item2   item3
-----------------------

The result of the conversion can be generated by using the web interface of pandoc. The LaTeX output is somewhat verbose

See table \ref{my_table}.

\begin{longtable}[c]{@{}lll@{}}
\caption{(table title) \label{my_table}}\tabularnewline
\toprule
\begin{minipage}[b]{0.09\columnwidth}\raggedright\strut
Header1
\strut\end{minipage} &
\begin{minipage}[b]{0.09\columnwidth}\raggedright\strut
Header2
\strut\end{minipage} &
\begin{minipage}[b]{0.09\columnwidth}\raggedright\strut
Header3
\strut\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{0.09\columnwidth}\raggedright\strut
Header1
\strut\end{minipage} &
\begin{minipage}[b]{0.09\columnwidth}\raggedright\strut
Header2
\strut\end{minipage} &
\begin{minipage}[b]{0.09\columnwidth}\raggedright\strut
Header3
\strut\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{0.09\columnwidth}\raggedright\strut
item1
\strut\end{minipage} &
\begin{minipage}[t]{0.09\columnwidth}\raggedright\strut
item2
\strut\end{minipage} &
\begin{minipage}[t]{0.09\columnwidth}\raggedright\strut
item3
\strut\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

Compare with the ConTeXt output:

See table \ref{my_table}.

\placetable{(table title) \label{my_table}}
\starttable[|lp(0.10\textwidth)|lp(0.10\textwidth)|lp(0.10\textwidth)|]
\HL
\NC Header1
\NC Header2
\NC Header3
\NC\AR
\HL
\NC item1
\NC item2
\NC item3
\NC\AR
\HL
\stoptable

As you can see, in both cases the "table title" is correctly marked as the caption of the generated table.

share|improve this answer
1  
Welcome to TeX.SX! It would be great if you can extend your answer, for example providing the code for real implementation. –  Claudio Fiandrino Jan 20 at 7:44
    
@user44431 Would you mind to elaborate your answer? –  pushpen.paul Jul 19 at 16:48
    
@user44431 I hope you do not mind I added the output of Pandoc. Also, try pandoc is very useful for trying the conversion without installing anything. –  Bordaigorl Oct 17 at 11:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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