And how to make them show as roman numerals in TOC?
[Tex/LaTex] How to make \section items numbers show as Roman Numerals like I II III IV..
numberingsectioningtable of contents
Related Solutions
Patching \@makechapterhead
to print \Roman{chapter}
instead of \thechapter
allows you to have chapter headings formatting with Roman numerals yet have references inside your text to still be Arabic:
\documentclass{book}
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\makeatletter
\patchcmd{\@makechapterhead}% <cmd>
{\thechapter}% <search>
{\Roman{chapter}}% <replace>
{}{}% <success><failure>
\makeatother
\begin{document}
%\tableofcontents
\chapter{A chapter}\label{chap-label}
See Chapter~\ref{chap-label}.
\end{document}
Note that numbering inside your ToC will also be Arabic. To change this, a patch to \@chapter
is required (also wrapped inside a \makeatletter
-\makeatother
-pair):
\patchcmd{\@chapter}% <cmd>
{\numberline{\thechapter}}% <search>
{\numberline{\Roman{chapter}}}% <replace>
{}{}% <success><failure>
One way would be to replace your \addcontentsline
by \addtocontents
more detailed macros. (in code comments: the more complicated case with package hyperref loaded)
\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}
% %
% % see commented out lines below for this case with 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}
\addtocontents{toc}{\protect\contentsline{section}{Indice
Generale}{{\bfseries\scshape\thepage}}}
% in case hyperref is loaded use rather:
% \makeatletter
% \addtocontents{toc}{\protect\contentsline{section}{Indice
% Generale}{{\bfseries\scshape\thepage}}{\@currentHref }}
% \makeatother
\tableofcontents{}
\clearpage{}
%
\thispagestyle{TOCplain}
\cleardoublepage{}
%
\thispagestyle{TOCplain}
%\addcontentsline{toc}{section}{Elenco delle Figure}
\addtocontents{toc}{\protect\contentsline{section}{Elenco delle
Figure}{{\bfseries\scshape\thepage}}}
% if hyperref:
% \makeatletter
% \addtocontents{toc}{\protect\contentsline{section}{Elenco delle
% Figure}{{\bfseries\scshape\thepage}}{\@currentHref }}
% \makeatother
\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
Change the representation of the corresponding counter (
section
, in this case) by adding to the preamble:EDIT: this redefinition will probably require increasing the space allowed for typesetting section numbers in the ToC; this can be done, for example, with the help of the tocloft package by adding the following lines to the preamble: