5

More precisely, I want to get a 18 × 26 cm² landscape box with a rule at the middle. Combining the crop package and this code I got:

\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}

But as you can see (I reduced the size to 5 × 2 so it's more visible), the rule isn't exactly halfway.

Halfway rule

I assume this is due either to the box's margins or the rule's margins. How to work this out?

2

You have to specify a proper margin for the page. I have set a margin of 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}

enter image description here

The red X is the just to show the center. To be on safer side, you may set headheight, headsep and footskip also to be zero. You may do so in

\usepackage[paperwidth=18cm,paperheight=26cm,margin=0in,headheight=0in,headsep=0in,footskip=0in]{geometry}

A tikz solution:

\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}

enter image description here

  • Why the shifts? It's enough to use \draw[red, line width=0.4pt](current page.west) -- (current page.east);. – Gonzalo Medina May 26 '14 at 23:50
  • 1
    @GonzaloMedina Because I am still sleeping ;). It is morning 5.20 here. I will correct. Thanks. – user11232 May 26 '14 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.