我一直在努力使用longtable
、array
和rotating
包适当地对齐旋转的文本。我基本上希望列标题在底部对齐,但是,即使在发出明确的不规则指令后,LaTeX 也会将它们居中。
\documentclass[a4paper,10pt]{report}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{array}
\usepackage{rotating}
\begin{document}
\begin{longtable}{
>{\centering\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.60\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}|
>{\arraybackslash}m{0.010\linewidth}}
\caption{Minimal Example Table}
\label{tab:minimal-example:the-table} \\
\cline{3-9}
\multicolumn{1}{c}{} &
\multicolumn{1}{c|}{} &
\begin{sideways}\textbf{Column 1}\end{sideways} &
\begin{sideways}\textbf{Column 2}\end{sideways} &
\begin{sideways}\textbf{Column 3}\end{sideways} &
\begin{sideways}\textbf{Column 4}\end{sideways} &
\begin{sideways}\textbf{Long Column 1}\end{sideways} &
\begin{sideways}\textbf{Column 5}\end{sideways} &
\begin{sideways}\textbf{Column 6}\end{sideways}\\
\cline{1-9}
\endfirsthead
\caption[]{(continued)}\\
\cline{3-9}
\multicolumn{1}{c}{} &
\multicolumn{1}{c|}{} &
\begin{sideways}\textbf{Column 1}\end{sideways} &
\begin{sideways}\textbf{Column 2}\end{sideways} &
\begin{sideways}\textbf{Column 3}\end{sideways} &
\begin{sideways}\textbf{Column 4}\end{sideways} &
\begin{sideways}\textbf{Long Column 1}\end{sideways} &
\begin{sideways}\textbf{Column 5}\end{sideways} &
\begin{sideways}\textbf{Column 6}\end{sideways}\\
\cline{1-9}
\endhead
% Page footer
\cline{1-9}
\multicolumn{9}{c}{(Continued on next page)} \\
\endfoot
% Last page footer
%\bottomrule
\endlastfoot
\multirow{3}{*}{\begin{sideways}\textbf{R1}\end{sideways}} &
{Place holder text....}&
{}&
{}&
{}&
{}&
{X}&
{}&
{}\\
\cline{2-9}
{}&
{Place holder text....}&
{}&
{X}&
{X}&
{}&
{X}&
{X}&
{X}\\
\cline{1-9}
\multirow{3}{*}{\begin{sideways}\textbf{R2}\end{sideways}} &
{Place holder text....}&
{}&
{}&
{}&
{}&
{X}&
{}&
{}\\
\cline{2-9}
{}&
{Place holder text....}&
{}&
{X}&
{X}&
{}&
{X}&
{X}&
{X}\\
\cline{2-9}
{}&
{Place holder text....}&
{}&
{X}&
{X}&
{}&
{X}&
{X}&
{X}\\
\cline{1-9}
\end{longtable}
\end{document}
答案1
您指定的列宽不可能很窄,并且由于列说明符的原因,旋转的文本居中m
。
我会使用类似下面的东西,虽然我注意到你添加了一条评论说你需要指定列,这样你就可以切换c
回>{\centering\arraybackslash}p{...}
某个宽度。
旋转包主要是为了与同名的 latex2.09 包兼容,它只是标准 latex 旋转函数的包装器,因此使用它更简单。
\documentclass[a4paper,10pt]{report}
\usepackage{longtable}
\usepackage{multirow}
\usepackage{array}
\usepackage{rotating}
\begin{document}
\setlength\extrarowheight{3pt}
\begin{longtable}{
c|l|
*{7}{c|}}
\caption{Minimal Example Table}
\label{tab:minimal-example:the-table} \\
\cline{3-9}
\multicolumn{1}{c}{} &
\multicolumn{1}{c|}{} &
\rotatebox{90}{\textbf{Column 1 }} &
\rotatebox{90}{\textbf{Column 2 }} &
\rotatebox{90}{\textbf{Column 3 }} &
\rotatebox{90}{\textbf{Column 4 }} &
\rotatebox{90}{\textbf{Long Column 1 }} &
\rotatebox{90}{\textbf{Column 5 }} &
\rotatebox{90}{\textbf{Column 6 }}\\
\cline{1-9}
\endfirsthead
\caption[]{(continued)}\\
\cline{3-9}
\multicolumn{1}{c}{} &
\multicolumn{1}{c|}{} &
\rotatebox{90}{\textbf{Column 1}} &
\rotatebox{90}{\textbf{Column 2}} &
\rotatebox{90}{\textbf{Column 3}} &
\rotatebox{90}{\textbf{Column 4}} &
\rotatebox{90}{\textbf{Long Column 1}} &
\rotatebox{90}{\textbf{Column 5}} &
\rotatebox{90}{\textbf{Column 6}}\\
\cline{1-9}
\endhead
% Page footer
\cline{1-9}
\multicolumn{9}{c}{(Continued on next page)} \\
\endfoot
% Last page footer
%\bottomrule
\endlastfoot
\multirow{3}{*}{\rotatebox{90}{\textbf{R1}}} &
{Place holder text....}&
{}&
{}&
{}&
{}&
{X}&
{}&
{}\\
\cline{2-9}
{}&
{Place holder text....}&
{}&
{X}&
{X}&
{}&
{X}&
{X}&
{X}\\
\cline{1-9}
\multirow{3}{*}{\rotatebox{90}{\textbf{R2}}} &
{Place holder text....}&
{}&
{}&
{}&
{}&
{X}&
{}&
{}\\
\cline{2-9}
{}&
{Place holder text....}&
{}&
{X}&
{X}&
{}&
{X}&
{X}&
{X}\\
\cline{2-9}
{}&
{Place holder text....}&
{}&
{X}&
{X}&
{}&
{X}&
{X}&
{X}\\
\cline{1-9}
\end{longtable}
\end{document}