Siirry sisältöön

Like everybody who has tried it knows, if you put two consecutive \hline commands in a LaTeX tabular table, there will be a gap in the vertical lines. For example, the following code produces such a result:

\begin{tabular}{|l|l|} \hline Name & Age \\ \hline\hline John & 35 \\ Mary & 42 \\ \hline \end{tabular} 

However, here’s a quick (and dirty) solution to this problem: use line break spacing. \\[space] will use a custom line break height, and by reducing the height by 1em, we can nicely shrink the gap produced by just inserting a single line break between the \hlines.

That is not quite enough, though. You’ll need to add ampersands to push the right-side line to its correct place. But after that, the result is just what you wished for.

The following code illustrates this:

\begin{tabular}{|l|l|} \hline Name & Age \\ \hline & \\[-1em]\hline John & 35 \\ Mary & 42 \\ \hline \end{tabular} 

Mainokset