我目前正在尝试创建单页程序(描述单位的配置文件),我的计划是使用表格来实现。除了表格内文本的对齐方式外,它运行良好。我使用 p{...},因为我想要左上对齐,但这会导致以下输出:
对齐到底部 (b{...}) 效果很好,问题似乎只发生在左列旋转时。我已经尝试了各种方法,比如不同的旋转方式(例如 \begin{sideways})、尝试调整列宽等等。
\documentclass[twoside, english, draft]{article}
\usepackage{rotating}
\usepackage{array}
\newdimen\NetTableWidth
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\noindent
\NetTableWidth=\dimexpr
\linewidth
- 8\tabcolsep
- 5\arrayrulewidth
\relax
\begin{center}
\begin{longtable}{
p{.05\NetTableWidth}
p{.45\NetTableWidth}
p{.45\NetTableWidth}
}
\toprule
& \textbf{Parameter a} & \textbf{Parameter b} \\
\midrule
\rotatebox{90}{\textbf{Factor a}}
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
\\
\addlinespace[1em]
\rotatebox{90}{\textbf{Factor b}}
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\\
\bottomrule
\end{longtable}
\end{center}
\end{document}
答案1
使用 键。您可以使用– 我以第二行为例来[origin=r]
微调对齐方式:\raisebox
\documentclass[twoside, english, draft]{article}
\usepackage{rotating}
\usepackage{array}
\newdimen\NetTableWidth
\usepackage{booktabs}
\usepackage{longtable}
\begin{document}
\noindent
\NetTableWidth=\dimexpr
\linewidth
- 8\tabcolsep
- 5\arrayrulewidth
\relax
\begin{longtable}{
p{.05\NetTableWidth}
p{.45\NetTableWidth}
p{.45\NetTableWidth}
}
\toprule
& \textbf{Parameter a} & \textbf{Parameter b} \\
\midrule
\rotatebox[origin=r]{90}{\textbf{Factor a}}
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
\\
\addlinespace[1em]
\raisebox{0.43ex}{\rotatebox[origin=r]{90}{\textbf{Factor b}}}
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\\
\bottomrule
\end{longtable}
\end{document}
答案2
Bernard 给出了一个很好的答案,但这里还有另一种方法
您可以使用\multirow{1}{=}{\centering \adjustbox{valign=c, rotate=90}{<cell contents>}}
。这里的=
意思是多行宽度将由表格前言决定。
\documentclass[twoside, english, draft]{article}
\usepackage{rotating}
\usepackage{array}
\newdimen\NetTableWidth
\usepackage{booktabs}
\usepackage{longtable}
\usepackage{adjustbox}
\usepackage{multirow}
\begin{document}
\noindent
\NetTableWidth=\dimexpr
\linewidth
- 8\tabcolsep
- 5\arrayrulewidth
\relax
\begin{center}
\begin{longtable}{
p{.05\NetTableWidth}
p{.45\NetTableWidth}
p{.45\NetTableWidth}
}
\toprule
& \textbf{Parameter a} & \textbf{Parameter b}
\\
\midrule
\multirow{1}{=}{\centering \adjustbox{valign=c, rotate=90}{\textbf{Factor a}}}
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
\\
\addlinespace[1em]
\multirow{1}{=}{\centering \adjustbox{valign=c, rotate=90}{\textbf{Factor b}}}
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis.
&
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit, vestibu-
lum ut, placerat ac, adipiscing vitae, felis. Curabitur dictum gravida mauris.
Nam arcu libero, nonummy eget, consectetuer id, vulputate a, magna.
\\
\bottomrule
\end{longtable}
\end{center}
\end{document}