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 (still :) have a ham-radio logbook, a single a4 page which I fill out manually (so this is just an empty form/a template of sorts). Please see below for the code.

The page number is on the bottom left. I'd like to automatically print this one page multiple times, counting up the page numbers (whenever I need more pages to fill out - ham radio is fun sometimes!).

So basically I'd like to tell TeX "Take this template and print it 10 times, numbering the pages from 13 to 22".

Any ideas would be highly appreciated, as always.

\documentclass[12pt,a4paper,oneside,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{ragged2e}
\usepackage{array}
\usepackage[table]{xcolor}
\usepackage[a4paper, left=0.6cm, right=0.5cm,top=3.7cm, bottom=0.5cm]{geometry}
\usepackage{graphicx,type1cm,eso-pic}
\makeatletter
    \AddToShipoutPictureBG{
            \setlength{\@tempdimb}{.5\paperwidth}
            \setlength{\@tempdimc}{0.85\paperheight}
            \setlength{\unitlength}{1pt}
            \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){
            \makebox(0,0){\rotatebox{0}{\textcolor[gray]{.4}
            {\fontsize{2cm}{2cm}\selectfont{Amateurfunk-Log DC1TS}}}}}
    }

    \AddToShipoutPicture*{
            \setlength{\@tempdimb}{0.02\paperwidth}
            \setlength{\@tempdimc}{0.12\paperheight}
            \setlength{\unitlength}{1pt}
            \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){
            \makebox(0,0){\rotatebox{270}{\textcolor[gray]{0.65}
            {\fontsize{1cm}{1cm}\selectfont{Seite 004}}}}}
    }

\newcolumntype{M}[1]{>{\Centering}m{#1}}
\newcolumntype{C}{>{\rule[-3ex]{0pt}{8ex}}c}

\begin{document}
\sffamily
    \rowcolors{3}{gray!5}{white}
    \begin{tabular}{
    | M{2cm} %Datum
    | M{1.3cm}  %Zeit Start
    | M{1.3cm}  %Zeit Ende
    | M{2cm}  %Frequenz
    | M{1.5cm}  %Mode
    | M{3cm}  %Rufzeichen
    | M{3cm}  %Name
    | M{3cm}  %QTH
    | M{1.3cm} %Power
    | M{0.9cm} %Report gegeben
    | M{0.9cm} %Report erhalten
    | M{0.8cm} %QSL gesendet
    | M{0.8cm} %QSL erhalten
    |}
    \hline
    Datum & \multicolumn{2}{c|}{Zeit UTC} &
    Frequenz & Mode & Rufzeichen & Name & QTH & Power &
    \multicolumn{2}{c|}{Report} & \multicolumn{2}{c|}{QSL}  \\ [1ex]

    & Start & Ende & (MHz) &  &  & & & (W) & geg. & empf. & ges. & erh. \\ [1ex]
    \hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]    \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \end{tabular}

\end{document}

Error: Picture of error occuring

share|improve this question
    
If I add more pages to your document, I don't get any subsequent page numbers. Was this intended? –  Andrey Vihrov Aug 10 '11 at 8:43
    
yes, but inly out of lack of knowing; this basically is a one-page template, all other pages would be exactly the same. until now I only altered the line containing the hard-coded line number and printed it, repeating these steps multiple times. –  Christian Aug 10 '11 at 10:24
add comment

2 Answers

up vote 7 down vote accepted

I would use TikZ for this application. It not only gives you access to the \foreach functionality, but also allows for flexible positioning of text on the page. Also, using the \pgfmathprintnumber command you can automatically typeset the page numbers in the format you used (with leading zeros).

Note that you need to run LaTeX twice to get the placement of the page numbers and the title:

\documentclass[12pt,a4paper,oneside,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{ragged2e}
\usepackage{array}
\usepackage[table]{xcolor}
\usepackage[a4paper, left=0.6cm, right=0.5cm,top=3.7cm, bottom=0.5cm]{geometry}
\usepackage{graphicx,type1cm}
\usepackage{tikz}

\newcolumntype{M}[1]{>{\Centering}m{#1}}
\newcolumntype{C}{>{\rule[-3ex]{0pt}{8ex}}c}

\begin{document}
\sffamily
\rowcolors{3}{gray!5}{white}

\foreach \n in {10,...,20} {
\pgfmathsetmacro\pageno{\n/1000}
\tikz [remember picture,overlay]
    \node at (current page.north) [
        yshift=-2cm,
        black!60!white,
        scale=4.5] {Amateurfunk-Log DC1TS}
    node at (current page.south west) [
        black!60!white,
        rotate=-90,
        anchor=south east,
        scale=2.2,
        inner xsep=1em] {Seite $\mathsf{
            \pgfmathprintnumber[
                fixed,
                fixed zerofill,
                precision=3,
                skip 0.,
                dec sep={}
            ]{\pageno}}$};  

    \begin{tabular}{
    | M{2cm} %Datum
    | M{1.3cm}  %Zeit Start
    | M{1.3cm}  %Zeit Ende
    | M{2cm}  %Frequenz
    | M{1.5cm}  %Mode
    | M{3cm}  %Rufzeichen
    | M{3cm}  %Name
    | M{3cm}  %QTH
    | M{1.3cm} %Power
    | M{0.9cm} %Report gegeben
    | M{0.9cm} %Report erhalten
    | M{0.8cm} %QSL gesendet
    | M{0.8cm} %QSL erhalten
    |}
    \hline
    Datum & \multicolumn{2}{c|}{Zeit UTC} &
    Frequenz & Mode & Rufzeichen & Name & QTH & Power &
    \multicolumn{2}{c|}{Report} & \multicolumn{2}{c|}{QSL}  \\ [1ex]

    & Start & Ende & (MHz) &  &  & & & (W) & geg. & empf. & ges. & erh. \\ [1ex]
    \hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]    \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \end{tabular}
    \newpage
}
\end{document}

share|improve this answer
    
Very clever \pgfmathprintnumber hack there to get the leading zeroes! I considered using it but concluded it couldn't do what was needed here - didn't even think of something like this. –  Ant Aug 10 '11 at 10:13
    
I get a repeating error, as shown here: pastebin.com/at8TGEQR (can't post it here, somehow...). Any help greatly appreciated! –  Christian Aug 10 '11 at 10:48
1  
I think the problem is that you're using an older version of pgf - try upgrading to 2.10 (which is installed in TeX Live 2011 if you feel like upgrading the whole thing, or just get the package from ctan). –  Ant Aug 10 '11 at 10:55
2  
Yes, this is because you're using PGF 2.0. You should definitely update that package to 2.1. –  Jake Aug 10 '11 at 13:09
1  
@Christian: It looks like you didn't compile twice. The placement of TikZ objects with overlay, remember picture is only correct on the second compiler run –  Jake Aug 10 '11 at 22:18
show 3 more comments

An easy way is to use pgffor:

\documentclass[12pt,a4paper,oneside,landscape]{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}
\usepackage[ngerman]{babel}
\usepackage{ragged2e}
\usepackage{array}
\usepackage[table]{xcolor}
\usepackage[a4paper, left=0.6cm, right=0.5cm,top=3.7cm, bottom=0.5cm]{geometry}
\usepackage{graphicx,type1cm,eso-pic,pgffor}
\makeatletter
    \AddToShipoutPictureBG{
            \setlength{\@tempdimb}{.5\paperwidth}
            \setlength{\@tempdimc}{0.85\paperheight}
            \setlength{\unitlength}{1pt}
            \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){
            \makebox(0,0){\rotatebox{0}{\textcolor[gray]{.4}
            {\fontsize{2cm}{2cm}\selectfont{Amateurfunk-Log DC1TS}}}}}
    }

\newcolumntype{M}[1]{>{\Centering}m{#1}}
\newcolumntype{C}{>{\rule[-3ex]{0pt}{8ex}}c}

\begin{document}
\foreach\pagenumber in {13, ..., 22} {

    \AddToShipoutPicture*{
            \setlength{\@tempdimb}{0.02\paperwidth}
            \setlength{\@tempdimc}{0.12\paperheight}
            \setlength{\unitlength}{1pt}
            \put(\strip@pt\@tempdimb,\strip@pt\@tempdimc){
            \makebox(0,0){\rotatebox{270}{\textcolor[gray]{0.65}
            {\fontsize{1cm}{1cm}\selectfont{Seite 0\pagenumber}}}}}
    }

\sffamily
    \rowcolors{3}{gray!5}{white}
    \begin{tabular}{
    | M{2cm} %Datum
    | M{1.3cm}  %Zeit Start
    | M{1.3cm}  %Zeit Ende
    | M{2cm}  %Frequenz
    | M{1.5cm}  %Mode
    | M{3cm}  %Rufzeichen
    | M{3cm}  %Name
    | M{3cm}  %QTH
    | M{1.3cm} %Power
    | M{0.9cm} %Report gegeben
    | M{0.9cm} %Report erhalten
    | M{0.8cm} %QSL gesendet
    | M{0.8cm} %QSL erhalten
    |}
    \hline
    Datum & \multicolumn{2}{c|}{Zeit UTC} &
    Frequenz & Mode & Rufzeichen & Name & QTH & Power &
    \multicolumn{2}{c|}{Report} & \multicolumn{2}{c|}{QSL}  \\ [1ex]

    & Start & Ende & (MHz) &  &  & & & (W) & geg. & empf. & ges. & erh. \\ [1ex]
    \hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]    \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \hline
    & : & : & & & & & & & & & & \\ [4ex]        \hline
    \multicolumn{13}{|C|}{\textcolor{black!10}{\Huge\bfseries Notizen}}\\\hline
    \end{tabular}
\newpage
}
\end{document}

At the moment this is hardcoded for two-digit page numbers, but with a little bit more work you could add the right number of zeros depending on the page number, if you need that functionality.

share|improve this answer
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.