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}
7
  • 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 at 19:03
  • Closely related: tex.stackexchange.com/questions/469575/… Feb 15 at 4: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 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 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 at 19:11

1 Answer 1

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

You must log in to answer this question.

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