2

I am aiming to typeset a manual of procedures. For the sake of simplicity, I will use same code as in my previous question:

\documentclass[a4paper,14pt]{extreport}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{framed, color}
\definecolor{shadecolor}{rgb}{0.64, 0.64, 0.82}

\begin{document}
\begin{flushright}
\textsl{\textcolor{red}{Procurement  Protocol \textnumero 001}}\\
\today
\end{flushright}
\begin{center}
\textbf{{\Large     Protocols for Safe Procurement of Specimens \\
Procurement  Protocol \textnumero 001}}
\end{center}
\begin{multicols}{2}
\linespread{1.5}\selectfont
\setlength{\parindent}{0pt}
\textbf{Procurement \textnumero:} \dotfill
\textbf{Procurement date:} \dotfill
\textbf{Shipment type:} \dotfill
\textbf{Received by:} \dotfill
\textbf{Received on date:} \dotfill
\textbf{Country of origin:} \dotfill
\end{multicols}
\begin{shaded}
\centering\Large\bfseries Exemplary Specimen:
\end{shaded}
\lipsum[1]
\newpage
\begin{flushright}
\textsl{\textcolor{red}{Procurement  Protocol \textnumero \textbf{002}}}\\
\today
\end{flushright}
\begin{center}
\textbf{{\Large     Protocols for Safe Procurement of Specimens \\
            Procurement  Protocol \textnumero \textbf{002}}}
\end{center}
\begin{multicols}{2}
\linespread{1.5}\selectfont
\setlength{\parindent}{0pt}
\textbf{Procurement \textnumero:} \dotfill
\textbf{Procurement date:} \dotfill
\textbf{Shipment type:} \dotfill
\textbf{Received by:} \dotfill
\textbf{Received on date:} \dotfill
\textbf{Country of origin:} \dotfill
\end{multicols}
\begin{shaded}
\centering\Large\bfseries Exemplary Specimen:
\end{shaded}
\lipsum[2]
\end{document}

The document should contain a set of short (5-7 pp) instructions. As per requirements, each instruction should bear a "number stamp" in either left or right top corner of the page, as you can see in the image below. enter image description here Of course, I can add "number stamp" manually with \flushright environment, as in the "example" code, but is there a way to accomplish this in semi-automatic manner? I am aware of packages fancyhdr and xwatermark that might be used for this purpose. My question is: how to make "fancyhdr" produce different headers through different ranges of pages? I.e. pages 1 - 5 have "No 1" in right corner; pages 6 to 11 have "No 2" end so forth. Thank you for helping me with this!

2
  • I would highly recommend some reusale macros so you have a consistent output.
    – Johannes_B
    Commented Nov 11, 2017 at 5:59
  • It would be nice, but writing a macro is way beyond my modest knowledge of LaTeX. I am thinking of something like defining as many "page styles" as many "forms" I'll have and then using them one by one, or doing it manually (if no solution exists).
    – user136555
    Commented Nov 11, 2017 at 6:13

1 Answer 1

5

I would define some macros to produce a consistent layout along with a counter that steps with every new protocol.

usersxFancyhdr

\documentclass[a4paper,14pt]{extreport}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{lipsum}
\usepackage{framed, color}
\definecolor{shadecolor}{rgb}{0.64, 0.64, 0.82}


\newcounter{procurement}
\usepackage{scrlayer-scrpage}
\ohead{\textcolor{red}{Procurement  Protocol \textnumero~\theprocurement}\\\today}
\setlength{\headheight}{34.0pt}
\newcommand{\nextprotocol}{% automatic title on a new page
\clearpage
\refstepcounter{procurement}
\begin{center}
\textbf{\large     Protocols for Safe Procurement of Specimens \\
Procurement  Protocol \textnumero~\theprocurement}
\end{center}
}
\setlength{\parindent}{0pt}
\newcommand{\showEx}{%
\begin{shaded}
\centering\Large\bfseries Exemplary Specimen:
\end{shaded}
}



\begin{document}


\nextprotocol
\begin{tabular}{p{.47\linewidth}p{.47\linewidth}}
{Procurement \textnumero:} \dotfill &
{Procurement date:} \dotfill \\
{Shipment type:} \dotfill &
{Received by:} \dotfill \\
{Received on date:} \dotfill &
{Country of origin:} \dotfill \\
\end{tabular}

\showEx

\lipsum[1]


