I'm currently writing my second thesis template for LyX 2.0.6 under MiKTeX 2.9, and since I'm using the article
document class I have to manually organize the page numbering inside the ToC, LoF, LoT et similia.
Thanks to fancyhdr
I had no problems for the specific page number typesetting on the document body, which will be shown in the MWE; but when I began to organize my ToC formatting I encountered an issue that required this kind of help.
My goal is to obtain the Roman numbering for the pseudo-frontmatter
inside the ToC without selecting pagenumbering{Roman}
, because I want to use the Small Caps font selection.
The MWE is as follows:
\documentclass[11pt,twoside,british,italian]{article}
%
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{babel}
\usepackage{lipsum}
%
\makeatletter
%
% define the page style, note \pagestyle{fancy} already in the preamble
\renewcommand{\sectionmark}[1]{\markboth{Sezione\ \thesection.\ #1}{}}
\renewcommand{\subsectionmark}[1]{\markright{#1}}
\fancyhf{}
\fancyhead[RE]{\nouppercase{\slshape \leftmark}}
\fancyhead[LO]{\nouppercase{\slshape \lastrightmark}}
\fancyhead[LE,RO]{\itshape \thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
% create new \fancypagestyles in respect to short sections
\usepackage{slantsc}
\usepackage{extramarks}
%
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[CE,CO]{\slshape{\scshape \thepage}} % Page numbers with my defined style
\renewcommand{\headrulewidth}{0pt}%
}
\fancypagestyle{nonTOCplain}{%
\fancyhf{}
\fancyhead[LE,RO]{\itshape \thepage}
\renewcommand{\headrulewidth}{0pt}%
}
\fancypagestyle{TOCplain}{%
\fancyhf{}
\fancyhead[RE]{\nouppercase{\slshape \leftmark}}
\fancyhead[LO]{\nouppercase{\slshape \lastrightmark}}
\fancyhead[LE,RO]{\slshape{\scshape \thepage}} % Page numbers with my defined style
\renewcommand{\headrulewidth}{0.4pt}%
}
%
% the pages of the ToC/LoF/LoT are numbered Lowercase Roman
\let\myTOC\tableofcontents
\renewcommand\tableofcontents{%
\pagenumbering{roman} % I don't want "Roman" because there are too big letters!
\thispagestyle{plain}
\myTOC%
}
%
\makeatother
%
\begin{document}
%
\thispagestyle{plain}
\addcontentsline{toc}{section}{Indice Generale}
\tableofcontents{}
\clearpage{}
%
\thispagestyle{TOCplain}
\cleardoublepage{}
%
\thispagestyle{TOCplain}
\addcontentsline{toc}{section}{Elenco delle Figure}
\listoffigures
\clearpage{}
%
\thispagestyle{TOCplain}
\cleardoublepage{}
\pagenumbering{arabic}
%
\thispagestyle{nonTOCplain}
\section{Introduzione}
\lipsum[1]
%
\cleardoublepage{}
%
\thispagestyle{nonTOCplain}
\section{Prima sezione }
\lipsum[3]
\subsection{Prima sottosezione }
\lipsum[3]
%
\end{document}
As it is complied, the frontmatter pages have slanted small caps roman numerals:
but inside the ToC they appear only lowercase upright roman:
My question so remains on how to obtain the document body number style inside the ToC, maybe using this imaginary command:
\newcommand*\ToCpagefont{\bfseries\scshape} % roman-smallcaps-bold page number
Although I tried tocloft
with the useful command:
\usepackage{tocloft}
\renewcommand*{\cftsecpagefont}{\uppercase\bfseries}
it gives me only undefined control sequences, and I think it is more reliable if every element inside the ToC formatting was adapted to this package; since I don't use it I'd like to know if there is some sort of solution to this starts-to-wear-me-off issue.
EDIT: Here is the MWE with addition of Hyperref
:
\documentclass[11pt,twoside,british,italian]{article}
%
\usepackage[T1]{fontenc}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{babel}
\usepackage{lipsum}
%
\usepackage[unicode=true,
bookmarks=true,bookmarksnumbered=true,bookmarksopen=false,
breaklinks=false,pdfborder={0 0 1},backref=false,colorlinks=true]
{hyperref}
%
\makeatletter
%
% define the page style, note \pagestyle{fancy} already in the preamble
\renewcommand{\sectionmark}[1]{\markboth{Sezione\ \thesection.\ #1}{}}
\renewcommand{\subsectionmark}[1]{\markright{#1}}
\fancyhf{}
\fancyhead[RE]{\nouppercase{\slshape \leftmark}}
\fancyhead[LO]{\nouppercase{\slshape \lastrightmark}}
\fancyhead[LE,RO]{\itshape \thepage}
\renewcommand{\headrulewidth}{0.4pt}
\renewcommand{\footrulewidth}{0pt}
% create new \fancypagestyles in respect to short sections
\usepackage{slantsc}
\usepackage{extramarks}
%
\fancypagestyle{plain}{%
\fancyhf{}
\fancyfoot[CE,CO]{\slshape{\scshape \thepage}} % Page numbers with my defined style
\renewcommand{\headrulewidth}{0pt}%
}
\fancypagestyle{nonTOCplain}{%
\fancyhf{}
\fancyhead[LE,RO]{\itshape \thepage}
\renewcommand{\headrulewidth}{0pt}%
}
\fancypagestyle{TOCplain}{%
\fancyhf{}
\fancyhead[RE]{\nouppercase{\slshape \leftmark}}
\fancyhead[LO]{\nouppercase{\slshape \lastrightmark}}
\fancyhead[LE,RO]{\slshape{\scshape \thepage}} % Page numbers with my defined style
\renewcommand{\headrulewidth}{0.4pt}%
}
%
% the pages of the ToC/LoF/LoT are numbered Lowercase Roman
\let\myTOC\tableofcontents
\renewcommand\tableofcontents{%
\pagenumbering{roman} % I don't want "Roman" because there are too big letters!
\thispagestyle{plain}
\myTOC%
}
%
\makeatother
%
\begin{document}
%
\thispagestyle{plain}
\addcontentsline{toc}{section}{Indice Generale}
\tableofcontents{}
\clearpage{}
%
\thispagestyle{TOCplain}
\cleardoublepage{}
%
\thispagestyle{TOCplain}
\addcontentsline{toc}{section}{Elenco delle Figure}
\listoffigures
\clearpage{}
%
\thispagestyle{TOCplain}
\cleardoublepage{}
\pagenumbering{arabic}
%
\thispagestyle{nonTOCplain}
\section{Introduzione}
\lipsum[1]
%
\cleardoublepage{}
%
\thispagestyle{nonTOCplain}
\section{Prima sezione }
\lipsum[3]
\subsection{Prima sottosezione }
\lipsum[3]
%
\end{document}
Best Answer
One way would be to replace your
\addcontentsline
by\addtocontents
more detailed macros. (in code comments: the more complicated case with package hyperref loaded)