I'm going mad with this issue. I have a book divided in parts, I currently have the following TOC:
but I would like to hide the page number on the right and have the part
title centered. The LaTeX code is:
\renewcommand*\part[1]{
\vspace*{160pt}
\addtocounter{part}{1}
\setcounter{chapter}{0}
{\centering\sffamily
\Large \textsc{Parte} \Roman{part}
\par\nobreak
\vskip 14pt
\huge \uppercase{#1} \par\nobreak
}
\addcontentsline{toc}{part}{\centering {Parte \thepart} \\ \numberline{} \centering{#1}
}
\vskip 40pt
}
Where is the mistake please?
I'm used to writing code in languages like C, Php, Javascript and there the arguments to pass to a function are clearly visible. Whereas here I have a function \part
with one argument, the title #1
, while \thepart
is something like a global variable. Where is the page number though? I expected something like \thecontentspage
, here there is nothing of the like and still the page number appears, not required, at the end of the line. Where is the instruction to write the number to the right?
This is confusing to me. I understand LaTeX follows a paradigm, a logic quite different from other programming languages, but I haven't yet understood this logic.
How can I remove that number on the right and have the title centered?
of course it is a book so ... \documentclass[12pt]{book}
Reply
I'm not sure to understand MWE, I see there is a debate about this requirement. I guess a complete .tex file producing a minimal PDF, something I did for other problems.
But to be complete I have to add everything before the \begin{document}, 159 lines plus a minimal example, at least two parts and some dummy chapters and sections. More than 200 lines ...
The problem is still there.
Hope someone has the time to have a look to the code below.
\documentclass[12pt]{book}
\usepackage[italian,english,german]{babel}
\usepackage{fontspec}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{xcolor}
\usepackage[linktoc=all]{hyperref}
\usepackage{titletoc}
\usepackage[odd]{emptypage}
\usepackage{lmodern}
\usepackage{ulem}
\usepackage{enumitem}
\usepackage{longtable}
\usepackage{caption}
\usepackage{multirow}
\usepackage{amssymb}
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{verbatim}
\usepackage{ragged2e}
\usepackage{makeidx}
\usepackage{fancyhdr}
\pagestyle{fancy}
\usepackage{mystyle_17x24}
\title{La crittografia della Repubblica di Venezia}
\author{Paolo Bonavoglia \\
{\tt [email protected]}
}
\date{\today}
\newcommand*{\tabbox}[2][t]{%
\vspace{0pt}\parbox[#1][3.7\baselineskip]{1cm}{\strut#2\strut}}
\renewcommand\labelitemi{---}
\newcommand*\FancyNulla{%
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
}
\newcommand*\cleartorightpage{%
\cleardoublepage
\FancyNulla
}
\newcommand*\FancyParte[1]{%
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
\fancyhead[LE]{\thepage #1}
\fancyhead[CE]{Parte \thepart}
\fancyhead[RE]{}
\fancyfoot[LO]{}
\fancyfoot[CO]{}
\fancyfoot[RO]{\thepage}
}
\newcommand*\FancyIndice[1]{%
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
\fancyhead[LE]{\thepage}
\fancyhead[CE]{#1}
\fancyhead[RE]{}
\fancyhead[LO]{}
\fancyhead[CO]{#1}
\fancyhead[RO]{\thepage}
}
\newcommand*\FancyParteSenzaNumeri[1]{%
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
\fancyhead[LE]{}
\fancyhead[CE]{#1}
\fancyhead[RE]{}
\fancyhead[LO]{}
\fancyhead[CO]{}
\fancyhead[RO]{}
}
\newcommand*\FancyCapitolo[1]{%
\fancyfoot{} % clear all footer fields
\fancyhead[LE]{\thepage}
\fancyhead[CE]{Parte \thepart}
\fancyhead[RE]{}
\fancyhead[LO]{}
\fancyhead[CO]{Cap. \! \thechapter \; #1}
\fancyhead[RO]{\thepage}
}
\newcommand*\Figura[4]{%
\begin{figure}[ht]\begin{center}\includegraphics[#1]{#2} \caption{\small \textit{#3}}
\label{#4}
\end{center}\end{figure}
}
\setcounter{table}{0}
\renewcommand*\part[1]{
\vspace*{160pt}
\addtocounter{part}{1}
\setcounter{chapter}{0}
{\centering\sffamily
\Large \textsc{Parte} \Roman{part}
\par\nobreak
\vskip 14pt
\uppercase{#1} \par\nobreak
}
\addcontentsline{toc}{part}{\centering {Parte \thepart} \\ \numberline{} \centering{#1} }
\vskip 40pt
}
\titlecontents{chapter}[0pt \addvspace{2em} \hspace*{-2.3em}]
{\thecontentspage \quad Capitolo \thecontentslabel{} \\}%
{\hspace{-4pt} }
{}
{}
{}
\titlecontents*{section}[0pt\small]
{\upshape\-}
{\thecontentslabel {\;}}
{}
{, {\thecontentspage}}
[][\ \textendash\ ][]
\titlecontents*{subsection}[0pt\small]
{\itshape\-}
{\; \thecontentslabel {\;}}
{}
{, {\upshape\thecontentspage}}
[][\ \textendash\ ][]
% You can include more LaTeX packages here
\setlength{\abovecaptionskip}{3pt plus 2pt minus 1pt}
\setlength{\belowcaptionskip}{4pt plus 2pt minus 1pt}
\counterwithout{footnote}{chapter}
\counterwithout{figure}{chapter}
\counterwithout{table}{chapter}
\makeindex
\begin{document}
\fancyhead{} % clear all header fields
\fancyfoot{} % clear all footer fields
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\pagenumbering{roman}
\selectlanguage{italian} %%% remove comment delimiter ('%') and select language if required
\tableofcontents
\pseudochapter{Prefazione}
\cleardoublepage
\setcounter{part}{0}%restore counter
\pagenumbering{arabic}
\part{Le cifre della Repubblica di Venezia}
\clearpage
\FancyParte{Le cifre della Repubblica di Venezia}
\FancyCapitolo{Organizzazione}
\clearpage
\section{La necessità di scrivere in cifra}
\clearpage
xxxx
\clearpage
\section{Dummy}
\section{Useless}
\part{Dummy part}
\section{La necessità di scrivere in cifra}
\clearpage
xxxx
\clearpage
\section{Dummy}
\section{Useless}
\end{document}
book
,memoir
or another similar class. Could you make a Minimal Working Example (MWE) please?ToC layout
used at the turn at the nineteenth century in books written by some British scientists back then. They divided their books into parts and chapters with the sections with pages (or sometimes not even that) in paragraph style. Is that what you want to achieve? An example of what I mean can be found here.\renewcommand*\part[1]{
be\renewcommand*{\part}[1][]{
? That is enclosing the to be redefined\part
in curly brackets and adding an extra[ ]
to the command.