Graphics, Figures & Tables ⇒ Vertical Lines exceed Table
-
- Posts: 6
- Joined: Sun Sep 09, 2012 6:08 pm
Vertical Lines exceed Table
I've got two rather simple tables. The data is all in the right place, but the vertical lines exceed the end of both tables. Also I have no vertical line at the end of first row of the second table. I'm sorry to post such a primitive question. Even tried to search the forum, but failed. So thought it would be much much easier to just ask an expert to help me out.
Please find attached source and output files.
Thank you!
Sonia
- Attachments
-
- samplefile.pdf
- (35.2 KiB) Downloaded 218 times
-
- samplefile.tex
- (1.37 KiB) Downloaded 203 times
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Vertical Lines exceed Table
This is the cause of your problems: don't put the
\label
inside the tabular
. It can't label anything there since it needs to follow \caption
and worse: it starts a new cell. In your second table the \multicolumn
s only span two cells instead of three which is why you're missing two cells in that line.Since you're mentioning aesthetics I'd suggest a few things:
- use less vertical lines, I'd use none
- you're loading booktabs; use it
- use siunitx for the alignment of the numbers.
Code: Select all
\documentclass{article}
\usepackage{booktabs,siunitx}
\setlength\heavyrulewidth{1pt}
\begin{document}
\begin{table}[ht]
\centering\small
\caption{insert caption here}\label{UM_result1}
\begin{tabular}{l*5{S[table-format=2.1]}}
\toprule
& \multicolumn{2}{c}{Men} & \multicolumn{2}{c}{Women} \\
\cmidrule(lr){2-3}\cmidrule(lr){4-5}
Age & {Leg (n=34)} & {Arm (n=14)} & {Leg (n=29)} & {Arm (n=12)} \\
Mean & 45.0 & 30.3 & 37.0 & 25.8 \\
SD & 21.5 & 8.1 & 18.0 & 5.8 \\
Min & 19.0 & 24.0 & 20.0 & 21.0 \\
Max & 84.0 & 46.0 & 76.0 & 42.0 \\
\bottomrule
\end{tabular}
\end{table}
blhablah blha
blah blha blha
\begin{table}[ht]
\centering\small
\caption{insert caption here}\label{UM_result2}
\begin{tabular}{
l
*2{
S[table-space-text-post=\,\% *,table-format=2]
S[table-format=1.2]
S[table-format=1.2]
}
}
\toprule
& \multicolumn{3}{c}{Leg model} & \multicolumn{3}{c}{Arm model} \\
\cmidrule(lr){2-4}\cmidrule(lr){5-7}
& {Mean difference} & {$r$} & {$r^2$} & {Mean difference} & {$r$} & {$r^2$} \\
Mass & 2\,\% & 0.39 & 0.15 & 37\,\% * & 0.64 & 0.41 \\
Mass-Fat & 7\,\% * & 0.60 & 0.36 & 36\,\% * & 0.89 & 0.80 \\
Regression & 0\,\% & 0.68 & 0.46 & 2\,\% & 0.92 & 0.85 \\
Approximation & 1\,\% & 0.88 & 0.78 & 0\,\% & 0.99 & 0.99 \\
\bottomrule
\end{tabular}
\end{table}
\end{document}
-
- Posts: 6
- Joined: Sun Sep 09, 2012 6:08 pm
Re: Vertical Lines exceed Table
