[Tex/LaTex] Line break in table and multicolumn layout problem

tables

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.

Best Answer

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.