更确切地说,我想要一个 18 × 26 cm² 的横向框,中间有一个规则。结合庄稼包装和此代码我有:
\documentclass{article}
\usepackage[paperwidth=18cm,paperheight=26cm]{geometry}
\usepackage[a4,frame,center,noinfo]{crop}
\begin{document}%
\thispagestyle{empty}%
\topskip0pt
\baselineskip0pt
\vspace*{\fill}%
\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}%
\vspace*{\fill}%
\end{document}
但正如您所见(我将尺寸缩小到 5 × 2 以便更明显),规则并不完全是一半。
我认为这是由于框的边距或规则的边距造成的。如何解决这个问题?
答案1
您必须为页面指定适当的边距。我已将边距设置为0in
。
\documentclass{article}
\usepackage[paperwidth=18cm,paperheight=26cm,margin=0in]{geometry} %% specify equal margin
%\usepackage[a4,frame,center,noinfo]{crop} %% not needed
\usepackage{tikz}
\begin{document}%
\thispagestyle{empty}%
\topskip0pt
\baselineskip0pt
\vspace*{\fill}%
\noindent\makebox[\linewidth]{\rule{\paperwidth}{0.4pt}}%
\vspace*{\fill}%
%% to confirm the center
\begin{tikzpicture}[remember picture,overlay]
\node[scale=3,text=red] at (current page.center) {X};
\end{tikzpicture}
\end{document}
红色X
只是为了显示中心。为了更安全,您可以将和headheight
设置为零。您可以在headsep
footskip
\usepackage[paperwidth=18cm,paperheight=26cm,margin=0in,headheight=0in,headsep=0in,footskip=0in]{geometry}
一个tikz
办法:
\documentclass{article}
\usepackage[paperwidth=18cm,paperheight=26cm,margin=0in]{geometry} %% specify equal margin
%\usepackage[a4,frame,center,noinfo]{crop} %% not needed
\usepackage{tikz}
\begin{document}%
\begin{tikzpicture}[remember picture,overlay]
\draw[olive, line width=8pt] (current page.south west) rectangle (current page.north east);
\draw[red, line width=0.4pt](current page.west) -- (current page.east);
\node[scale=3,text=red] at (current page.center) {X}; %%% uncomment just for demo
\end{tikzpicture}
\end{document}