1

See my code below and attached image showing output of the code. I'm producing a table which is just about finished, but one last thing is bothering me. The text in the cells of the column titled "Upper Level" are not centred.

\newcommand{\rotatemultirow}[1]{\parbox[t]{3mm}{\multirow{6}{*}{\rotatebox[origin=l]{90}{#1}}}}
\begin{table}[t!]
\caption{Caption.}
    {\setlength{\extrarowheight}{2pt}%
    \begin{tabular}{|c|>{\centering}p{24mm}|>{\centering}p{20mm}|>{\centering}p{15mm}|>{\centering}p{22mm}|>{\centering}p{12mm}|>{\centering}p{12mm}|>{\centering}p{12mm}|}
        \cline{2-8}
        \multicolumn{1}{c|}{}
        & $\begin{matrix} \textbf{Upper} \\\textbf{Level} \end{matrix}$
        & $\begin{matrix} \textbf{Lower} \\\textbf{Level} \end{matrix}$
        & $\begin{matrix} \textbf{$\mathbf{\lambda_{ij}}$} \\ \text{(nm)} \end{matrix}$ 
        & $\begin{matrix} \textbf{$\mathbf{A_{ij}}$} \\ \text{(10$^{7}$ s$^{-1}$)} \end{matrix}$ 
        & $\begin{matrix} \textbf{$\mathbf{\beta_{exp}}$} \\ \text{(\%)} \end{matrix}$  
        & $\begin{matrix} \textbf{$\mathbf{\beta_{th}}$} \\ \text{(\%)} \end{matrix}$  
        & $\begin{matrix} \textbf{$\mathbf{\beta_{rec}}$} \\ \text{(\%)} \end{matrix}$  \tabularnewline
        \cline{1-8}
        \hline
        \textbf{He} &$\dagger$ & $^{3}$S$_{1}$ & 1083.3 & 1.02 & \textemdash & \textemdash & \textemdash \tabularnewline
        \hline
        \rotatemultirow{\textbf{Neon}\hspace{1cm}}
        &\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$133.1\,nm)}} 
        & 1s$_{2}$ & 693.1 & 1.74-1.88 & 38 & 35 & 37 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{4}$ & 630.7 & 0.42-0.59 & 11 & 11 & 11 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 614.5 & 2.16-2.82 & 51 & 54 & 52 \bigstrut \tabularnewline
        \cline{2-8}
        & \multirow{3}[8]{20mm}{\makecell{2p$_{8}$\\(2$\times$133.5\,nm)}} 
        & 1s$_{2}$ & 717.6 & 0.26-0.37 & 7 & 3 & 6 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{4}$ & 650.8 & 2.03-3.00 & 58 & 63 & 60 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 633.6 & 1.26-1.77 & 35 & 34 & 34 \bigstrut \tabularnewline
        \hline
        \rotatemultirow{\textbf{Argon}\hspace{1cm}}
        &\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$188.3\,nm)}} 
        & 1s$_{2}$ & 922.5 & 0.59-0.63 & 16 & 16 & 26 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{4}$ & 800.6 & 0.48-0.51 & 13 & 12 & 25 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 763.5 & 2.62-2.96 & 71 & 72 & 49 \bigstrut \tabularnewline
        \cline{2-8}
        & \multirow{3}[8]{20mm}{\makecell{2p$_{8}$\\(2$\times$189.4\,nm)}} 
        & 1s$_{2}$ & 978.5 & 0.11-0.17 & 3 & 5 & 7 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{4}$ & 842.5 & 2.11-2.52 & 66 & 67 & 51 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 801.5 & 1.00-1.04 & 31 & 28 & 43 \bigstrut \tabularnewline
        \hline
        \rotatemultirow{\textbf{Krypton}\hspace{1cm}}
        &\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$214.8\,nm)}} 
        & 1s$_{2}$ & 1373.9 & 0.02-0.03 & 0 & 1 & 7 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{4}$ & 819.0 & 0.9-1.1 & 26 & 24 & 22 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 760.2 & 2.6-3.1 & 74 & 75 & 71 \bigstrut \tabularnewline
        \cline{2-8}
        &\multirow{3}[8]{20mm}{\makecell{2p$_{8}$\\(2$\times$216.7\,nm)}} 
        & 1s$_{2}$ & 1547.4 & 0.003-0.008 & 0 & 0 & 1 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{4}$ & 877.7 & 1.5-2.6 & 68 & 68 & 69 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 810.4 & 0.7-1.1 & 32 & 32 & 30 \bigstrut \tabularnewline
        \hline
        \rotatemultirow{\textbf{Xenon}\hspace{1cm}}
        &\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$252.5\,nm)}} 
        & 1s$_{2}$ & 4932.4 & 0.002 & 0 & 0 & 0 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{4}$ & 895.5 & 1.06 & 21 & 30 & 9 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 823.4 & 2.49 & 79 & 70 & 91 \bigstrut \tabularnewline
        \cline{2-8}
        &\multirow{3}[8]{20mm}{\makecell{2p$_{9}$\\(2$\times$256.0\,nm)}} 
        & 1s$_{2}$ & 10698.1 & 0 & 0 & 0 & 0 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{4}$ & 992.6 & 1.96 & 49 & 65 & 71 \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 904.8 & 1.07 & 51 & 35 & 29 \bigstrut \tabularnewline
        \hline
        \rotatemultirow{\textbf{Radon}\hspace{-0.2cm}}
        &\multirow{2}[8]{20mm}{\vspace{-3mm}\makecell{2p$_{6}$\\(2$\times$290.7\,nm)}} 
        & 1s$_{4}$ & 781.2 & NA & NA & NA & NA \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 705.7 & NA & NA & NA & NA \bigstrut \tabularnewline
        \cline{2-8}
        &\multirow{2}[8]{20mm}{\vspace{-3mm}\makecell{2p$_{9}$\\(2$\times$299.8\,nm)}} 
        & 1s$_{4}$ & 933.0 & NA & NA & NA & NA \bigstrut \tabularnewline \cline{3-8}
        &  & 1s$_{5}$ & 827.3 & NA & NA & NA & NA \bigstrut \tabularnewline
        \hline
    \end{tabular}}
    \label{tbl:choosingTransition}
