1

What what be the best way of making "ID" vertically centered in the header in the table below?

Also, are there any suggestions or recommendations that anyone would have to make this table more aesthetically pleasing? Thanks!

table1

\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\begin{document}

\begin{table}
\caption{Specific Acid Added to Samples}
\label{Acid_Added}
\centering
\begin{tabular}{ >{\bfseries}c  S[table-format=2.2]  S[table-format=2.2]  S[table-format=1.2] }
\toprule
ID & {Specific Acid} & {Spread} & {Specific Acid} \\
& {Weight [\si{\mg}]} & {Weight [\si{\g}]} & {Conc [\si{\mg\per\g}]} \\
\midrule
1   &0.20   &19.96  &0.01\\
2   &0.40   &20.00  &0.02\\
3   &1.00   &19.98  &0.05\\
4   &2.00   &20.00  &0.10\\
5   &4.00   &20.00  &0.20\\
6   &10.00  &20.00  &0.50\\
\bottomrule
\end{tabular}
\end{table}

\end{document}
1

Here are two versions of your table in which I vertically centered ID using the \thead command from the makecell package:

enter image description here

\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\begin{document}

\begin{table}
\caption{Specific Acid Added to Samples}
\label{Acid_Added}
\centering
\begin{tabular}{ >{\bfseries}c  S[table-format=2.2]  S[table-format=2.2]  S[table-format=1.2] }
\toprule
\thead{ID} & {\thead{Specific Acid\\ Weight [\si{\mg}]}} & {\thead{Spread\\ Weight [\si{\g}]}} & {\thead{Specific Acid\\Conc [\si{\mg\per\g}]}} \\
\midrule
1   &0.20   &19.96  &0.01\\
2   &0.40   &20.00  &0.02\\
3   &1.00   &19.98  &0.05\\
4   &2.00   &20.00  &0.10\\
5   &4.00   &20.00  &0.20\\
6   &10.00  &20.00  &0.50\\
\bottomrule
\end{tabular}
\end{table}


\begin{table}
\renewcommand{\theadfont}{\normalsize}
\caption{Specific Acid Added to Samples}
\label{Acid_Added}
\centering
\begin{tabular}{ >{\bfseries}c  S[table-format=2.2]  S[table-format=2.2]  S[table-format=1.2] }
\toprule
\thead{ID} & {\thead{Specific Acid\\ Weight [\si{\mg}]}} & {\thead{Spread\\ Weight [\si{\g}]}} & {\thead{Specific Acid\\Conc [\si{\mg\per\g}]}} \\
\midrule
1   &0.20   &19.96  &0.01\\
2   &0.40   &20.00  &0.02\\
3   &1.00   &19.98  &0.05\\
4   &2.00   &20.00  &0.10\\
5   &4.00   &20.00  &0.20\\
6   &10.00  &20.00  &0.50\\
\bottomrule
\end{tabular}
\end{table}

\end{document}

Personaly, I'd prefer a table without using bold for the ID's and I'd also use the caption package to control the spacing etween caption and toprule:

enter image description here

\documentclass{article}
\usepackage[abbreviations=true,per-mode=symbol]{siunitx}
\usepackage{booktabs}
\usepackage{makecell}
\usepackage{caption}
\begin{document}

\begin{table}
\caption{Specific Acid Added to Samples}
\label{Acid_Added}
\centering
\begin{tabular}{c  S[table-format=2.2]  S[table-format=2.2]  S[table-format=1.2] }
\toprule
\thead{ID} & {\thead{Specific Acid\\ Weight [\si{\mg}]}} & {\thead{Spread\\ Weight [\si{\g}]}} & {\thead{Specific Acid\\Conc [\si{\mg\per\g}]}} \\
\midrule
1   &0.20   &19.96  &0.01\\
2   &0.40   &20.00  &0.02\\
3   &1.00   &19.98  &0.05\\
4   &2.00   &20.00  &0.10\\
5   &4.00   &20.00  &0.20\\
6   &10.00  &20.00  &0.50\\
\bottomrule
\end{tabular}
\end{table}
\end{document}
  • Thanks @leandriis, if I want to move the units to the next line in the header (e.g. [mg/g] on a new line), how would I be able to do that? Right now if I do that with \\ I get an error for the [] brackets, but not if I use () brackets – Vuro H Oct 18 at 18:17
  • \\{} as in \thead{Specific Acid\\ Weight\\{} [\si{\mg}]} should work for that. – leandriis Oct 18 at 19:07
0

The multirow package allows you to vertically fuse cells together. Once it has been loaded in your preamble, you can use the command \multirow{<number of cells to fuse>}{<width>}{<content>}. Note that you can replace the width with a * to respect the given cell width.

  • Also, this question probably has already been asked and answered somewhere on TeXSE. – v_manz Oct 16 at 15:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.