如何制作具有多个旋转行和列的表格?

如何制作具有多个旋转行和列的表格?

我想让我的表格看起来像这样,但也将单元格的行与旋转的文本对齐

在此处输入图片描述

答案1

你是指这样的表格吗:

\documentclass{article}
\usepackage{multirow}
\usepackage{graphicx}
\usepackage{caption}
\captionsetup{%
    labelsep=colon,
    justification=raggedright,
    labelfont=default,
    singlelinecheck=off
}


\begin{document}
    
    \begin{table}[]
        \centering
        \resizebox{0.8\textwidth}{!}{
        \begin{minipage}{\textwidth}
        \caption{Table description}
        \label{Some Table}
        \begin{tabular}{|c|c|c|c|c|c|cc|ccc|}
            \hline
            \multicolumn{11}{|c|}{Complete name}                                                                                                  \\ \hline
            \multicolumn{11}{|c|}{Description}                                                                                                    \\ \hline
            \multirow{4}{*}{Exam} &
            \multirow{4}{*}{Assistance} &
            \multirow{4}{*}{Questionary} &
            \multirow{4}{*}{Homework} &
            \multirow{4}{*}{Second Program} &
            \multirow{4}{*}{Frist Program} &
            \multicolumn{2}{c|}{Grup Characters} &
            \multicolumn{1}{l}{Comments} &
            &
            \\ \cline{9-10}
            &    &    &    &    &    & \multicolumn{2}{l|}{Date:}                          & \multicolumn{1}{l}{S}  & \multicolumn{1}{c|}{} &  \\ \cline{9-9}
            &    &    &    &    &    & \multicolumn{2}{l|}{Serial No:}                     & \multicolumn{1}{l|}{U} & \multicolumn{1}{c|}{} &  \\
            &    &    &    &    &    & \multicolumn{1}{l}{No:} & \multicolumn{1}{l|}{Name} & \multicolumn{1}{l|}{}  & \multicolumn{1}{c|}{} &  \\ \hline
            10 & 10 & 10 & 10 & 10 & 10 & \multicolumn{1}{c|}{1}  & Jane Doe                  & \multicolumn{1}{c|}{}  & \multicolumn{1}{c|}{} &  \\ \hline
            9  & 9  & 9  & 9  & 9  & 9  & \multicolumn{1}{c|}{2}  & Jane Doe                  & \multicolumn{1}{c|}{}  & \multicolumn{1}{c|}{} &  \\ \hline
            8  & 8  & 8  & 8  & 8  & 8  & \multicolumn{1}{c|}{3}  & Jane Doe                  & \multicolumn{1}{c|}{}  & \multicolumn{1}{c|}{} &  \\ \hline
            10 & 10 & 10 & 10 & 10 & 10 & \multicolumn{1}{c|}{4}  & Jane Doe                  & \multicolumn{1}{c|}{}  & \multicolumn{1}{c|}{} &  \\ \hline
            5  & 5  & 5  & 5  & 5  & 5  & \multicolumn{1}{c|}{5}  & Jane Doe                  & \multicolumn{1}{c|}{}  & \multicolumn{1}{c|}{} &  \\ \hline
            10 & 10 & 10 & 10 & 10 & 10 & \multicolumn{1}{c|}{6}  & Jane Doe                  & \multicolumn{1}{c|}{}  & \multicolumn{1}{c|}{} &  \\ \hline
        \end{tabular}
        \end{minipage}}
    \end{table}
\end{document}

在此处输入图片描述

答案2

  • 您没有提供任何表格代码,也没有提供文档布局信息,因此答案只能基于猜测
  • 一开始我使用@Roland回答(+1)
  • 与以下 MWE 中的@Roland 回答相比,进行了以下更改:
    • 用于表的是tabularx
    • 添加旋转的列标题,如图所示
\documentclass{article}
\usepackage{geometry}
%---------------- show page layout. don't use in a real document!
\usepackage{rotating}
\usepackage{makecell, multirow, tabularx}
\NewExpandableDocumentCommand\mcc{O{1}m}%
    {\multicolumn{#1}{|c|}{#2}}
\NewExpandableDocumentCommand\mcl{O{1}m}%
    {\multicolumn{#1}{l|}{#2}}
\newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{caption}
\usepackage[labelsep=colon,
            justification=raggedright,
            labelfont=default,
            singlelinecheck=off
            ]{caption}


\begin{document}
    \begin{table}[ht]
    \centering
    \small
\caption{Table description}
\label{Some Table}
    \settowidth\rotheadsize{Questionary}
    \renewcommand\cellrotangle{60}
    \setcellgapes{1pt}
    \makegapedcells
\begin{tabularx}{\linewidth}{|*{6}{C|}c|c|*{3}{C|}}
    \hline
\mcc[11]{\thead{Complete name}}             \\
    \hline
\mcc[11]{\thead{Description}}               \\
    \hline
\multirow{4}{*}[1.5ex]{\rothead{Exam}}
    &   \multirow{4}{*}[1.5ex]{\rothead{Assistance}}
        &   \multirow{4}{*}[1.5ex]{\rothead{Questionary}}
            &   \multirow{4}{*}[1.5ex]{\rothead{Homework}}
                &   \multirow{4}{*}[1.5ex]{\rothead{Second\\ Program}}
                    &   \multirow{4}{*}[1.5ex]{\rothead{First\\ Program}}
                        &   \mcl[2]{Grup Characters}
                                &   \mcl[3]{Comments}       \\
    \cline{9-10}
    &   &   &   &   &   &   \mcl[2]{Date}
                                &   \mcl[2]{S}
                                    &                       \\
    \cline{9-9}
    &   &   &   &   &   &   \mcl[2]{Serial No:}
                                & \mcl{U} 
                                    &   &                   \\
    \cline{7-8}
    &   &   &   &   &   &   No:
                            &   Name
                                &   &   &                   \\
    \hline
10  & 10 & 10 & 10 & 10 & 10 & 1 & Jane Doe &   &   &       \\
    \hline
9   & 9  & 9  & 9  & 9  & 9  & 2 & Jane Doe &   &   &       \\  \hline
8   & 8  & 8  & 8  & 8  & 8  & 3 & Jane Doe &   &   &       \\  \hline
10  & 10 & 10 & 10 & 10 & 10 & 4 & Jane Doe &   &   &       \\  \hline
5   & 5  & 5  & 5  & 5  & 5  & 5 & Jane Doe &   &   &       \\  \hline
10  & 10 & 10 & 10 & 10 & 10 & 6 & Jane Doe &   &   &       \\  \hline
\end{tabularx}
    \end{table}
\end{document}

在此处输入图片描述

相关内容