0

based on question two page numbering scheme for SOP - Standard Operating Procedure document, I got this MWE.

\documentclass{article}

\usepackage{atenddvi} % added <<<<<<<<<<<<<
\usepackage{lastpage}  % added <<<<<<<<<<<<<
\usepackage[user]{zref}% added <<<<<<<<<<<<<

\usepackage{titletoc}

\usepackage{kantlipsum}% ONLY dummy text

\usepackage{fancyhdr}
\fancypagestyle{firststyle}{% changed <<<<<<<<<<<<<<<<
    \fancyhf{} %clear header and footer
    \fancyfoot[R]{\stepcounter{pageaux}
            \fbox{%
            \begin{tabular}{r}
                Global Page: \thepage/\pageref{LastPage} \\
                SOP Page: \thepageaux/\ref{\currentauxref} \\
        \end{tabular}}
}}
\pagestyle{firststyle}

%%********************************* from  https://tex.stackexchange.com/a/82560/161015
\newcounter{pageaux}
\def\currentauxref{PAGEAUX1}
\makeatletter
\newcommand{\resetpageaux}{%
    \clearpage
    \edef\@currentlabel{\thepageaux}\label{\currentauxref}%
    \xdef\currentauxref{PAGEAUX\thepage}%
    \setcounter{pageaux}{0}}
\AtEndDvi{\edef\@currentlabel{\thepageaux}\label{\currentauxref}}
\makeatother
%%*********************************

\begin{document}
    
    \thispagestyle{empty}   
    \tableofcontents
    \newpage
    
    \addcontentsline{toc}{section}{SOP 1 - Administration}
        
    \resetpageaux% reset aux page numbers
    
    \startlist{toc}
    \printlist{toc}{}{\section*{Contents - SOP 1}}
    
    \section{OBJECTIVE}
    \kant[9]
    \section{RESPONSIBILITY}
    \kant[2]
    \section{PROCEDURES}
    \kant[9]
    \stopcontents
    
    \newpage
    
    \setcounter{section}{0}
    \addcontentsline{toc}{section}{SOP 2 - Production}
    
    \resetpageaux% reset aux page numbers
    
    \startlist{toc}
    \printlist{toc}{}{\section*{Contents - SOP 2}}
    
    \section{OBJECTIVE}
    \kant[1-8]
    \section{RESPONSIBILITY}
    \kant[1-8]
    \section{PROCEDURES}
    \kant[1-8]
    \stopcontents
    
\end{document}

Is there a way for the main TOC to show a global numbering and the TOC of each SOP a local numbering?

2
  • What do you mean by "global" and "local" numbering? Aug 1, 2022 at 17:34
  • global is the total number of pages in document, local is the total number pages from a single sop. Aug 1, 2022 at 22:43

1 Answer 1

1

This solution requires two steps. (does not use titletoc)

In the first step, the individual SOP files are compiled generating the individual ToC files to be used in the second step. For convenience, the content of each SOP is in a separate file as SOP<number>content.tex

Note that the first local page of each SOP is 1 as it should be for a local page number.

The second step creates the final document with all the SOPs content, generates the global TOC and uses the local ToC created in the first step.

All files must be in the same directory.

a

c

File SOP1.tex (one page)

%%% file SOP1.tex

\documentclass{article}

\usepackage{kantlipsum}% ONLY dummy text

\begin{document}
    \tableofcontents
     \input{\jobname contents}
\end{document

File SOP2.tex (nine pages)

%%% file SOP2.tex

\documentclass{article}

\usepackage{kantlipsum}% ONLY dummy text

\begin{document}
    \tableofcontents
     \input{\jobname contents}
\end{document}

File SOP1contents.tex

%%% file SOP1contents.tex

\addcontentsline{toc}{section}{SOP 1 - Administration}          
\section{OBJECTIVE}
\kant[9]
\section{RESPONSIBILITY}
\kant[2]
\section{PROCEDURES}
\kant[9]

File SOP2contents.tex

%%% file SOP2contents.tex

\addcontentsline{toc}{section}{SOP 2 - Production}  
\section{OBJECTIVE}
\kant[1-8]
\section{RESPONSIBILITY}
\kant[1-8]
\section{PROCEDURES}
\kant[1-8]

File main.tex in the same directory of SOP1.tex and SOP2.tex ! (eleven pages)

%%  File main.tex

\documentclass{article}

\usepackage{atenddvi} % added <<<<<<<<<<<<<
\usepackage{lastpage}  % added <<<<<<<<<<<<<
\usepackage[user]{zref}% added <<<<<<<<<<<<<
    
\usepackage{kantlipsum}% ONLY dummy text

\usepackage{fancyhdr}
\fancypagestyle{firststyle}{% changed <<<<<<<<<<<<<<<<
    \fancyhf{} %clear header and footer
    \fancyfoot[R]{\stepcounter{pageaux}
        \fbox{%
            \begin{tabular}{rr}
                Global Page:&\thepage/\pageref{LastPage} \\
                SOP Page:   & \thepageaux/\ref{\currentauxref} \\
        \end{tabular}}
}}
\pagestyle{firststyle}

%%********************************* from  https://tex.stackexchange.com/a/82560/161015
\newcounter{pageaux}
\def\currentauxref{PAGEAUX1}
\makeatletter
\newcommand{\resetpageaux}{%
    \clearpage
    \edef\@currentlabel{\thepageaux}\label{\currentauxref}%
    \xdef\currentauxref{PAGEAUX\thepage}%
    \setcounter{pageaux}{0}}
\AtEndDvi{\edef\@currentlabel{\thepageaux}\label{\currentauxref}}
\makeatother
%%*********************************

\begin{document}

    \thispagestyle{empty}   
    \tableofcontents
    \newpage    
    
    \resetpageaux% reset aux page numbers   
        
    \input{SOP1.toc} % input toc of SOP 1 <<<<<<<<<<<<<<<<<<<<<,,
    \input{SOP1contents}
            
    \newpage
    \setcounter{section}{0}     
    \resetpageaux% reset aux page numbers   
        
    \input{SOP2.toc}  % input toc of SOP 2 <<<<<<<<<<<<<<<<<<<<<<<<<        
    \input{SOP2contents}
        
\end{document}

You must log in to answer this question.

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