多次打印单页,并计算页码

多次打印单页,并计算页码

我(仍然:)有一本业余无线电日志,一张 A4 纸,我手动填写(所以这只是一个空表格/某种模板)。请参阅下面的代码。

页码在左下角。我想自动多次打印这一页,并计算页码(每当我需要填写更多页面时 - 业余无线电有时很有趣!)。

所以基本上我想告诉 TeX“拿着这个模板打印 10 次,把页码从 13 到 22”。

一如既往,任何想法都会受到高度赞赏。

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

错误: 发生错误的图片

答案1

我会在这个应用程序中使用 TikZ。它不仅可以让您访问\foreach功能,还可以灵活地在页面上定位文本。此外,使用该\pgfmathprintnumber命令,您可以自动以您使用的格式(带前导零)排版页码。

请注意,您需要运行两次 LaTeX 才能获得页码和标题的位置:

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

答案2

一个简单的方法是使用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}

目前,这是对两位数页码的硬编码,但如果您需要该功能,只需稍微做一点工作,您就可以根据页码添加正确数量的零。

相关内容