我的文档应该是 letterpaper,附件应该是 a4paper。我对包\newgeometry
中的命令寄予厚望geometry
,但文档说
\newgeometry
与 几乎类似,\geometry
只是它\newgeometry
禁用了序言中指定的所有选项,并跳过了与纸张大小相关的选项:landscape
和portrait
纸张大小选项(例如papersize
等等paper=a4paper
)。
任何帮助都将不胜感激!
答案1
PDFLaTeX 中的功能如下:
\documentclass{article}
\begin{document}
Normal page
\eject \pdfpagewidth=3in \pdfpageheight=10in
Tall page
\eject \pdfpagewidth=10in \pdfpageheight=3in
Wide page
\end{document}
这应该与 Xelatex 配合使用。请参阅 SO qn,在乳胶文档中间更改纸张尺寸?,了解更多。
答案2
您可以使用typearea
包(KOMA-Script 包)更改纸张大小,并重新计算所有相关边距、页眉和页脚位置等。以下代码演示了该技术,但会生成一些与违反排版规则相关的警告(不建议在 A3 上放置 10pt 字体)。您可能需要调整一些进一步的typearea
设置以获得更好的结果。
\documentclass{article}
\usepackage[paper=A4]{typearea}
\usepackage{lipsum}% dummy code
\begin{document}
\lipsum% Placed on A4
\KOMAoptions{paper=A3}
\recalctypearea
\lipsum% Placed on A3
\KOMAoptions{paper=A4}
\recalctypearea
\lipsum% Placed on A4 again
\end{document}
一些 KOMA-Script 选项会自动触发重新计算类型区域和“页面设置”,但paper
实际上并非如此。不过,在文档中间重新计算会产生新页面,因此这里不需要\clearpage
、\newpage
或。\eject
答案3
下面是一个简化的示例,它在两个自定义页面大小和相应的布局(边距)之间切换,可以编译pdflatex
- 有关更多详细信息,请参阅我的回答在 xelatex 中使用“几何”设置正确的自定义页面大小时出现问题:
\documentclass{article}
% reminder: US letter: 596pt x 795pt
\newlength{\pagewidthA}
\newlength{\pageheightA}
\setlength{\pagewidthA}{300bp}
\setlength{\pageheightA}{400bp}
\newlength{\pagewidthB}
\newlength{\pageheightB}
\setlength{\pagewidthB}{400bp}
\setlength{\pageheightB}{500bp}
% stockwidth and stockheight - from memoir,
% here just for cheating `layouts` warnings
\newlength{\stockwidth}
\newlength{\stockheight}
\usepackage{geometry}
% this command will take effect into L1 layout just after \begin{document}
% but the L1 geometry will otherwise be ignored
\geometry{twoside,inner=50bp,outer=30bp,top=50bp,bottom=50bp}
\usepackage{tikz,enumitem}
\usepackage{fix-cm}
\usepackage{layouts}
\usepackage{etoolbox}
\patchcmd{\drawpage}{\ifdrawparameters}{\iftrue}%
{\typeout{^^J*******\string\drawpage fixed*******^^J}}%
{\typeout{^^J*******\string\drawpage not fixed*******^^J}}
\usepackage{lipsum}
\makeatletter
\newcommand{\printpagevalues}{%
% from geometry.sty:
* paper: \ifx\Gm@paper\@undefined<default>\else\Gm@paper\fi \\%
* layout: \ifGm@layout<custom>\else<same size as paper>\fi \\%
\@ifundefined{ifGm@layout}{}{%
\ifGm@layout
* layout(width,height): (\the\Gm@layoutwidth,\the\Gm@layoutheight) \\%
\fi
* layoutoffset:(h,v)=(\the\Gm@layouthoffset,\the\Gm@layoutvoffset) \\%
}%
\pagevalues % from package layouts
}
\makeatother
\newcommand{\generatePageLayouts}{%
\newgeometry{layoutwidth=\pagewidthA,layoutheight=\pageheightA,left=1mm,right=5mm,bottom=1mm,top=1mm}
\savegeometry{LayoutPageA}
\newgeometry{layoutwidth=\pagewidthB,layoutheight=\pageheightB,twoside,inner=2.5cm,outer=0.5cm,top=1.5cm,bottom=1.5cm}
\savegeometry{LayoutPageB}
}
\newcommand{\switchToLayoutPageA}{%
% switch page size first:
\pdfpagewidth=\pagewidthA \pdfpageheight=\pageheightA % for PDF output
\paperwidth=\pagewidthA \paperheight=\pageheightA % for TikZ
\stockwidth=\pagewidthA \stockheight=\pageheightA % hyperref (memoir)?!
\loadgeometry{LayoutPageA} % note; \loadgeometry may reset paperwidth/h!
}
\newcommand{\switchToLayoutPageB}{%
% switch page size first:
\pdfpagewidth=\pagewidthB \pdfpageheight=\pageheightB % for PDF output
\paperwidth=\pagewidthB \paperheight=\pageheightB % for TikZ
\stockwidth=\pagewidthB \stockheight=\pageheightB % hyperref (memoir)?!
\loadgeometry{LayoutPageB} % note; \loadgeometry may reset paperwidth/h!
}
\begin{document}
% here geometry layout L1 is instantiated;
% without anything else, paper size defaults to US letter!
% \restoregeometry command restores L1!!
\fontsize{8}{9}\selectfont % this nowork in preamble!
% generate page layouts first based on layoutwidth as page size;
% don't switch actual page sizes yet:
\generatePageLayouts{}
%%% start with content
% start with LayoutPageA (includes switching page size)
\switchToLayoutPageA{}
\pagestyle{empty} % no page numbers here
\\
\the\paperwidth
\lipsum[1]
\printpagevalues{}
\clearpage
% switch to LayoutPageB (includes switching page size)
\switchToLayoutPageB{}
% start page numbering here ("this will reset the page number"):
\pagenumbering{arabic}
% make page numbers visible
\pagestyle{plain}
\the\paperwidth
\lipsum[1]
Trying
some
text
\printpagevalues{}
\end{document}