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.

I would like to avoid TikZ or another package. I would like the frame surrounds the page with a rule on all sides and I would like to have a page number below the frame in the middle. I have some difficulties to understand how to use \output and shipout

share|improve this question
    
You mean rules around the text area of the page, do you? –  Martin Scharrer Apr 10 '11 at 21:50
    
yes I would like one or two rules around the text area for every pages –  Alain Matthes Apr 10 '11 at 21:56
    
Any particular reason why you want to avoid using a package? –  Aditya Apr 11 '11 at 16:05
    
No I have to make some texts in plain TeX for friends –  Alain Matthes Apr 11 '11 at 16:12
add comment

2 Answers

up vote 6 down vote accepted

Plain TeX solution:

\def\frameit#1#2{%
 \vbox{\hrule
  \hbox{%
    \vrule \kern#2pt
      \vbox{\kern#2pt #1
         \kern#2pt}%
      \kern#2pt\vrule}
\hrule}}

\output={%
   \shipout\vbox{%
    \frameit{\box255}9
      \medskip
      \centerline{Test Framed Page}}
  \advancepageno}

\frameit{1}{1}
\bye

For any chance to understand output routines start from plain TeX and the TeXBook. See also this post, where I posted some links to TUGBoat articles about the OTR.

share|improve this answer
    
thanks I was looking for a solution like this. Thanks for the post my problem is how to use shipout. –  Alain Matthes Apr 10 '11 at 22:17
    
@Altermundus If you want to hook anything into LaTeX's output routine rather hook at AtBeginDvi, have a look at source2e. –  Yiannis Lazarides Apr 10 '11 at 22:21
1  
TeX by Topic has a concise explanation of the use of \output, section 28.2. –  Charles Stewart Apr 11 '11 at 5:46
add comment

You could draw the rules by yourself inside the header and footer. See e.g. the layout package to learn about the exact offsets you have to use.

Here my try which is pretty accurate:

\documentclass{article}

\usepackage{lipsum}
\usepackage{fancyhdr}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}

\pagestyle{fancy}

\lhead{%
    \raisebox{\dimexpr-\headsep-\dp\strutbox\relax}[0pt][0pt]{\rlap{\hbox to \textwidth{\hrulefill}}}%
    \raisebox{\dimexpr-\headsep-\textheight-\dp\strutbox\relax}[0pt][0pt]{\vrule height \textheight}%
}
\rhead{%
    \raisebox{\dimexpr-\headsep-\textheight-\dp\strutbox\relax}[0pt][0pt]{\vrule height \textheight}%
}
\lfoot{%
    \raisebox{\footskip}[0pt][0pt]{\rlap{\hbox to \textwidth{\hrulefill}}}%
}

\begin{document}
\lipsum[1-40]
\end{document}

Result:

Result

share|improve this answer
    
Interesting and more clear to understand for me but I prefer to avoid the use of a package. This solution can be useful ! thanks now I need to understand the code from Yiannis –  Alain Matthes Apr 10 '11 at 22:22
add comment

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.