2

How to align cmidrule when merge cell with multirow and has a cell with rotatebox below?

\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tikz}
\usepackage{lscape}
\newcommand{\CustomCheckedBox}{\resizebox{!}{11pt}{%
        \begin{tikzpicture}
        \draw[line width=2pt, rounded corners] (0.75,1)--(0,1)--(0,0) -- (1,0) -- (1,0.5);
        \draw[xshift=0cm,yshift=0.35cm,line width=2pt] (0.25,0.25)--(0.5,0)--(1,0.5);
        \end{tikzpicture}}}

\newcommand{\CustomSquare}{\resizebox{!}{11pt}{%
        \begin{tikzpicture}
        \draw[line width=2pt, rounded corners] (1,1)--(0,1)--(0,0) -- (1,0) -- cycle;
        \end{tikzpicture}}%
}

\begin{document}
    \begin{landscape}
    \begin{tabular}{@{\hspace{1cm}}p{3.5cm} lll lll lll lll l}
        
        \toprule
        \multicolumn{1}{c}{\multirow{3}{*}{\textbf{Waste class}}} & 
        \multicolumn{4}{c}{\textbf{Characteristics}} &
        \multicolumn{2}{c}{\multirow{2}[2]{*}{\textbf{Dangerousness}}}  &
        \multicolumn{3}{c}{\multirow{2}[2]{*}{\textbf{Risk rating}}} &
        \multicolumn{4}{c}{\multirow{2}[2]{*}{\textbf{Economic aspect}}}\\
        \cmidrule(r{1mm}){2-5}
        \cmidrule(l{1mm}){6-7}
        \cmidrule(r{1mm}l{1mm}){8-10}
        \cmidrule(l{1mm}){11-14}
        &
        \multicolumn{2}{c}{\textbf{physical}} &
        \multicolumn{2}{c}{\textbf{chemical}} &
        &&&&&&&&\\
        \cmidrule(r{1mm}){2-3}
        \cmidrule(r{1mm}){4-5}      
        &
        \rotatebox{75}{\textbf{Dry}} &
        \rotatebox{75}{\textbf{Wet}} &
        \rotatebox{75}{\textbf{Organic}} &
        \rotatebox{75}{\textbf{Inorganic}} &
        \rotatebox{75}{\textbf{Dangerous}} &
        \rotatebox{75}{\textbf{Not dangerous}} &
        \rotatebox{75}{\textbf{Hazardous}} & 
        \rotatebox{75}{\textbf{Biodegradable}} &
        \rotatebox{75}{\textbf{Non biodegradable}} &
        \rotatebox{75}{\textbf{Reusable}} & 
        \rotatebox{75}{\textbf{Compostable}} & 
        \rotatebox{75}{\textbf{Recoverable}} & 
        \rotatebox{75}{\textbf{Unusable}}\\
        \midrule
        
        \multicolumn{14}{l}{\textbf{Municipal Solid Waste}}\\\cmidrule{1-1}
        \multicolumn{14}{l}{\hspace{5mm}\textbf{Home}}\\\cmidrule(l{5mm}){1-1}
        Recyclable & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare\\
        Unusable & \CustomCheckedBox & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomSquare & \CustomCheckedBox\\
        Organic & \CustomSquare & \CustomCheckedBox & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare\\
        \multicolumn{14}{l}{\hspace{5mm}\textbf{Urban}}\\\cmidrule(l{5mm}){1-1}%&  &  &  &  &  &  &  &  &  &  &    &  & \\
        Sweeping & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomSquare & \CustomSquare & \CustomCheckedBox\\
        Pruning tree & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare\\
        Weeding & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare\\
        \bottomrule
    \end{tabular}

\end{landscape}

\end{document}

enter image description here

2
  • Is this the desiered output? i.sstatic.net/KfwQm.png
    – leandriis
    Aug 1, 2020 at 6:14
  • It the table you showed already complete or will you add more rows later on? Probably there is a better way to present the table than using rotated headers on a landscape table since the header texts will apear upside down when you view the page in a portrait orientation. Probably transposing the table could help.
    – leandriis
    Aug 1, 2020 at 6:17

2 Answers 2

3

In order to avoid the overlap of the \cmidrule with the \multirow texts, move the \cmidrule commands right after the \cmidrule that spans both "chemical" columns, instead of after the \cmidrule that spans all 4 "Characteristics" columns.

I have also included a second example that avoids the use of rotated table headers in a landscape table. Column headers appear upside down with this double rotated combination:

enter image description here

\documentclass{article}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tikz}
\usepackage{lscape}

\newcommand{\CustomCheckedBox}{\resizebox{!}{11pt}{%
        \begin{tikzpicture}
        \draw[line width=2pt, rounded corners] (0.75,1)--(0,1)--(0,0) -- (1,0) -- (1,0.5);
        \draw[xshift=0cm,yshift=0.35cm,line width=2pt] (0.25,0.25)--(0.5,0)--(1,0.5);
        \end{tikzpicture}}}

\newcommand{\CustomSquare}{\resizebox{!}{11pt}{%
        \begin{tikzpicture}
        \draw[line width=2pt, rounded corners] (1,1)--(0,1)--(0,0) -- (1,0) -- cycle;
        \end{tikzpicture}}%
}

\begin{document}
    \begin{landscape}
    \setlength{\tabcolsep}{3.75pt} % added to avoid the overfull box warning
    \begin{tabular}{@{\hspace{1cm}}p{3.5cm} lll lll lll lll l}
        
        \toprule
        \multicolumn{1}{c}{\multirow{3}{*}{\textbf{Waste class}}} & 
        \multicolumn{4}{c}{\textbf{Characteristics}} &
        \multicolumn{2}{c}{\multirow{2}[2]{*}{\textbf{Dangerousness}}}  &
        \multicolumn{3}{c}{\multirow{2}[2]{*}{\textbf{Risk rating}}} &
        \multicolumn{4}{c}{\multirow{2}[2]{*}{\textbf{Economic aspect}}}\\
        \cmidrule(r{1mm}){2-5}
        &
        \multicolumn{2}{c}{\textbf{physical}} &
        \multicolumn{2}{c}{\textbf{chemical}} &
        &&&&&&&&\\
        \cmidrule(r{1mm}){2-3}
        \cmidrule(r{1mm}){4-5}
        \cmidrule(l{1mm}){6-7} % moved down in order to avoid overlap 
        \cmidrule(r{1mm}l{1mm}){8-10} % moved down in order to avoid overlap
        \cmidrule(l{1mm}){11-14}       % moved down in order to avoid overlap
        &
        \rotatebox{75}{\textbf{Dry}} &
        \rotatebox{75}{\textbf{Wet}} &
        \rotatebox{75}{\textbf{Organic}} &
        \rotatebox{75}{\textbf{Inorganic}} &
        \rotatebox{75}{\textbf{Dangerous}} &
        \rotatebox{75}{\textbf{Not dangerous}} &
        \rotatebox{75}{\textbf{Hazardous}} & 
        \rotatebox{75}{\textbf{Biodegradable}} &
        \rotatebox{75}{\textbf{Non biodegradable}} &
        \rotatebox{75}{\textbf{Reusable}} & 
        \rotatebox{75}{\textbf{Compostable}} & 
        \rotatebox{75}{\textbf{Recoverable}} & 
        \rotatebox{75}{\textbf{Unusable}}
\\
        \midrule
        
        \multicolumn{14}{l}{\textbf{Municipal Solid Waste}}\\\cmidrule{1-1}
        \multicolumn{14}{l}{\hspace{5mm}\textbf{Home}}\\\cmidrule(l{5mm}){1-1}
        Recyclable & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare\\
        Unusable & \CustomCheckedBox & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomSquare & \CustomCheckedBox\\
        Organic & \CustomSquare & \CustomCheckedBox & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare\\
        \multicolumn{14}{l}{\hspace{5mm}\textbf{Urban}}\\\cmidrule(l{5mm}){1-1}%&  &  &  &  &  &  &  &  &  &  &    &  & \\
        Sweeping & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomSquare & \CustomSquare & \CustomCheckedBox\\
        Pruning tree & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare\\
        Weeding & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare & \CustomCheckedBox & \CustomSquare & \CustomSquare\\
        \bottomrule
    \end{tabular}

\end{landscape}

\begin{tabular}{@{\quad}l cccccc}
\toprule
 &  \multicolumn{6}{c}{\textbf{Municipal Solid Waste}}\\
 \cmidrule{2-7}
 &  \multicolumn{3}{c}{Home} & \multicolumn{3}{c}{Urban}\\
  \cmidrule(r){2-4} \cmidrule(l){5-7}
  &  \rotatebox{90}{Recyclable} 
    & \rotatebox{90}{Unusable} 
      & \rotatebox{90}{Organic} 
        & \rotatebox{90}{Sweeping} 
          & \rotatebox{90}{Prunning tree} 
             & \rotatebox{90}{Weeding} \\
  \midrule
 \multicolumn{1}{@{}l}{\textbf{Physical Characteristics}}\\
  Dry 
    & \CustomCheckedBox 
      & \CustomCheckedBox 
        & \CustomSquare 
          & \CustomCheckedBox 
            &\CustomCheckedBox 
              &\CustomCheckedBox  \\ 
  Wet 
    & \CustomSquare 
      & \CustomCheckedBox 
        &\CustomCheckedBox  
          & \CustomSquare 
            & \CustomSquare  
              & \CustomSquare \\
 \addlinespace
 \multicolumn{1}{@{}l}{\textbf{Chemical Characteristics}}\\
  Organic & \\
  Inorganic & \\
 \addlinespace
 \multicolumn{1}{@{}l}{\textbf{Dangerousness}}\\
  Dangerous &\\
  Not dangerous &\\
 \addlinespace
 \multicolumn{1}{@{}l}{\textbf{Risk Rating}}\\
  Hazardous & \\
  Biodegradable &\\
  Non biodegradable &\\
 \addlinespace
 \multicolumn{1}{@{}l}{\textbf{Economic aspect}}\\
  Reusable & \\
  Compostable & \\
  Recoverable & \\
  Unusable\\
\bottomrule
\end{tabular}
\end{document}
-1

You need to change the three multirows number to 1 to shift the rows upwards-- if you want the rows to descend simply change the multirow number to 4

\multicolumn{2}{c}{\multirow{1}[2]{*}{\textbf{Dangerousness}}}  &
\multicolumn{3}{c}{\multirow{1}[2]{*}{\textbf{Risk rating}}} &
\multicolumn{4}{c}{\multirow{1}[2]{*}{\textbf{Economic aspect}}}\\

enter image description here

\begin{tabular}{@{\hspace{1cm}}p{3.5cm} lll lll lll lll l}
    
    \toprule
    \multicolumn{1}{c}{\multirow{3}{*}{\textbf{Waste class}}} & 
    \multicolumn{4}{c}{\textbf{Characteristics}} &
    \multicolumn{2}{c}{\multirow{1}[2]{*}{\textbf{Dangerousness}}}  &
    \multicolumn{3}{c}{\multirow{1}[2]{*}{\textbf{Risk rating}}} &
    \multicolumn{4}{c}{\multirow{1}[2]{*}{\textbf{Economic aspect}}}\\
    \cmidrule(r{1mm}){2-5}
    \cmidrule(l{1mm}){6-7}
    \cmidrule(r{1mm}l{1mm}){8-10}
    \cmidrule(l{1mm}){11-14}
    &
    \multicolumn{2}{c}{\textbf{physical}} &
    \multicolumn{2}{c}{\textbf{chemical}} &
    &&&&&&&&\\
    \cmidrule(r{1mm}){2-3}
    \cmidrule(r{1mm}){4-5}      
    &
\\
\bottomrule

\end{tabular}
2
  • 1
    but using multirow {1} ... it doesn't make sense, is better take off the command, the result is the same. \multicolumn{2}{c}{\textbf{Dangerousness}} & \multicolumn{3}{c}{\textbf{Risk rating}} & \multicolumn{4}{c}{\textbf{Economic aspect}}\\ Jul 31, 2020 at 14:08
  • request to give a handrawn sketch of your requirement related to the header rows
    – js bibra
    Aug 1, 2020 at 1:36

You must log in to answer this question.

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