我想测试横向表格,并从横向环境开始。但是代码无法编译,我收到错误:
(./content/landscapetable.tex
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \begin{center}
这是一个简单的例子:
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{rotating}
\begin{document}
\begin{sideways}
\begin{center}
\centering
% \captionsetup{type=table}
% \caption{Sehr breite Tabelle.}
\begin{tabularx}{0.8\textheight}{XXX}
\hline
head & head & head \\
\hline
text which is considereably longer than
the width of the column &
text which is considereably longer than
the width of the column &
text which is considereably longer than
the width of the column \\
\hline
\end{tabularx}
\end{center}
\end{sideways}
\end{document}
删除侧面环境,然后进行编译。
编辑:当中心环境被移除,并且居中保留,并且再次引入标题时,会出现另一个标题错误。
\begin{sideways}
\centering
\captionsetup{type=table}
\caption{Sehr breite Tabelle.}
\begin{tabularx}{1.0\textheight}{*{6}{X}}
\hline
head & head & head & head & head & head \\
...
\end{tabularx}
\end{sideways}
然后错误是
! Missing \endgroup inserted.
<inserted text>
\endgroup
l.5 \caption{Sehr breite Tabelle.}
使用 sidewaystable 可以工作,但这不是我想要的。
答案1
为什么两者都\centering
需要center
环境?删除后者,示例就可以正常编译。
(基于评论的新解决方案。)
如果您不想旋转标题,为什么要将标题放在环境中sideways
?您可以做的是将表格放在正常table
环境中,然后将 放在tabularx
中sideways
。
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage{tabularx}
\usepackage{caption}
\usepackage{rotating}
\begin{document}
\begin{table}
\centering
\captionsetup{type=table}
\caption{Sehr breite Tabelle.}
\begin{sideways}
\begin{tabularx}{0.8\textheight}{XXX}
\hline
head & head & head \\
\hline
text which is considereably longer than
the width of the column &
text which is considereably longer than
the width of the column &
text which is considereably longer than
the width of the column \\
\hline
\end{tabularx}
\end{sideways}
\end{table}
\end{document}
另一方面,我认为最好使用sidewaystable
,并将标题也旋转。在阅读标题和阅读表格之间必须翻页会很尴尬和不方便。