\nextprotocol
\begin{tabular}{p{.47\linewidth}p{.47\linewidth}}
{Procurement \textnumero:} \dotfill &
{Procurement date:} \dotfill \\
{Shipment type:} \dotfill &
{Received by:} \dotfill \\
{Received on date:} \dotfill &
{Country of origin:} \dotfill \\
\end{tabular}
\showEx
\lipsum[2]




\nextprotocol
\begin{tabular}{p{.47\linewidth}p{.47\linewidth}}
{Procurement \textnumero:} \dotfill &
{Procurement date:} \dotfill \\
{Shipment type:} \dotfill &
{Received by:} \dotfill \\
{Received on date:} \dotfill &
{Country of origin:} \dotfill \\
\end{tabular}
\showEx
\lipsum[2]
\end{document}

If the number is not numerical, but an arbitrary string, you can still use a simple text macro to fill in the header.

%Without a counter but an arbitrary string

usersxFancyhdrExtended

\documentclass[a4paper,14pt]{extreport}
\usepackage{fontspec}

\usepackage{polyglossia}
\setmainlanguage{english}
\usepackage{lipsum}
\usepackage{multicol}
\usepackage{framed, color}
\definecolor{shadecolor}{rgb}{0.64, 0.64, 0.82}


\usepackage{scrlayer-scrpage}
\newcommand{\thisprocurement}{}
\ohead{\textcolor{red}{Procurement  Protocol \textnumero~\thisprocurement}\\\today}
\setlength{\headheight}{34.0pt}
\newcommand{\nextprotocol}[1][Not defined. Attention]{% automatic title on a new page
\clearpage
\renewcommand{\thisprocurement}{#1}
\begin{center}
\textbf{\large     Protocols for Safe Procurement of Specimens \\
Procurement  Protocol \textnumero~\thisprocurement}
\end{center}
}
\setlength{\parindent}{0pt}
\newcommand{\showEx}{%
\begin{shaded}
\centering\Large\bfseries Exemplary Specimen:
\end{shaded}
}



\begin{document}


\nextprotocol[Wombat12]
\begin{tabular}{p{.47\linewidth}p{.47\linewidth}}
{Procurement \textnumero:} \dotfill &
{Procurement date:} \dotfill \\
{Shipment type:} \dotfill &
{Received by:} \dotfill \\
{Received on date:} \dotfill &
{Country of origin:} \dotfill \\
\end{tabular}

\showEx

\lipsum[1]


\nextprotocol[Capybara.42]
\begin{tabular}{p{.47\linewidth}p{.47\linewidth}}
{Procurement \textnumero:} \dotfill &
{Procurement date:} \dotfill \\
{Shipment type:} \dotfill &
{Received by:} \dotfill \\
{Received on date:} \dotfill &
{Country of origin:} \dotfill \\
\end{tabular}
\showEx
\lipsum[2]




\nextprotocol
\begin{tabular}{p{.47\linewidth}p{.47\linewidth}}
{Procurement \textnumero:} \dotfill &
{Procurement date:} \dotfill \\
{Shipment type:} \dotfill &
{Received by:} \dotfill \\
{Received on date:} \dotfill &
{Country of origin:} \dotfill \\
\end{tabular}
\showEx
\lipsum[2]
\end{document}
13
  • Thank you, Johannes! It is an interesting solution, it does work automatically! If I may ask: how do you think is a solution that does not involve custom counter possible? Instead, is it possible to use some cross-referencing? For example, to put something like \ohead{\textcolor{red}{Procurement Protocol \textnumero~\ref{#1}}\\\today} \setlength{\headheight}{34.0pt} for the page header and \begin{center} \textbf{\large Protocols for Safe Procurement of Specimens \\ Procurement Protocol \textnumero~001\label{#1}} \end{center} } for text body.
    – user136555
    Commented Nov 11, 2017 at 8:03
  • @user136555 In order to use label ref, you need a counter. My example is already set up for that. You can simply use them.
    – Johannes_B
    Commented Nov 11, 2017 at 8:04
  • Play around a bit, i'll be back in 6 hours.
    – Johannes_B
    Commented Nov 11, 2017 at 8:06
  • In other words, I should put something like ABC001\label{\theprocurement}. Am I getting it right?
    – user136555
    Commented Nov 11, 2017 at 8:07
  • Finally I managed to create something that does the job the way I want it, albeit, using this piece of code \makeatletter \newcommand{\setword}[2]{% \phantomsection #1\def\@currentlabel{\unexpanded{#1}}\label{#2}% } \makeatothe from other question.
    – user136555
    Commented Nov 11, 2017 at 20:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .