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.

Suppose you have a short document (including a fancy header) which occupies only a small part of a DIN A4 page, like in this example:

\documentclass[a4paper, 12pt]{article}

\usepackage[top=2cm,hmargin=2.2cm]{geometry}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhf{}
\fancyhead[R]{\small \today}
\fancyhead[L]{\small  header}
\fancyfoot[C]{}


\begin{document}
short text  short text  short text short text  short
text  short text  short text  short text  short text  short
text  short text short text  short text  short text  short
text short text  short text  short text  short text  short
text  short text  short text  short text  short text end of the text.
\end{document}

Suppose I want to print this text 50 times. To save paper I would print it and use a photocopier to copy this text incl. fancy header several times to one sheet of paper.

Now my question is, if there is a simple LaTeX way to do this, i.e. in the above example, have as many copies of all text from fancy header to "end of the text" automatically on a DIN A4 sheet as you can fit on it?

share|improve this question

1 Answer 1

up vote 7 down vote accepted

I do not know an fully automatically way, but it is possible to do it manually with minimal adjustments.

First way:

Reduce the height of the page to the minimal height by replacing a4paper with pagewidth=21cm,pageheight=4cm (here 21cm is the A4 width and 4cm depends on the text content and margin requirements).

\usepackage[top=2cm,hmargin=2.2cm,paperwidth=21cm,paperheight=4cm]{geometry}

Then create a second small LaTeX document which includes the PDF of the first using the pdfpages pages and places it multiple times on one page:

\documentclass[a4paper]{article}
\usepackage{pdfpages}
\begin{document}
\includepdf[page={1,1,1,1,1,1,1},nup=1x7]{mainfile}
\end{document}

This places the first document (called mainfile.tex/.pdf here) seven times on page. Adjust both the number of 1, and the number of nup=1x to the real number which fit on one page.

Example Result:

Result


Second way:

You could create the headers using normal text instead so it can be repeated over the page. A tabular would be adequate here. Putting the main text into one multi-column cell also prevents page breaks inside the text. The the text could be repeated using a loop. Adjust the \vspaces and the repeat numbers to fit your requirements.

\documentclass[a4paper, 12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[pdftex]{graphicx}
\usepackage[top=2cm,hmargin=2.2cm]{geometry}
\pagestyle{empty}

\begin{document}

\newcount\num
\loop\ifnum\num<7
\par\noindent
\begin{tabular}{@{}l@{}r@{}}
    \small \today & header \\
    \hline\noalign{\vspace{.5cm}}
    \multicolumn{2}{@{}p{\linewidth}@{}}{%
\hspace*{\parindent}% if par indent is required
 short text  short text  short text short text  short
text  short text  short text  short text  short text  short
text  short text short text  short text  short text  short
text short text  short text  short text  short text  short
text  short text  short text  short text  short text end of the text
}
\end{tabular}
\par\vspace{1cm}%
\advance\num by 1
\repeat

\end{document}
share|improve this answer
    
The problem I am finding with this (2nd) solution is, if I put a `\` in the text, I get endless stream of errors given below ... see removed non-answer –  Tem Pora Nov 24 '12 at 6:56

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.