0

How could I print the current page (of the section) and the total pages of a section, in the footer? Suppose the footer of page 20 reads

page 3 of 6 in section 5 (20)

because page 20 is the third page of section 5, which consists of 6 pages. @JamesT This is the minimum example I could do

\usepackage[spanish, es-noshorthands]{babel}
\usepackage[pdftex]{graphicx}
\usepackage{lastpage}
\usepackage{kantlipsum} % get some text
\usepackage{fancyhdr}
\pagestyle{fancy}
\newcounter{dummy}
\newcommand{\secpages}{\pageref{first}}
\newcommand{\resetpagecounts}{%
    \refstepcounter{dummy}\label{first}% store page number
    \clearpage
    \let\secpages=\numpages
    \setcounter{page}{1}}
\cfoot{\thepage\ of *TotalOfSection* en Actividad \thesection \rule[1mm]{1cm}{1pt} *current page* (*Total pages*)}
\begin{document}
\section{Actividad}
\kant[1-5]

\resetpagecounts    
\section{Actividad}
\kant[1-10]
\resetpagecounts

\section{Actividad}
\kant[1-15]

\end{document}

JOM
  • 457
  • 1
    That depends on what packages you are using, which document class etc., could you edit a MWE into your question please? Just to show the document class and packages, are you using fancyhdr etc? – JamesT Feb 14 '23 at 19:03
  • Closely related: https://tex.stackexchange.com/questions/469575/reset-page-numbering-and-total-number-of-pages-per-section – John Kormylo Feb 15 '23 at 04:21
  • Yes, closely related @JohnKormylo, but I can't access to de actual and the total page counter (I think lastpage will do it). I'm afraid that every approach I see, is based on modifying the existing page numbering. Unfortunately there are things on \latex programming that I simply don't understand. – JOM Feb 16 '23 at 18:50
  • @JamesT \documentclass[a4paper,10pt]{article} , \usepackage{fancyhdr} and a bunch of other packages. the \thesection refuses to work in \lfoot, but worked in \cfoot. My work isis a collection of activities (every activity in an own \section) and information between semesters. – JOM Feb 16 '23 at 18:58
  • There is probably a way to assist you but without seeing some code then it is impossible. Could you please edit into your question a small amount of code that we can compile and test please, otherwise there is no way to answer this sorry. – JamesT Feb 16 '23 at 19:11
  • @JamesT, I tried , based on https://tex.stackexchange.com/questions/469575/reset-page-numbering-and-total-number-of-pages-per-section, but LastPage and the other counters not worked. – JOM Feb 21 '23 at 15:42
  • Easiest thing: check the pdf. No kidding, it works. – user574859 Feb 24 '23 at 20:26

1 Answers1

1

Finnally I combined two sources : [https://latex.org/forum/viewtopic.php?t=4623][1] and [https://latex.org/forum/viewtopic.php?t=33181][2] and

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{atenddvi}
\usepackage{lastpage}
\pagestyle{fancy}
\fancyhead{}
\fancyfoot[C]{\stepcounter{pageaux}pag. \thepageaux\ de \ref{\currentauxref} en sección \thesection  }
\rfoot{\thepage\ de \pageref{LastPage}}
\usepackage{kantlipsum}

\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

\let\stdsection\section \renewcommand\section{\resetpageaux\stdsection} \begin{document} \section{la primera}
\kant \section{la segunda}
\kant[1-14] \section{la tercera}
\kant[1-22] \end{document}´´

JOM
  • 457