似乎两者都\textwidth
不能\textheight
强制表格填满整个宽度。
\documentclass[dvips]{book}
\usepackage[a4paper,margin=20mm,showframe]{geometry}
\usepackage{lscape}
\usepackage{lipsum}
\usepackage{calc}
\usepackage{longtable,array}
\begin{document}
\chapter{One}
\lipsum[1]
\section{One One}
\lipsum[2]
\pagestyle{empty}
\begin{landscape}
\begin{longtable}{|m{0.4\textheight-2\tabcolsep-1.5\fboxrule}|m{0.6\textheight-2\tabcolsep-1.5\fboxrule}|}
\hline
a & b\\\hline
c & d\\\hline
\end{longtable}
\end{landscape}
\pagestyle{plain}
\lipsum[3]
\end{document}
编辑1:
我对列宽进行了修正,即改为2\fboxrule
。1.5\fboxrule
之前的计算是错误的,因为两列之间的规则不应该计算两次。我在这里有点失误。
我得到了如下输出:
编辑2:这是我的真实场景(与最少的代码相反)
\documentclass[dvipsnames,rgb,dvips]{book}
\usepackage[a4paper,margin=20mm,showframe]{geometry}
\usepackage{longtable}
\usepackage{array}
\usepackage{calc}
\usepackage{ltablex}
\usepackage{lscape}
\newcounter{No}
\renewcommand{\theNo}{\stepcounter{No}\arabic{No}}
\newenvironment{MyTable}[4]%
{%
\newcolumntype{A}[1]%
{%
>{%
\begin{minipage}%
{%
##1\textwidth-2\tabcolsep-1.5\arrayrulewidth%
}%
\vspace{\tabcolsep}%
}%
c%
<{\vspace{\tabcolsep}\end{minipage}}%
}%
\setcounter{No}{0}%comment out this if you want to continuous numbering for all tables.
\begin{longtable}%
{%
|>{\scriptsize\centering\theNo}A{#1}<{}%
|>{}A{#2}<{\centering\input{\jobname.tmp}}%
|>{\centering\lstinputlisting{\jobname.tmp}}A{#3}<{}%
|>{\scriptsize\arraybackslash}A{#4}<{}%
|%
}%
\hline\ignorespaces%
}%
{%
\end{longtable}%
}
\newcommand{\Comment}[1]{& & & #1\\\hline}
\usepackage{listings}
\lstset{%
language={PSTricks},
basicstyle=\ttfamily\scriptsize,%
keywordstyle=\color{blue}%,
%backgroundcolor=\color{yellow!30}%
}
\usepackage{fancyvrb}
\def\MyRow{%
\VerbatimEnvironment%
\begin{VerbatimOut}{\jobname.tmp}%
}
\def\endMyRow{%
\end{VerbatimOut}%
}
\usepackage{pstricks,pst-node}
\newpsstyle{gridstyle}{%
gridwidth=0.4pt,%default: 0.8pt
gridcolor=Red!20,%default: black
griddots=0,%default: 0
%
gridlabels=3pt,%default: 10pt
gridlabelcolor=Blue,%default: black
%
subgriddiv=5,%default: 5
subgridwidth=0.2pt,%default: 0.4pt
subgridcolor=Green!20,%default: gray
subgriddots=0%default: 0
}
\usepackage{lipsum}
\begin{document}
\chapter{Introduction to PSTricks}
\lipsum[1]
\section{At a glance galleries}
\lipsum[1-5]
%Landscape starts here.
%\pagestyle{empty}
\begin{landscape}
\thispagestyle{empty}
\begin{MyTable}{0.05}{.25}{0.4}{0.3}%
%=============
\begin{MyRow}
\pspicture*[showgrid](4,4)
\pnode(1,1){A}
\pnode(3,3){B}
\ncline{A}{B}
\endpspicture
\end{MyRow}
\Comment{\lipsum[1]}
%=============
\begin{MyRow}
\begin{pspicture}[showgrid](4,3)
\psframe*[linecolor=red!30](3,2)
\end{pspicture}
\end{MyRow}
\Comment{\lipsum[2]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=green!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[3]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=yellow!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[4]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=Maroon!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[5]}
%=============
\end{MyTable}
%Landscape stops here.
\end{landscape}
%\pagestyle{plain}
\section{Node}
\lipsum[1-5]
\end{document}
不幸的是,\arrayrulewidth
不起作用。
编辑3:
dvips
已为上述两个代码片段添加了。但\arrayrulewidth
仍然无法按我们想要的方式工作。
答案1
这是我的解决方案
\documentclass[dvipsnames,rgb,dvips]{book}
\usepackage[a4paper,margin=20mm,showframe]{geometry}
\usepackage{longtable}
\usepackage{array}
\usepackage{calc}
\usepackage{ltablex}
\usepackage{lscape}
\usepackage{ragged2e}
\newcounter{No}
\renewcommand{\theNo}{\stepcounter{No}\arabic{No}}
\newcolumntype{A}[1]{%
>{\vspace*{\medskipamount}\Centering}
p{#1\linewidth-2\tabcolsep-2\arrayrulewidth}
<{\smallskip}}
\newenvironment{MyTable}[4]%
{\setcounter{No}{0}%comment out this if you want to continuous numbering for all tables.
\begin{longtable}{%
|>{\scriptsize\theNo}A{#1}<{}%
|>{}l<{\minipage[t]{#2\linewidth-2\tabcolsep-2\arrayrulewidth}
\vspace{0pt}\input{\jobname.tmp}\endminipage}%
|>{\Centering\lstinputlisting{\jobname.tmp}}A{#3}<{}%
|>{\scriptsize\arraybackslash}A{#4}<{}%
|%
}%
\hline\ignorespaces%
}%
{%
\end{longtable}%
}
\newcommand{\Comment}[1]{& & & #1\\\hline}
\usepackage{listings}
\lstset{%
language={PSTricks},
basicstyle=\ttfamily\scriptsize,%
keywordstyle=\color{blue}%,
%backgroundcolor=\color{yellow!30}%
}
\usepackage{fancyvrb}
\def\MyRow{%
\VerbatimEnvironment%
\begin{VerbatimOut}{\jobname.tmp}}
\def\endMyRow{\end{VerbatimOut}}
\usepackage{pstricks,pst-node}
\newpsstyle{gridstyle}{%
gridwidth=0.4pt,%default: 0.8pt
gridcolor=Red!20,%default: black
griddots=0,%default: 0
%
gridlabels=3pt,%default: 10pt
gridlabelcolor=Blue,%default: black
%
subgriddiv=5,%default: 5
subgridwidth=0.2pt,%default: 0.4pt
subgridcolor=Green!20,%default: gray
subgriddots=0%default: 0
}
\usepackage{lipsum}
\begin{document}
\chapter{Introduction to PSTricks}
\lipsum[1]
\section{At a glance galleries}
\lipsum[1-5]
%Landscape starts here.
%\pagestyle{empty}
\begin{landscape}
\noindent
\rule{\linewidth}{4pt}
\thispagestyle{empty}
\begin{MyTable}{0.05}{.25}{0.4}{0.3}%
%=============
\begin{MyRow}
\pspicture[showgrid](4,4)
\pnode(1,1){A}
\pnode(3,3){B}
\ncline{A}{B}
\endpspicture
\end{MyRow}
\Comment{\lipsum[1]}
%=============
\begin{MyRow}
\begin{pspicture}[showgrid](4,3)
\psframe*[linecolor=red!30](3,2)
\end{pspicture}
\end{MyRow}
\Comment{\lipsum[2]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=green!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[3]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=yellow!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[4]}
%=============
\begin{MyRow}
\pspicture[showgrid](4,3)
\psframe*[linecolor=Maroon!30](3,2)
\endpspicture
\end{MyRow}
\Comment{\lipsum[5]}
%=============
\end{MyTable}
%Landscape stops here.
\end{landscape}
%\pagestyle{plain}
\section{Node}
\lipsum[1-5]
\end{document}
答案2
总是在环境\linewidth
内使用landscape
不是 \textwidth
答案3
我发现了一个非常简单的解决方案:只需使用
\resizebox{\linewidth}{!}{
\begin{tabular}{}
%Your table content
\end{tabular}
}
显然\linewidth
是由景观重新定义的,但\textwidth
事实并非如此。
答案4
免责声明:此解决方案旨在仅限 KOMA-script 的课程。
landscape
包的环境确实pdflscape
是创建侧向浮动的关键,如图所示赫伯特的解决方案。
事实上,它会旋转浮动,但保持页眉和脚注的正确位置。此外,它还会自动旋转 pdf 中的相关页面,以便于在屏幕上阅读文档。
但是,正如 KOMA-Script 文档第 16.6 条所述:
包
lscape
定义了一个环境 Landscape 来设置页面内容,但不设置页眉和页脚 Landscape。在这个环境中,它会更改\textheight
为 的值\textwidth
,但不会更改\textwidth
为 的原值\textheight
。这是不一致的。
因此,KOMA-script 类的解决方案也是加载包scrhack
,后 pdflscape
。
\documentclass{scrartcl}
%needed for this solution
\usepackage{pdflscape}
\usepackage{scrhack}
%mainstream packages for tables
\usepackage{tabularx}
\usepackage{booktabs}
%for illustration purpose
\usepackage{lipsum}
\usepackage{showframe}
\begin{document}
\lipsum[1-2]
\begin{landscape}%
\captionof{table}[Caption for LoT]{Caption of the table}%
\small%
\noindent%
\begin{tabularx}{\textheight}{lXX}
\toprule
\emph{Lorem}
&
\textbf{Ipsum dolor}
&
\textbf{Sit amet}
\\
\midrule
\emph{Consectetur adipiscing}
&
In sed facilisis lacus, consectetur volutpat nulla. Praesent quis vulputate urna.
&
Suspendisse non dui fermentum, convallis velit non, consequat diam.
\\
\emph{In at sem eros.}
&
Maecenas tellus eros, porttitor non varius eget, porttitor eu ipsum.
&
Etiam accumsan pharetra convallis.
\\
\bottomrule
\end{tabularx}%
\end{landscape}
\lipsum[3-4]
\end{document}