3

I'm trying to fit this table to the page width but I can't. I tried the tabularx environment and the contents got mixed. I tried also the tabulary environment: it's better, the contents are not mixed but the table exceed the page width.

The code I'm using for the table, using tabularx is this:

`\documentclass[10pt,a4paper]{article}
\usepackage[latin1]{inputenc}
\usepackage{graphicx}
\usepackage{multirow}
\usepackage{caption}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{footmisc}
\begin{document}
\begin{table}
\scalebox{1}{
\begin{minipage}{1\textwidth}
\centering
\caption{aaaaa aaaaa aaaa aaaa}
\begin{tabularx}{1\textwidth} {X X X X X X X X}
\toprule
Aaaaa aaa & Bbbbbbbbb & \multicolumn{2}{l}{CCCCCC CCCcccccc} & \multicolumn{2}{l}{Dddddddd} & \multicolumn{2}{l}{Eeeeeeeeee\footnote{ccccc ccccc cc} eeeeeee  eeeeeee} \\
    \midrule
    \multirow{5}[9]{*}{Kitchen} & Refrigerator & 40    &       & \multicolumn{1}{l}{14} & \multicolumn{1}{l}{\multirow{5}[9]{*}{40}} & \multirow{2}[4]{*}{28} & \multirow{5}[9]{*}{55} \\
          & Separate freezer & 40    &       & \multicolumn{1}{l}{10} & \multicolumn{1}{l}{} &       &  \\
          & Dishwasher & 40    &       & \multicolumn{1}{l}{7} & \multicolumn{1}{l}{} & \multirow{2}[4]{*}{16} &  \\
          & Washing machine & 40    &       & \multicolumn{1}{l}{9} & \multicolumn{1}{l}{} &       &  \\
          & Others & 40    &       & \multicolumn{1}{l}{-} & \multicolumn{1}{l}{} & 11    &  \\
    \multirow{2}[3]{*}{Electric equipment} & Informatics & \multicolumn{2}{l}{\multirow{2}[3]{*}{33}} & \multicolumn{1}{l}{7} & \multicolumn{1}{l}{\multirow{2}[3]{*}{13}} & 12    & \multirow{2}[3]{*}{21} \\
          & Entertainment & \multicolumn{2}{l}{} & \multicolumn{1}{l}{6} & \multicolumn{1}{l}{} & 9     &  \\
    \multicolumn{2}{l}{Lighting systems} & \multicolumn{2}{l}{13} & \multicolumn{2}{l}{8} & \multicolumn{2}{l}{18} \\
    \multirow{3}[6]{*}{HVAC} & Air heating & \multicolumn{1}{l}{9} & \multicolumn{1}{l}{\multirow{3}[6]{*}{11}} & 9     &       & \multicolumn{2}{l}{\multirow{2}[4]{*}{n. a.}} \\
          & Air cooling & \multicolumn{1}{l}{2} & \multicolumn{1}{l}{} & 9     &       & \multicolumn{2}{l}{} \\
          & Air conditioner & \multicolumn{1}{l}{-} & \multicolumn{1}{l}{} & 9     &       & \multicolumn{2}{l}{2} \\
    \multicolumn{2}{l}{Water heating} & \multicolumn{2}{l}{2} & \multicolumn{2}{l}{-} & \multicolumn{2}{l}{n. a.} \\
    \multicolumn{2}{l}{Others} & \multicolumn{2}{l}{-} & \multicolumn{2}{l}{30} & \multicolumn{2}{l}{4} \\
    \bottomrule
\end{tabularx}
\label{tab:comp_dist_cons_dif_sourc}
\end{minipage}}
\end{table}
\end{document}`

enter image description here

For tabulary I replace: \begin{tabularx}{1\textwidth} {X X X X X X X X} ... \end{tabularx}

by this: \begin{tabulary}{1\textwidth} {J J J J J J J J} \end{tabulary}

And I got this:

enter image description here

Is there any way to adjust both the table contents and the table width? Thank you in advance.

1 Answer 1

3

Your headers are so wide that the table will not fit. You need to force their widths to be smaller, one solution is to put the multicolumn ones in a p type column of specified size:

