I try to compile several .tex in a main document, so i use the package subfiles.
I want to display for each inputed file the page number of the current page relatively to the inputed file, and also to display the total pages of this inputed file on each its page ; and this for all the inputed files.
I'm near to sucess but ...
I use a local counter for the number of page, and several counters for the total page amount of each inputed file (using the package totcount).
I have simplified the code, so here I have one main file "main-file.tex", and 3 folders "Ch1", "Ch2", and "Ch3", the first containing the file "Ch1-2nde.tex", the second containing the file "Ch2-2nde.tex", and the last the file "Ch3-2nde.tex". Here is the code I use for main-file.tex :
\documentclass[s,onecolumn]{article}
\RequirePackage[a4paper, top=0.5cm, bottom=1.6cm, left=0.7cm , right=0.7cm]{geometry}
\usepackage{graphicx}
\usepackage{lastpage}
\RequirePackage{multido}
\usepackage{subfiles}
\RequirePackage{totcount}
\RequirePackage{fancyhdr}
\renewcommand\headrulewidth{1pt}
\renewcommand\footrulewidth{1pt}
\pagestyle{fancy}
\makeatletter
\let\org@subfile\subfile
\renewcommand*{\subfile}[1]{%
\filename@parse{#1}% LaTeX's file name parser
\expandafter
\graphicspath\expandafter{\expandafter{\filename@area}}%
\org@subfile{#1}%
\newpage %ajout ici pour sauter automatiquement une page entre
}
\makeatother
\newcounter{localPage}
\newcounter{AuxCounter}
\renewcommand{\theAuxCounter}{\roman{AuxCounter}}
%to create counter "compteurChi" "compteurChii" ..., and \roman because no
%number is supported as a counter name.
\newcommand{\entetecours}[1]
{
\setcounter{localPage}{0}
\begin{center}
{\textbf{\huge Chapitre #1}}
\end{center}
\fancyfoot[C]{\textbf{Page \thepage / \pageref{LastPage} }}
\setcounter{AuxCounter}{#1}
\fancyfoot[L]{Chap#1
{\addtocounter{compteurCh\theAuxCounter}{1}
\addtocounter{localPage}{1}
\fbox{\bfseries \thelocalPage} / \total{compteurCh\theAuxCounter}}
}
}
\begin{document}
\multido{\i=1+1}{3}{%
\setcounter{AuxCounter}{\i}
\newcounter{compteurCh\theAuxCounter}
\regtotcounter{compteurCh\theAuxCounter}
}
\multido{\i=1+1}{3}{\subfile{Ch\i/Ch\i-2nde}}
\end{document}
Here the code in Ch1-2nde.tex :
\entetecours{1}
Ch1 first page
\newpage
Ch1 second page
\newpage
Ch1 third page
The code in Ch2-2nde.tex :
\entetecours{2}
Ch2 first page
\newpage
Ch2 second page
\newpage
Ch2 third page
The code in Ch3-2nde.tex :
\entetecours{3}
Ch3 first page
\newpage
Ch3 second page
\newpage
Ch3 third page
So, The problem is even if I compile two times, there is still "??" left at the bottom left side for the two first inputed files (the counter value of compteurChi and compteurChii are not present in the .aux file ... And I don't know why).
Please, some help ^^.
compteurChcounters are defined after\begin{document}, this screws the totcount system up – May 15 '15 at 01:38\multido{\i=1+1}{3}{% \setcounter{AuxCounter}{\i} \newcounter{compteurCh\theAuxCounter} \regtotcounter{compteurCh\theAuxCounter} }before the\begin{document}nothing change, it stays as before. – math45 May 15 '15 at 02:02\newcountershould be used in the preamble only – May 15 '15 at 02:08\setcounter{AuxCounter}{1} \newcounter{compteurChi} \regtotcounter{compteurChi} \newcounter{compteurChii} \regtotcounter{compteurChii} \newcounter{compteurChiii} \regtotcounter{compteurChiii}in the preamble, it worked. So the problem comes from the loop .... Do you know how to solve this ? Thanks – math45 May 15 '15 at 02:21\newcountertoo) are always tricky, due to grouping effects – May 15 '15 at 08:16