Graphics, Figures & TablesAlignment of Table Head to "±" Sign

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Andlauge
Posts: 1
Joined: Tue Jul 23, 2013 5:28 pm

Alignment of Table Head to "±" Sign

Post by Andlauge »

Hi,

I've made this table using the dcolumn package in the preamble. However, are headlines (i.e. "Size (nm)" and $N_{R6G(mean)}$) are not centered above the "±" signs in the table.

Code: Select all

\begin{table}[!htb]
  \centering
  \resizebox{11cm}{!}{
    \begin{tabular}{D{,}{\, \pm \,}{-1} D{,}{\, \pm \,}{-1} c D{,}{\, \pm \,}{-1} D{,}{\, \pm \,}{-1} c D{,}{\, \pm \,}{-1} D{,}{\, \pm \,}{-1}} \toprule[1.5pt]
      \multicolumn{2}{c}{\head{Mock}} & & \multicolumn{2}{c}{\head{SF9}} & & \multicolumn{2}{c}{\head{HEK293}} \\
      \multicolumn{1}{c}{Size (nm)} &  \multicolumn{1}{c}{$N_{R6G(mean)} $} & &  \multicolumn{1}{c}{Size (nm)} & \multicolumn{1}{c}{$N_{R6G(mean)} $} & &  \multicolumn{1}{c}{Size (nm)} &  \multicolumn{1}{c}{$N_{R6G(mean)} $} \\ \cmidrule(lr){1-8}
      81.5,0.6 & 75,2 & & 74.5,0.4 & 83,1 & & 75.5,0.4 & 80,1 \\
      122.3,0.5 & 106,1 & & 120.8,0.6 & 160,3 & & 120.8,0.6 & 146,2 \\
      169.1,0.9 & 181,4 & & 172.7,1.0 & 274,8 & & 170.9,1.0 & 263,6\\
      236.3,2.5 & 327,11 & & 235.6,2.0 & 513,21 & & 239.7,2.9 & 545,21\\ \bottomrule[1.5pt]
    \end{tabular}
  }
  \caption[Number of transported R6G molecules]{Summary of VMAT2 transport.}
  \label{tab:VMATsummary}
\end{table}
Any ideas on how I can do this?
Last edited by localghost on Tue Jul 23, 2013 5:43 pm, edited 1 time in total.

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

cgnieder
Site Moderator
Posts: 2000
Joined: Sat Apr 16, 2011 7:27 pm

Alignment of Table Head to "±" Sign

Post by cgnieder »

Welcome to the LaTeX community!

I would use the siunitx package for number alignment in tables (and also for typesetting units):

Code: Select all

\documentclass{article}
\usepackage{array,booktabs}
\usepackage{siunitx}
\sisetup{separate-uncertainty}
\newcommand*\head[1]{\textbf{#1}}
\begin{document}

\begin{table}
  \centering
  \small
  \begin{tabular}{
      S[table-format=3.1(2)]
      S[table-format=3.2]
      S[table-format=3.1(2)]
      S[table-format=3.2]
      S[table-format=3.1(2)]
      S[table-format=3.2]
    }
    \toprule
      \multicolumn{2}{c}{\head{Mock}} &
      \multicolumn{2}{c}{\head{SF9}} &
      \multicolumn{2}{c}{\head{HEK293}} \\
      {Size (\si{\nano\metre})} & {$N_{R6G(mean)}$} &
      {Size (\si{\nano\metre})} & {$N_{R6G(mean)}$} &
      {Size (\si{\nano\metre})} & {$N_{R6G(mean)}$} \\
    \midrule
      81.5(6)   & 75,2   & 74.5(4)   & 83,1   & 75.5(4)   & 80,1 \\
      122.3(5)  & 106,1  & 120.8(6)  & 160,3  & 120.8(6)  & 146,2 \\
      169.1(9)  & 181,4  & 172.7(10) & 274,8  & 170.9(10) & 263,6\\
      236.3(25) & 327,11 & 235.6(20) & 513,21 & 239.7(29) & 545,21\\
    \bottomrule
  \end{tabular}
  \caption[Number of transported R6G molecules]{Summary of VMAT2 transport.}
  \label{tab:VMATsummary}
\end{table}

\end{document}
table.png
table.png (30.68 KiB) Viewed 3557 times
Regards
site moderator & package author
Post Reply