\end{table}

Table from code output

  • Welcome to TeX.SX! Usually TeX should break the lower lines but it can't. Try to make the column wider and it will be centered (the cell offsets will be intact again). – TeXnician Feb 16 at 11:06
  • You have \bigstrut directives in lots of cells, but not in any of the header cells. Either delete all \bigstrut directives or insert them in the header cells as well. – Mico Feb 16 at 11:35
1

Here is a simpler code, using siunitx for the alignment of numbers on the decimal dot in the 4th column, and vertical padding of cells with makecell:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[showframe]{geometry}
\usepackage{amsmath}
\usepackage[detect-weight]{siunitx}
\usepackage{array, caption, multirow, makecell, bigstrut, rotating}
\renewcommand\theadfont{\boldmath\bfseries\normalsize}
\newcommand{\rotatemultirow}[2][6]{\parbox[t]{3mm}{\multirow{#1 }{*}{\rotatebox[origin=c]{90}{#2}}}}

\begin{document}

\begin{table}[t!]
\captionsetup{skip=6pt}
\caption{Caption.}
\sisetup{table-number-alignment=center}
 \setlength{\extrarowheight}{3pt}\centering%
\setcellgapes[b]{2pt}\makegapedcells
 \begin{tabular}
{|c|>{\centering}p{24mm}|>{\centering}p{20mm}|S[table-format=5.1]|>{\centering}p{18mm}|*{3}{>{\centering}p{12mm}|}}%
% {|c|>{\centering}p{24mm}|>{\centering}p{20mm}|>{\centering}p{15mm}|>{\centering}p{22mm}|*{3}{>{\centering}p{12mm}|}}
        \cline{2-8}
        \multicolumn{1}{c|}{}
        &\thead{Upper \\ Level}
        &\thead{Lower \\ Level}
        &{\thead{$\lambda_{ij}$ \\ (nm)}}
        &\thead{$A_{ij}$ \\ (\SI{e7}{\per\s})}
        &\thead{$\beta_{\exp}$ \\ (\%)}
        &\thead{$\beta_\text{th}$ \\ (\%)}
        &\thead{$\beta_\text{rec}$ \\ (\%)} \tabularnewline
        \cline{1-8}
        \hline
        \textbf{He} &$\dagger$ & $^{3}$S$_{1}$ & 1083.3 & 1.02 & \textemdash & \textemdash & \textemdash \tabularnewline
        \hline
 \rotatemultirow[6.8]{\textbf{Neon}}
% &\multirow{3}[8]{20mm}{\makecell{2p$_{6}$\\(2$\times$133.1\,nm)}}
 &\multirowcell{3}{2p$_{6}$\\(2$\times$133.1\,nm)}
 & 1s$_{2}$ & 693.1 & 1.74--1.88 & 38 & 35 & 37 \tabularnewline \cline{3-8}
 & & 1s$_{4}$ & 630.7 & 0.42--0.59 & 11 & 11 & 11 \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 614.5 & 2.16--2.82 & 51 & 54 & 52 \tabularnewline
 \cline{2-8}
 &\multirowcell{3}{2p$_{8}$\\(2$\times$133.5\,nm)}
 & 1s$_{2}$ & 717.6 & 0.26--0.37 & 7 & 3 & 6 \tabularnewline \cline{3-8}
 & & 1s$_{4}$ & 650.8 & 2.03--3.00 & 58 & 63 & 60 \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 633.6 & 1.26--1.77 & 35 & 34 & 34 \tabularnewline
 \hline
 \rotatemultirow[6.8]{\textbf{Argon}}
 &\multirowcell{3}{2p$_{6}$\\(2$\times$188.3\,nm)}
 & 1s$_{2}$ & 922.5 & 0.59--0.63 & 16 & 16 & 26 \tabularnewline \cline{3-8}
 & & 1s$_{4}$ & 800.6 & 0.48--0.51 & 13 & 12 & 25 \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 763.5 & 2.62--2.96 & 71 & 72 & 49 \tabularnewline
 \cline{2-8}
 &\multirowcell{3}{2p$_{8}$\\(2$\times$189.4\,nm)}
 & 1s$_{2}$ & 978.5 & 0.11--0.17 & 3 & 5 & 7 \tabularnewline \cline{3-8}
 & & 1s$_{4}$ & 842.5 & 2.11--2.52 & 66 & 67 & 51 \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 801.5 & 1.00--1.04 & 31 & 28 & 43 \tabularnewline
 \hline
 \rotatemultirow[6.8]{\textbf{Krypton}}
 &\multirowcell{3}{2p$_{6}$\\(2$\times$214.8\,nm)}
 & 1s$_{2}$ & 1373.9 & 0.02--0.03 & 0 & 1 & 7 \tabularnewline \cline{3-8}
 & & 1s$_{4}$ & 819.0 & 0.9--1.1 & 26 & 24 & 22 \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 760.2 & 2.6--3.1 & 74 & 75 & 71 \tabularnewline
 \cline{2-8}
 &\multirowcell{3}{2p$_{8}$\\(2$\times$216.7\,nm)}
 & 1s$_{2}$ & 1547.4 & 0.003--0.008 & 0 & 0 & 1 \tabularnewline \cline{3-8}
 & & 1s$_{4}$ & 877.7 & 1.5--2.6 & 68 & 68 & 69 \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 810.4 & 0.7--1.1 & 32 & 32 & 30 \tabularnewline
 \hline
 \rotatemultirow[6.9]{\textbf{Xenon}}
 &\multirowcell{3}{2p$_{6}$\\(2$\times$252.5\,nm)}
 & 1s$_{2}$ & 4932.4 & 0.002 & 0 & 0 & 0 \tabularnewline \cline{3-8}
 & & 1s$_{4}$ & 895.5 & 1.06 & 21 & 30 & 9 \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 823.4 & 2.49 & 79 & 70 & 91 \tabularnewline
 \cline{2-8}
 &\multirowcell{3}{2p$_{9}$\\(2$\times$256.0\,nm)}
 & 1s$_{2}$ & 10698.1 & 0 & 0 & 0 & 0 \tabularnewline \cline{3-8}
 & & 1s$_{4}$ & 992.6 & 1.96 & 49 & 65 & 71 \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 904.8 & 1.07 & 51 & 35 & 29 \tabularnewline
 \hline
 \rotatemultirow[4.5]{\textbf{Radon}}
 &\multirowcell{2}{2p$_{6}$\\(2$\times$290.7\,nm)}
 & 1s$_{4}$ & 781.2 & NA & NA & NA & NA \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 705.7 & NA & NA & NA & NA \tabularnewline
 \cline{2-8}
 &\multirowcell{2}{2p$_{9}$\\(2$\times$299.8\,nm)}
 & 1s$_{4}$ & 933.0 & NA & NA & NA & NA \tabularnewline \cline{3-8}
 & & 1s$_{5}$ & 827.3 & NA & NA & NA & NA \tabularnewline
 \hline
    \end{tabular}
    \label{tbl:choosingTransition}
\end{table}

\end{document} 

enter image description here

  • Hi Bernard, thank you for this! Can you advise as to why the third column (wavelength) is not centred? – Milad Dakka Mar 6 at 1:31
  • @MiladDakka: It is centred (globally), but in this column there is a number with 5 digits for the integer part, whereas almost all the other numbers have 3. You can cheat with this specifier: S[table-format=3.1,table-column-width=4em] instead of S[table-format=5.1]. – Bernard Mar 6 at 10:02

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.