我想将其设置table
为横向模式。为此,我使用了pdflscape
包。但我无法获得所需的结果。该怎么做?
以下是 MWE:
\documentclass[12pt]{article}
\usepackage{xtab,caption}
\usepackage{pdflscape}
\newcommand\Lenv{\textsf}
\begin{document}
\begin{landscape}
\topcaption{The principal xtab package commands} \label{tab:xtab}
\tablefirsthead{\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tablehead{\multicolumn{2}{c}%
{{\captionsize\bfseries \tablename\ \thetable{} --
continued from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tablelasthead{\multicolumn{2}{c}%
{{\captionsize\bfseries \tablename\ \thetable{} --
concluded from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tabletail{\hline \multicolumn{2}{|r|}{{Continued on next page}} \\ \hline}
\tablelasttail{\hline \hline}
\begin{center}
\begin{xtabular}{|l|p{0.5\textwidth}|}
\verb|\begin{xtabular}{...}| & This is equivalent to the normal
\verb|\begin{tabular}{...}| environment.
You supply the specification of the columns
just as for the normal \Lenv{tabular} environment.
\\
&
All commands that can be used within a \Lenv{tabular}
environment can also be used within
the \Lenv{xtabular} environment.
\\
&
Unlike the \Lenv{tabular} environment which prevents page breaking
within the tabular, the \Lenv{xtabular} allows page breaking, so that
tabulars can extend automatically across several pages.
... ... ...\\
\verb|\tablelasttail{...}| & The contents of this command are inserted before
the final (internal) \verb|\end{tabular}| of the table.
\\
&
For example, you might want to note that this is where
the table ends.
\\
\end{xtabular}
\end{center}
\end{landscape}
\end{document}
答案1
使用
\begin{xtabular}{|l|p{0.5\linewidth}|}
lscape
\textwidth
景观环境没有发生改变。
答案2
另一个选项是使用\textheight
。由于横向布局时,文本高度和文本宽度不会交换,因此表格的宽度沿着文本高度。在 中输入适当的值0.9\textheight
:
\documentclass[12pt]{article}
\usepackage{xtab,caption}
\usepackage{pdflscape}
\newcommand\Lenv{\textsf}
\begin{document}
\begin{landscape}
\topcaption{The principal xtab package commands} \label{tab:xtab}
\tablefirsthead{\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tablehead{\multicolumn{2}{c}%
{{\captionsize\bfseries \tablename\ \thetable{} --
continued from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tablelasthead{\multicolumn{2}{c}%
{{\captionsize\bfseries \tablename\ \thetable{} --
concluded from previous page}} \\
\hline \multicolumn{1}{|c|}{\textbf{Command}} &
\multicolumn{1}{c|}{\textbf{Effect}} \\ \hline }
\tabletail{\hline \multicolumn{2}{|r|}{{Continued on next page}} \\ \hline}
\tablelasttail{\hline \hline}
\begin{center}
\begin{xtabular}{|l|p{0.9\textheight}|}
\verb|\begin{xtabular}{...}| & This is equivalent to the normal
\verb|\begin{tabular}{...}| environment.
You supply the specification of the columns
just as for the normal \Lenv{tabular} environment.
\\
&
All commands that can be used within a \Lenv{tabular}
environment can also be used within
the \Lenv{xtabular} environment.
\\
&
Unlike the \Lenv{tabular} environment which prevents page breaking
within the tabular, the \Lenv{xtabular} allows page breaking, so that
tabulars can extend automatically across several pages.
... ... ...\\
\verb|\tablelasttail{...}| & The contents of this command are inserted before
the final (internal) \verb|\end{tabular}| of the table.
\\
&
For example, you might want to note that this is where
the table ends.
\\
\end{xtabular}
\end{center}
\end{landscape}
\end{document}