6

I'd like to have the headers of my table on two lines. For example, I would like Reaction Buffer to be ABOVE (150mM sodium acetate), and etc. for each column, but I don't know how to do this.

Also, the table is far too wide for my document, does anyone know how to compress (shrink) the whole thing?

\footnotesize
\begin{table}[h]
\centering
\small
\footnotesize
\tabcolsep=0.11cm
\begin{tabular}{@{}ll@{}@{}ll@{}@{}ll@{}ll@{}}
\toprule
Tube & MilliQ Water $(\mu L)$ \, &  100 mM MgCl\_2 $(\mu L)$, & Reaction Buffer (150 mM sodium acetate) $(\mu L)$  \,  & 500 mM NaOH $(\mu L)$, & 4 mM pNPP $(\mu L)$\\ 
\midrule
    1 & 60 & 15 & 30. (pH 4.0)& {} & 600. & 30. \\
    2 & 60 & 15 & 30. (pH 5.0) & {} & 600. & 30.\\
    3 & 60 & 15 & 30. (pH 6.0) & {} & 600. & 30.\\
    4 & 60 & 15 & {} & 30. (pH 7.0) & 600. & 30. \\
    5 & 60 & 15 & {} & 30. (pH 8.0) & 600. & 30. \\
    6 & 60 & 15 & {} & 30. (pH 9.0) & 600. & 30. \\ 
\bottomrule
\end{tabular}
\end{table}

\end{homeworkProblem}
Werner
  • 603,163
ragzoxaim
  • 337

2 Answers2

4

Use makecell for that, and its \thead command. In addition I loaded the mhchem and siunitx package.

\documentclass{article}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{array, booktabs, makecell}
\usepackage{siunitx, mhchem}
\newcommand\muL{\si{\micro\liter}}
\begin{document}

\begin{table}[h]
\centering
\small
\tabcolsep=0.11cm
\begin{tabular}{@{}*{7}{c}@{}}
\toprule
Tube & \thead{Milli-Q\\ Water \\ \muL} & \thead{100\,mM\\ \ce{MgCl2} \\ \muL} & \thead{Reaction Buffer \\ (150\,mM sodium\\ acetate) \muL} & \thead{500\,mM \\\ce{NaOH} \\ \muL} & \thead{4\,mM\\ pNPP \\\muL}\\
\midrule
    1 & 60 & 15 & 30. (pH 4.0)& {} & 600. & 30. \\
    2 & 60 & 15 & 30. (pH 5.0) & {} & 600. & 30.\\
    3 & 60 & 15 & 30. (pH 6.0) & {} & 600. & 30.\\
    4 & 60 & 15 & {} & 30. (pH 7.0) & 600. & 30. \\
    5 & 60 & 15 & {} & 30. (pH 8.0) & 600. & 30. \\
    6 & 60 & 15 & {} & 30. (pH 9.0) & 600. & 30. \\
\bottomrule
\end{tabular}
\end{table}

\end{document} 

enter image description here

Bernard
  • 271,350
3

With help of package makecell and siunitx I redisign your table in form, which should be a starting point for your further effort in its formatting:

enter image description here

\documentclass{article}
\usepackage{booktabs,makecell}
    \renewcommand\theadfont{\normalfont}
\usepackage{siunitx}

\usepackage[margin=30mm,showframe]{geometry}

    \begin{document}
\begin{table}[h]
    \centering
\caption{My important chemistry table}
    \label{tab:table-1}
\begin{tabular}{@{}*{8}{c}@{}}
    \toprule
\thead{Tube}   
    &   \thead{MilliQ\\ Water (\si{\micro L})} 
        &  \thead{\SI{100}{mM}\\ MgCl\textsubscript{2} (\si{\mu L})} 
            &   \thead{Reaction Buffer\\ 
                      (\SI{150}{mM} sodium\\
                       acetate) (\si{\micro L})}
                &   \thead{\SI{500}{mM}\\ NaOH (\si{\micro L})}
                    &   \thead{\SI{4}{mM}\\ pNPP (\si{\micro L})}  \\
    \midrule
1 & 60 & 15 & 30. (pH 4.0) & {} & 600. & 30. \\
2 & 60 & 15 & 30. (pH 5.0) & {} & 600. & 30. \\
3 & 60 & 15 & 30. (pH 6.0) & {} & 600. & 30. \\
4 & 60 & 15 & {} & 30. (pH 7.0) & 600. & 30. \\
5 & 60 & 15 & {} & 30. (pH 8.0) & 600. & 30. \\
6 & 60 & 15 & {} & 30. (pH 9.0) & 600. & 30. \\
    \bottomrule
\end{tabular}
\end{table}
    \end{document}    

Option showframe of package geometry serve only for show page layout. As you can see, I manually broke long column headers. This enable macrothead frommakecell package.

Note, this only one, relatively simple solution. There are others to, for example use column type p{<width>} or use tabularx etc.

Zarko
  • 296,517