LaTeX LaTeX: Tables and Columns and Units, oh my

AI Thread Summary
A user sought a way to create a LaTeX table where all entries in a column share the same units without repeating the unit for each entry. Initially, they encountered an error using the siunitx package due to incorrect syntax. After troubleshooting, they successfully implemented a solution using the S column type from siunitx, allowing them to specify the unit once for the entire column. This method works effectively as long as the numerical entries are of uniform length.
NeoDevin
Messages
334
Reaction score
2
I'm trying to make a table in LaTeX in which all the entries of a column have the same units, without having to type them for each column. (Before you say it, yes, I know I could just put the units in the column heading, but I don't want to).

I tried:
Code:
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{center}\begin{tabular}{|>{\SI\bgroup}c<{\egroup{\centi m}}|c|c|c|}\hline
0.1 & 0.2 & 0.3 & 0.4 \\ \hline
0.5 & 0.6 & 0.7 & 0.8 \\ \hline
\end{tabular}\end{center}
\end{document}

Which gives:
Code:
! Package siunitx Error: Invalid character `\bgroup ' in numerical input.

Any suggestions?
Thanks in advance.
 
Physics news on Phys.org
Figured it out.

If anyone else is interested
Code:
\documentclass{article}
\usepackage{siunitx}
\begin{document}
\begin{center}\begin{tabular}{|S<{\, \si{\centi m}}|c|c|c|}\hline
0.1 & 0.2 & 0.3 & 0.4 \\ \hline
0.5 & 0.6 & 0.7 & 0.8 \\ \hline
\end{tabular}\end{center}
\end{document}
Works as long as the numbers are all the same length.
 

Similar threads

Replies
4
Views
3K
Replies
3
Views
2K
Replies
9
Views
2K
Replies
3
Views
3K
Replies
2
Views
6K
Back
Top