Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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