[Tex/LaTex] How to make LaTeX (tabu, hhline) tables keep rowheights

spacingtablestabuvertical alignment

i want to typeset a long table across several columns / pages and want the table rows to keep register. my code looks basically like this:

\documentclass{book}
\usepackage{pagegrid}
\usepackage{fontspec}
\usepackage{tabu}
\usepackage{hhline}
\usepackage{multicol}
\setlength{\parskip}{0mm}
\setlength{\parindent}{0mm}
\setlength{\arrayrulewidth}{0.15mm}
\setlength{\doublerulesep}{0.5mm}
\begin{document}

\begin{multicols}{3}

{\setlength{\tabcolsep}{2mm}
\begin{tabu} to \linewidth { | X[1,l,m] | }
\hhline{|=|}
1 first line \\
\hhline{|=|}
2 secondline \\
\hhline{|=|}
\end{tabu}}

\vfill
\columnbreak

{\setlength{\tabcolsep}{2mm}
\begin{tabu} to \linewidth { | X[1,l,m] | }
\hhline{|-|}
1 first line \\
\hhline{|-|}
2 secondline \\
\hhline{|-|}
\end{tabu}}

\vfill
\columnbreak

{\setlength{\tabcolsep}{2mm}
\begin{tabu} to \linewidth { | X[1,l,m] | }
\hhline{|~|}
1 first line \\
\hhline{|~|}
2 secondline \\
\hhline{|~|}
\end{tabu}}

\end{multicols}
\end{document}

in reality those two-line tables really have 50 rows and extend over the entire page height. i need to insert double horizontal lines at various points in the tables, and of course those need space and add to table height—which causes the rows accross the pages to get out of sync. i should add that each partial table will have different numbers of lines occurring at different points, so using 'vertical glue' between rows (if that's possible) to make each stretch to page height wouldn't be ideal.

is there any way to force all rows to maintain height? in the past when faced with this problem in HTML/CSS, i always tried to typeset all the typographic elements but hid them from view where not needed. this greatly simplified things because you get away without many calculations, you just switch on what's need at a certain point. i'm not aware of any way to do that in (Xe)LaTeX.

how can i make all table rows keep in sync and 'add lines between table cells where needed', as it were?

Best Answer

You can make hhline always use a double line space:

\documentclass{book}
\usepackage{pagegrid}
\usepackage{fontspec}
\usepackage{tabu}
\usepackage{hhline}
\usepackage{multicol}
\setlength{\parskip}{0mm}
\setlength{\parindent}{0mm}
\setlength{\arrayrulewidth}{0.15mm}
\setlength{\doublerulesep}{0.5mm}
\makeatletter
\def\HH@add#1{\toks@\expandafter{\the\toks@#1\HH@box\z@\z@}}
\makeatletter
\begin{document}

\begin{multicols}{3}

{\setlength{\tabcolsep}{2mm}
\begin{tabu} to \linewidth { | X[1,l,m] | }
\hhline{|=|}
1 first line \\
\hhline{|=|}
2 secondline \\
\hhline{|=|}
\end{tabu}}

\vfill
\columnbreak

{\setlength{\tabcolsep}{2mm}
\begin{tabu} to \linewidth { | X[1,l,m] | }
\hhline{|-|}
1 first line \\
\hhline{|-|}
2 secondline \\
\hhline{|-|}
\end{tabu}}

\vfill
\columnbreak

{\setlength{\tabcolsep}{2mm}
\begin{tabu} to \linewidth { | X[1,l,m] | }
\hhline{|~|}
1 first line \\
\hhline{|~|}
2 secondline \\
\hhline{|~|}
\end{tabu}}

\end{multicols}
\end{document}
Related Question