jgm / pandoc

Universal markup converter

Home Page:https://pandoc.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[latex] Column spacing is incorrect (\tabcolsep) [2.11.2.0]

gabyx opened this issue · comments

Pandoc generates latex column spacing in latex output for a nCols=3-column like this:

IMO: \columnwidth - 2\tabcolsep) * \real{0.41} should be \columnwidth - (2*(nCols - 1))\tabcolsep) * \real{0.41}
Latex inserts for each column a \tabcolsep at the beginning and the end. So the space between two adjacent columns is 2\tabcolsep.

Bonus: It might be nice, to put the format (\columnwidth - 2\tabcolsep) * \real{0.30}}\raggedright directly into the column. e.g. (also removing unnecessary minipage if possible, might still stay...)

\begin{longtable}[]{@{}>{\raggedright}p{(\columnwidth - 2\tabcolsep) * \real{0.30}}ll@{}}

Test:

+----------------------------+---------------------------------------+----------------------------+
| A                          | B                                     | A                          |
+============================+=======================================+============================+
| sdasdasda                  | asdasdasdasd                          | sdasdasda                  |
|                            |                                       |                            |
+----------------------------+---------------------------------------+----------------------------+

Table: Title
pandoc -f markdown -t latex Test.md
\begin{longtable}[]{@{}lll@{}}
\caption{Title}\tabularnewline
\toprule
\begin{minipage}[b]{(\columnwidth - 2\tabcolsep) * \real{0.30}}\raggedright
A\strut
\end{minipage} &
\begin{minipage}[b]{(\columnwidth - 2\tabcolsep) * \real{0.41}}\raggedright
B\strut
\end{minipage} &
\begin{minipage}[b]{(\columnwidth - 2\tabcolsep) * \real{0.30}}\raggedright
A\strut
\end{minipage}\tabularnewline
\midrule
\endfirsthead
\toprule
\begin{minipage}[b]{(\columnwidth - 2\tabcolsep) * \real{0.30}}\raggedright
A\strut
\end{minipage} &
\begin{minipage}[b]{(\columnwidth - 2\tabcolsep) * \real{0.41}}\raggedright
A\strut
\end{minipage}\tabularnewline
\midrule
\endhead
\begin{minipage}[t]{(\columnwidth - 2\tabcolsep) * \real{0.30}}\raggedright
sdasdasda\strut
\end{minipage} &
\begin{minipage}[t]{(\columnwidth - 2\tabcolsep) * \real{0.41}}\raggedright
asdasdasdasd\strut
\end{minipage} &
\begin{minipage}[t]{(\columnwidth - 2\tabcolsep) * \real{0.30}}\raggedright
sdasdasda\strut
\end{minipage}\tabularnewline
\bottomrule
\end{longtable}

I've tried to implement the strategy recommended in the stackexchange post you linked to in the other issue. Minipages are only used when necessary, and width and alignment information is put in the column descriptors at the outset.
This gives nicer latex output, at least.

This is awesome! Thanks a lot John!