3

I am trying to convert a tex-document into a docx-file to share it with some colleagues who do not use TeX and will not do so in the (near) future. At the moment, the best possibility seems to be Pandoc for this endeavour. One reason why I use TeX in the first place are nicely formatted tables using e.g. booktabs or dcolumn. This is especially useful for the readability of longer tables. However, I am having problems with converting tables using Pandoc which are using \multicolumn or rely on dcolumn for cell alignment. Pandoc simply ignores the whole table and reads it as raw text.

Would it be possible to make Pandoc read the table as a table while ignoring dcolumn and \multicolumn without manually editing the whole document?

Here is a MWE:

\documentclass{article}
\usepackage{booktabs}
\usepackage{dcolumn}
\begin{document}
\begin{table}
\centering
\begin{tabular}{D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1} D{.}{.}{-1}}
\toprule
\multicolumn{1}{c}{Col A} & \multicolumn{1}{c}{Col B}& \multicolumn{1}{c}{Col C}& \multicolumn{1}{c}{Col D}& \multicolumn{1}{c}{Col E}\\
\midrule
0.0 & 5.146 & 5.151 & 5.156 & 5.151\\
0.1 & 5.57  & 5.516 & 5.61  & 5.704\\
0.2 & 5.758 & 5.762 & 5.978 & 6.122\\
0.3 & 5.959 & 5.95  & 6.296 & 6.514\\
0.5 & 6.223 & 6.223 & 6.851 & 7.237\\
1.0 & 6.616 & 6.615 & 7.974 & 8.848\\
\bottomrule
\end{tabular}
\caption{This is a table using booktabs, dcolumn and multicolumn}
\end{table}
\begin{table}
\centering
\begin{tabular}{ccccc}
\toprule
Col F & Col G& Col H& Col I& Col J\\
\midrule
0.0 & 5.146 & 5.151 & 5.156 & 5.151\\
0.1 & 5.57  & 5.516 & 5.61  & 5.704\\
0.2 & 5.758 & 5.762 & 5.978 & 6.122\\
0.3 & 5.959 & 5.95  & 6.296 & 6.514\\
0.5 & 6.223 & 6.223 & 6.851 & 7.237\\
1.0 & 6.616 & 6.615 & 7.974 & 8.848\\
\bottomrule
\end{tabular}
\caption{This is a simpler table using only booktabs}
\end{table}
\end{document}

Pandoc does not convert the first table but the second table using the command line pandoc -f latex -t docx document.tex -o document.docx.
Please note that \multicolumn is only used here to skip the alignment enforced by dcolumn. There could be more complicated examples.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.