2

I have a small problem. I would like to rebuild the following table:

enter image description here

Until now I made the following code:

\begin{tabular}{lllllll}\toprule
\textbf{Factor} & \textbf{Effect} & \textbf{Percentage of Variation} & \textbf{Confidence Intervall} & \textbf{Effect} & \textbf{Percentage of Variation} & \textbf{Confidence Intervall} \\ \midrule

I & 26.55 & ~ & (16.35,36,74) & 0.03 & ~ & (-0.02,0.07) \\

 \bottomrule
\end{tabular}

My problem now is the following:

  • I cannot get "Percentage of Variation" etc. on two lines (line break).

  • I don't know how to make the "Additive Model" und "Multiplicative Model".

I would really appreciate if somebody could help.

1

Here is a quick view on using booktabs for the layout, and makecell for per-cell alignment:

enter image description here

\documentclass{article}
\usepackage{booktabs,makecell}
\begin{document}
\begin{tabular}{lrcrrcr}
  \toprule
  & \multicolumn{3}{c}{\bfseries Additive Model} & \multicolumn{3}{c}{\bfseries Multiplicative Model} \\
  \cmidrule(lr){2-4}\cmidrule(lr){5-7}
  \textbf{Factor} & Effect & \makecell[cb]{Percentage \\ of Variation} & \makecell[cb]{Confidence \\ Interval} & 
    Effect & \makecell[cb]{Percentage \\ of Variation} & \makecell[cb]{Confidence \\ Interval} \\
  \midrule
  I   &  $26.55$ &      ~ & $( 16.35, 36.74)$ & $ 0.03$ &      ~ & $(-0.02, 0.07)$\rlap{\textsuperscript{a}} \\
  A   & $-26.04$ & $30.1$ & $(-36.23,-15.84)$ & $-0.97$ & $49.9$ & $(-1.02,-0.93)$ \\
  B   & $-26.04$ & $30.1$ & $(-36.23,-15.84)$ & $-0.97$ & $49.9$ & $(-1.02,-0.93)$ \\
  AB  & $ 25.54$ & $29.0$ & $( 15.35, 35.74)$ & $ 0.03$ & $\phantom{0}0.0$ & $(-0.02, 0.07)$\rlap{\textsuperscript{a}} \\
  $e$ &        ~ & $10.8$ &                 ~ &       ~ & $\phantom{0}0.2$ &               ~ \\
  \bottomrule
\end{tabular}
\end{document}

For small tables, manual \phantom adjustments are easy to make. Alternatively, one could consider siunitx column specifications.

2
\documentclass{article}
\usepackage{array}
\usepackage{booktabs}
\newcommand{\head}[1]{%
  \begin{tabular}[b]{@{}c@{}}
  #1
  \end{tabular}%
}
\begin{document}
\begin{table}
  \begin{tabular}{*{7}{c}}\toprule
   & \multicolumn{3}{c}{Additive model} & \multicolumn{3}{c}{Multiplicative model}\\\cmidrule(lr){2-4}\cmidrule(lr){5-7}
\textbf{Factor} & \textbf{Effect} & \head{\textbf{Percentage}\\ \textbf{of Variation}} & \head{\textbf{Confidence}\\ \textbf{Intervall}}& \textbf{Effect} & \head{\textbf{Percentage}\\ \textbf{of Variation}} & \head{\textbf{Confidence}\\ \textbf{Intervall}} \\ \midrule

I & 26.55 & ~ & (16.35,36,74) & 0.03 & ~ & (-0.02,0.07) \\

 \bottomrule
\end{tabular}
\end{table}
\end{document}

enter image description here

0
0

Another solution, also using makecell, siunitx, caption and threeparttable:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{fourier, heuristica}
    \usepackage{array, booktabs,  caption}
    \def\cmidrulewidth{\lightrulewidth}
\captionsetup{font = bf, labelfont =sc, labelsep = quad}
\usepackage{siunitx}
\sisetup{table-format=2.1}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries}
\renewcommand\theadalign{cb}
\usepackage{threeparttable}

\begin{document}

\begin{table}
\centering
\begin{threeparttable}
\caption{Percentage of Variation Explained by the Two Models}
\begin{tabular}{ >{\boldmath}cS[table-format=-2.2]SccS[table-format=-1.2]Sc}
\toprule
 & \multicolumn{3}{c}{\thead{Additive Model}}   & &  \multicolumn{3}{c}{\thead{Multiplicative Model}}  \\
 \cmidrule(lr){2-4}\cmidrule(lr){6-8}
\thead{Factor} & {\thead{Effect}} & {\thead{Percentage\\ of Variation}} & \thead{Confidence\\ Interval} & &  {\thead{Effect}} & {\thead{Percentage\\ of Variation}} & \thead{Confidence\\ Interval} \\
\cmidrule(lr){1-8}\addlinespace
$ I $ & 26.55 & ~ &$  (16.35,36.74) $ & &  0.03 & ~ & $ (-0.02,0.07) $ \\
$ A  $  & -26.04 & 30.1 & $  (-36.23,-15.84) $ & &  -0.97 & 49.9 & $ (-1.02,-0.93) $ \\
$ B  $  & -26.04 & 30.1 & $ (-36.23,-15.84) $ & &  -0.97 & 49.9 & $ (-1.02,-0.93) $ \\
$ AB $  &  25.54 & 29.0 & $ (15.35, 35.74) $ & &   0.03 & 0.0 & $ (-0.02, 0.07) $\rlap{\tnote{a}} \\
$ e $ &        ~ & 10.8 &                 ~ &       ~ & &  0.2 &               ~ \\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item[a]Not significant.
\end{tablenotes}
\end{threeparttable}
\end{table}

\end{document} 

enter image description here

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.