Sample output

\documentclass[10pt,a4paper]{article}

\usepackage[latin1]{inputenc}
\usepackage{multirow}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{booktabs}
\usepackage{caption}
\usepackage{footmisc}

\begin{document}
\begin{table}
  \begin{minipage}{1.0\linewidth}
    \centering
    \caption{aaaaa aaaaa aaaa aaaa}
    \begin{tabulary}{1\textwidth} {J J J J J J J J}
      \toprule Aaaaa aaa & Bbbbbbbbb & \multicolumn{2}{p{2cm}}{CCCCCC
      CCCcccccc} & \multicolumn{2}{p{2cm}}{Dddddddd} &
      \multicolumn{2}{p{2cm}}{Eeeeeeeeee\footnote{ccccc ccccc cc}
      eeeeeee  eeeeeee} \\
      \midrule \multirow{5}[9]{*}{Kitchen} & Refrigerator & 40 & &
      \multicolumn{1}{l}{14} &
      \multicolumn{1}{l}{\multirow{5}[9]{*}{40}} &
      \multirow{2}[4]{*}{28} & \multirow{5}[9]{*}{55} \\
      & Separate freezer & 40 & & \multicolumn{1}{l}{10} &
      \multicolumn{1}{l}{} &       &  \\
      & Dishwasher & 40 & & \multicolumn{1}{l}{7} &
      \multicolumn{1}{l}{} & \multirow{2}[4]{*}{16} &  \\
      & Washing machine & 40 & & \multicolumn{1}{l}{9} &
      \multicolumn{1}{l}{} &       &  \\
      & Others & 40 & & \multicolumn{1}{l}{-} &
      \multicolumn{1}{l}{} & 11    &  \\
      \multirow{2}[3]{*}{Electric equipment} & Informatics &
      \multicolumn{2}{l}{\multirow{2}[3]{*}{33}} &
      \multicolumn{1}{l}{7} &
      \multicolumn{1}{l}{\multirow{2}[3]{*}{13}} & 12 &
      \multirow{2}[3]{*}{21} \\
      & Entertainment & \multicolumn{2}{l}{} & \multicolumn{1}{l}{6} &
      \multicolumn{1}{l}{} & 9     &  \\
      \multicolumn{2}{l}{Lighting systems} & \multicolumn{2}{l}{13} &
      \multicolumn{2}{l}{8} & \multicolumn{2}{l}{18} \\
      \multirow{3}[6]{*}{HVAC} & Air heating & \multicolumn{1}{l}{9} &
      \multicolumn{1}{l}{\multirow{3}[6]{*}{11}} & 9 & &
      \multicolumn{2}{l}{\multirow{2}[4]{*}{n. a.}} \\
      & Air cooling & \multicolumn{1}{l}{2} & \multicolumn{1}{l}{} & 9
      &       & \multicolumn{2}{l}{} \\
      & Air conditioner & \multicolumn{1}{l}{-} & \multicolumn{1}{l}{}
      &
      9     &       & \multicolumn{2}{l}{2} \\
      \multicolumn{2}{l}{Water heating} & \multicolumn{2}{l}{2} &
      \multicolumn{2}{l}{-} & \multicolumn{2}{l}{n. a.} \\
      \multicolumn{2}{l}{Others} & \multicolumn{2}{l}{-} &
      \multicolumn{2}{l}{30} & \multicolumn{2}{l}{4} \\
      \bottomrule
    \end{tabulary}
    \label{tab:comp_dist_cons_dif_sourc}
  \end{minipage}
\end{table}
\end{document}
4
  • Thank you so much. Could you please tell me how can I force the width also of the non-multicolumn ones?
    – Catarina
    Commented Apr 4, 2014 at 15:24
  • For the other one column headings you could also use \multicolumn{1}{p{2cm}}{...}. Commented Apr 4, 2014 at 15:28
  • Is it necessary to have the tabulary environment encased in a minipage?
    – Mico
    Commented Apr 4, 2014 at 15:56
  • 1
    Yes, because of the footnote. Otherwise the footnote is not shown.
    – Catarina
    Commented Apr 4, 2014 at 19:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .