多行和旋转框中的 cmidrule 对齐

多行和旋转框中的 cmidrule 对齐

当合并多行单元格且下方有一个带有旋转框的单元格时,如何对齐 cmidrule?

\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}

在此处输入图片描述

答案1

为了避免\cmidrule\multirow文本重叠,请将\cmidrule命令移至跨越两个“化学”列的之后\cmidrule,而不是\cmidrule跨越所有 4 个“特性”列的之后。

我还提供了第二个示例,该示例避免在横向表格中使用旋转的表格标题。使用这种双重旋转组合,列标题会上下颠倒:

在此处输入图片描述

\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}

答案2

您需要将三个multirows数字更改为1将行向上移动 - 如果您希望行下降,只需将多行数字更改为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}}}\\

在此处输入图片描述

\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}

相关内容