[Tex/LaTex] Toptesi class and sequential page numbering

acronymsglossariespage-numberingroman numeralstable of contents

I'm working on a final dissertation and I've been using the toptesi class provided by our university. The problem is that I wanted to manually add the package. Now, whilst I managed to insert properly the acronyms list in the right spot (both in the document and the table of contents) by adding this code to the toptesi.sty file:

 \def\acronimi{%
 \iffrontmatter\else\frontmattertrue\fi
 \if@openright\cleardoublepage\else\clearpage\fi
 \printglossary[type=\acronymtype]
 \pagenumbering{roman}
 \global\@topnum\z@
 \@afterindentfalse
 \addcontentsline{toc}{chapter}{Acronyms}
       }  

after the default code:

\def\frontmatter{\clearpage\ps@plain\pagenumbering{roman}%
    \numeriromanitrue\frontmattertrue\@openrightfalse}
\def\mainmatter{\if@twoside\@openrighttrue\fi
    \clearpage\ps@headings\pagenumbering{arabic}%
    \numeriromanifalse\frontmatterfalse}
\AtBeginDocument{\frontmatter}
\figurespagefalse
\tablespagefalse
\def\sommario{%
 \iffrontmatter\else\frontmattertrue\fi
 \if@openright\cleardoublepage\else\clearpage\fi
 \global\@topnum\z@
 \@afterindentfalse
 \@schapter{\summaryname}%
 \addcontentsline{toc}{chapter}{\summaryname}%
        }
\def\ringraziamenti{%
 \iffrontmatter\else\frontmattertrue\fi
 \if@openright\cleardoublepage\else\clearpage\fi
 \global\@topnum\z@
 \@afterindentfalse
 \@schapter{\acknowledgename}%
 \addcontentsline{toc}{chapter}{\acknowledgename}%
        }

\renewcommand\chapter{%
  \iffrontmatter\mainmatter\fi
  \if@openright\cleardoublepage\else\clearpage\fi
  \thispagestyle{plain}%
  \global\@topnum\z@
  \@afterindentfalse
  \secdef\@chapter\@schapter}
\renewcommand\part{%
  \iffrontmatter\mainmatter\fi
  \if@openright\cleardoublepage\else\clearpage\fi
  \thispagestyle{empty}%
  \if@twocolumn\onecolumn\@tempswatrue\else\@tempswafalse\fi
  \null\vfil
  \secdef\@part\@spart}

\renewcommand\listoffigures{%
    \if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi
    \if@openright\cleardoublepage\else\clearpage\fi
    \global\@topnum\z@
    \@afterindentfalse
    \@schapter{\listfigurename}
    \@mkboth{\listfigurename}{\listfigurename}%
    \@starttoc{lof}%
    \clearpage
    \if@restonecol\twocolumn\fi
    }
\renewcommand\listoftables{%
    \if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi
    \if@openright\cleardoublepage\else\clearpage\fi
    \global\@topnum\z@
    \@afterindentfalse
    \@schapter{\listtablename}%
    \@mkboth{\listtablename}{\listtablename}%
    \@starttoc{lot}%
    \clearpage
    \if@restonecol\twocolumn\fi
    }  
\renewcommand\tableofcontents{%
 \if@twocolumn\@restonecoltrue\onecolumn\else\@restonecolfalse\fi
 \if@openright\cleardoublepage\else\clearpage\fi
 \global\@topnum\z@
 \@afterindentfalse
 \@schapter{\contentsname}%
 \@starttoc{toc}%
 \clearpage
 \if@restonecol\twocolumn\fi
    }
\def\indici{%
 \iffrontmatter\else\frontmattertrue\fi


     \iftablespage
                {\addvspace{10pt}
                \let\saveaddvspace=\addvspace
                \def\addvspace##1{}
                \listoftables
                \let\addvspace=\saveaddvspace}
                \addcontentsline{toc}{chapter}{List of Tables}%
        \fi
        \iffigurespage
                {\addvspace{10pt}
                \let\saveaddvspace=\addvspace
                \def\addvspace##1{}
                \listoffigures
                \let\addvspace=\saveaddvspace}
                \addcontentsline{toc}{chapter}{List of Figures}%
        \fi
        \tableofcontents
%          \addcontentsline{toc}{chapter}{Index}%
       }

it completely messes up the page numbering. Firstly, the acronyms page numbers are displayed as arabic instead of roman numbers (apart from the last page of the acronyms list which, surprisingly, exhibits a roman number). Secondly, the page numbering sequentiality is lost.

Edit: here is a file package with all the necessary files to simulate this error Click here to download a working example

Table of contents Passage from acknowledgements to acronyms Last acronym page with the return of the roman numbers

Best Answer

Don't modify a class file under any circumstances.

Just add the definition of \acronimi to your document; here's an example, obtained by reducing your document to a MWE. However you have to remove the \pagenumbering{roman} instruction that is the cause of your failure.

There are a few things more to adjust, because toptesi tries to do clever things when it finds a \chapter command, in particular switching to \mainmatter. So we set temporarily \chapter to swallow the * automatically provided by glossaries and to call the internal command \@schapter, that is what LaTeX calls when it sees \chapter*.

\documentclass[12pt,oneside,cucitura]{toptesi}

\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage[acronym]{glossaries}
% we want to teach the correct word for Italian
\addto\captionsitalian{\renewcommand{\acronymname}{Acronimi}}
\makeglossaries

\usepackage{hyperref}
\hypersetup{%
    pdfpagemode={UseOutlines},
    bookmarksopen,
    pdfstartview={FitH},
    colorlinks,
    linkcolor={blue},
    citecolor={red},
    urlcolor={blue}
  }

\makeatletter
\newcommand\acronimi{%
 \iffrontmatter\else\frontmattertrue\fi
 \if@openright\cleardoublepage\else\clearpage\fi
 % change the meaning of \chapter in a group
 \begingroup\def\chapter##1{\@schapter}
 \phantomsection % for the hyperlink
 \addcontentsline{toc}{chapter}{\acronymname} % for the TOC
 \printglossary[type=\acronymtype]
 % The following two lines seem unnecessary
 %\global\@topnum\z@
 %\@afterindentfalse 
 \endgroup
}  
\makeatother

% Define the acronyms
\newacronym{cctv}{CCTV}{closed-circuit television}
\newacronym{cdss}{CDSS}{clinical decision support systems}
\newacronym{chf}{CHF}{chronic heart failure}

\glsaddall

\begin{document}

\sommario

La pressione barometrica di Giove viene misurata
mediante un metodo originale  messo a punto dai candidati, che si basa
sul rilevamento telescopico della pressione.

\ringraziamenti

I candidati ringraziano vivamente il Granduca di Toscana per i mezzi
messi loro a disposizione, ed il signor Von Braun, assistente del
prof.~Albert Einstein, per le informazioni riservate che egli ha
gentilmente fornito loro, e per le utili discussioni che hanno permesso
ai candidati di evitare di riscoprire l'acqua calda.

\acronimi
\indici

\mainmatter

\part{Prima Parte}
\chapter{Introduzione generale}

Le grandezze in gioco ...

\end{document}

enter image description here