# ToC width, small \MakeUppercase font in a header, dots next to chapters

1. How to get ToC widther? 1a. How to get ToC higher? [more space under the chapter, before a next chapter]

2. How to add dots next to the chapters?

3. How to put on odd sides name of current chapter but without a chapter -- just number of the chapter and name of it on the right side [on left -- page number], and on the even side title of a book [on right -- page number]. Both with \MakeUppercase but with a smaller font.

 \documentclass[openany, 10pt]{book}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage[dotinlabels]{titletoc}

\newlength\BoxWd
\setlength\BoxWd{1cm}
\newlength\Aux

% chapter tiltes formatting
\titleformat{\chapter}[display]
{\normalfont\sffamily\bfseries\LARGE}
{\renewcommand{\thechapter}{\Roman{chapter}}%
\settowidth\Aux{\textcolor{white}{\Huge\thechapter}}
\ifnum\Aux>\BoxWd
\setlength\BoxWd{\Aux}
\else\fi
\hspace*{0.5em}\colorbox{black}{%
\parbox[c][1.2cm][c]{\BoxWd}{%
\centering\textcolor{white}{\Huge\thechapter}}}}
{-1ex}
{\titlerule\vspace{.7ex}\filleft\MakeUppercase{#1}}
[\vspace{.2ex}\titlerule]
% chapter tiltes spacing
\titlespacing*{\chapter}{0pt}{50pt}{80pt}

% section tiltes formatting
\titleformat{\section}
{\normalfont\Large\bfseries}{\MySecSquare\ \thesection}{1em}{#1}

% formatting for chapter entries in ToC
\titlecontents{chapter}
[1.5em]{}
{\sffamily\bfseries\contentslabel{1.5em}}
{\hspace*{-1.5em}}
{\hfill\sffamily\bfseries\contentspage}
% formatting for section entries in ToC
\titlecontents{section}
[3.8em]{}
{\sffamily\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\titlerule*[1pc]{.}\sffamily\contentspage}

% Square to be used in itemize
\newcommand\MySquare{%
\leavevmode\hbox to 1.2ex{\hss\vrule height .9ex width .7ex depth -.2ex\hss}}
% Square to be used in section titles
\newcommand\MySecSquare{%
\leavevmode\hbox to 1.2ex{\hss\vrule height 1.3ex width 1.1ex depth -.2ex\hss}}

% First level of itemize uses a square
\renewcommand\labelitemi{\MySquare}

\begin{document}

\tableofcontents

\chapter{Test Chapter 1}
\section{Test Section 1}
\section{Test Section 2}
\section*{Test Section 3}
\chapter{Test Chapter 2}
\chapter{Test Chapter 3}
\chapter{Test Chapter 4}
\chapter{Test Chapter 5}
\chapter{Test Chapter 6}
\chapter{Test Chapter 7}
\chapter{Test Chapter 8}
\chapter{Test Chapter 9}

\end{document}


This is a follow-up question: Book layout Contents, Chapter, Section,

-
REegarding your first requirement, do you want to change the text width only for the ToC or for all of the document? – Gonzalo Medina Aug 12 '12 at 2:57
Why did you open a bounty? – Marco Daniel Aug 26 '12 at 11:36
"One or more of the answers is exemplary and worthy of an additional bounty" – Daniel Miliński Aug 26 '12 at 13:34

Here's one possible solution; I used the titleps package to define a new page style with the required settings (please make sure to have an updated LaTeX system and that titleps is installed). The modification to add dots for chapter entries in the ToC was accomplished using \titlerule* (from the titletoc package).

\documentclass{book}
\usepackage{xcolor}
\usepackage[explicit]{titlesec}
\usepackage[dotinlabels]{titletoc}
\usepackage{titleps}
\usepackage{lipsum}

\newlength\BoxWd
\setlength\BoxWd{1cm}
\newlength\Aux

% chapter tiltes formatting
\titleformat{\chapter}[display]
{\normalfont\sffamily\bfseries\LARGE}
{\renewcommand{\thechapter}{\Roman{chapter}}%
\settowidth\Aux{\textcolor{white}{\Huge\thechapter}}
\ifnum\Aux>\BoxWd
\setlength\BoxWd{\Aux}
\else\fi
\hspace*{0.5em}\colorbox{black}{%
\parbox[c][1.2cm][c]{\BoxWd}{%
\centering\textcolor{white}{\Huge\thechapter}}}}
{-1ex}
{\titlerule\vspace{.7ex}\filleft\MakeUppercase{#1}}
[\vspace{.2ex}\titlerule]
% chapter tiltes spacing
\titlespacing*{\chapter}{0pt}{50pt}{80pt}

% section tiltes formatting
\titleformat{\section}
{\normalfont\Large\bfseries}{\MySecSquare\ \thesection}{1em}{#1}

% formatting for chapter entries in ToC
\titlecontents{chapter}
[1.5em]{}
{\sffamily\bfseries\contentslabel{1.5em}}
{\hspace*{-1.5em}}
{\titlerule*[1pc]{.}\sffamily\bfseries\contentspage}
% formatting for section entries in ToC
\titlecontents{section}
[3.8em]{}
{\sffamily\contentslabel{2.3em}}
{\hspace*{-2.3em}}
{\titlerule*[1pc]{.}\sffamily\contentspage}

% Square to be used in itemize
\newcommand\MySquare{%
\leavevmode\hbox to 1.2ex{\hss\vrule height .9ex width .7ex depth -.2ex\hss}}
% Square to be used in section titles
\newcommand\MySecSquare{%
\leavevmode\hbox to 1.2ex{\hss\vrule height 1.3ex width 1.1ex depth -.2ex\hss}}

% First level of itemize uses a square
\renewcommand\labelitemi{\MySquare}

% Command to store the book title
\newcommand\MyTitle{The Title of The Book}

% definition of new page style
\newpagestyle{mystyle}[\footnotesize]{
{\thepage}{}{\thechapter\ \MakeUppercase{\chaptertitle}}}
\pagestyle{mystyle}

\begin{document}

\tableofcontents

\chapter{Test Chapter One}
\section{Test Section One One}
\lipsum[1-20]
\chapter{Test Chapter Two}

\end{document}


Some images illustrating the requested modifications:

The ToC:

The top part of some pages showing the headers:

In case the titleps package is not availabel, the desired page style can also be produced using the fancyhdr package; using this package, you need to replace the lines

\usepackage{titleps}

% definition of new page style
\newpagestyle{mystyle}[\footnotesize]{
{\thepage}{}{\thechapter\ \MakeUppercase{\chaptertitle}}}
\pagestyle{mystyle}


with

\usepackage{fancyhdr}

% definition of new page style
\fancyhf{}

@DanielMiliński OK; I've updated my answer with another solution for the page style using fancyhdr instead of titleps. You still haven't answered my question regarding the width: do you want to increase the text width just for the ToC or for the entire document? – Gonzalo Medina Aug 12 '12 at 17:31