LaTeX: Tables and Columns and Units, oh my

In summary, the user is trying to create a table in LaTeX with all entries in a column having the same units without having to type them for each column. They have tried using the siunitx package, but encountered an error with the \bgroup command. After receiving a suggestion, they have figured out a solution by using the S column type and specifying the units in the table itself.
  • #1
NeoDevin
334
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
  • #2
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.
 

Related to LaTeX: Tables and Columns and Units, oh my

1. What is LaTeX and why is it used for creating tables and columns?

LaTeX is a typesetting system used for creating high-quality documents, particularly in the fields of mathematics, science, and engineering. It is used for creating tables and columns because it allows for precise control over the layout and formatting of these elements, making it ideal for creating technical documents with complex tables and columns.

2. How do I create a table in LaTeX?

To create a table in LaTeX, you will need to use the "tabular" environment, which allows you to specify the number of columns, alignment, and content for each cell in the table. You can also use various commands, such as "hline" and "multicolumn", to add horizontal lines and merge cells, respectively.

3. Can I add units to my table columns in LaTeX?

Yes, you can add units to your table columns in LaTeX by using the "siunitx" package. This package provides commands for formatting numbers and units in a consistent and professional manner, making it a popular choice for scientific and technical documents.

4. How can I make my table columns evenly spaced in LaTeX?

To make your table columns evenly spaced in LaTeX, you can use the "tabularx" package, which allows you to specify the overall width of the table and automatically adjusts the column widths to fit the specified width. You can also use the "tabular*" environment, which allows you to specify the width of each column individually.

5. Is it possible to include graphics or images in my table in LaTeX?

Yes, it is possible to include graphics or images in your table in LaTeX by using the "graphicx" package. This package provides commands for inserting images into your document, and you can also use these commands within the "tabular" environment to include images in your table cells.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
988
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
Back
Top