Home > sectioning > Book layout Contents, Chapter, Section,

# Book layout Contents, Chapter, Section,

August 10Hits:1

my goal is to get new style of Table of Contents, new style of Chapter and new style of section. I there is one more: how to change itemize native symbol for a black square?

Table of Contents: text on the left side in the middle of two lines. And there is a big white space non normal one.

Chapter: number of chapter in a roman in a black box on the line above the chapter name, Name of chapter on right side, another line under name of Chapter

Section: I want to add a black square at the begining of each section name.
I appreciate that thank You

You can use the packages titlesec for the titles of the sectional units, and titletoc for the entries in the ToC; a little example producing the layout for chapters and sections, and the redefinition of the label for itemize to use a square (feel free to adjust the settings according to your needs):

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

% chapter tiltes formatting
\titleformat{\chapter}[display]
{\normalfont\sffamily\bfseries\LARGE}
{\renewcommand{\thechapter}{\Roman{chapter}}\hspace*{0.5em}\colorbox{black}{%
\parbox[c][1.2cm][c]{1cm}{%
\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}
\titleformat{name=\section,numberless}
{\normalfont\Large\bfseries}{\MySecSquare}{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 One}
\section{Test Section One One}
\begin{itemize}
\item First item.
\item Second item.
\item Third item.
\end{itemize}
\section{Test Section One Two}
\chapter{Test Chapter Two}
\chapter{Test Chapter Three}

\end{document}



An image of the ToC showing the requested formatting for the entries, and an image of the first numbered chapter, showing the desired chapter titles formatting, the use of a black square in itemize and the section titles formatting:

There's a little detail that deserves some thought: the black box used to typeset the chapter number; in the code above I used a \parbox of fixed width (I chose 1cm) and this will be insufficient for "large" roman numerals (such as VIII), One option is to increase the width of the \parbox, but then small numerals (such as I) might not look good inside a too wide box. Another option is to have a default width of, say 1cm, and let the widht of the \parbox increase just for those numbers requiring more spacing; here's now the code implementing this idea:

\documentclass{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 One}
\setcounter{chapter}{17}% just for the example
\chapter{Test Chapter Eighteen}

\end{document}



An image of the titles for chapters I and XVIII:

## Related Articles

• ### Book layout Contents, Chapter, Section,August 10

my goal is to get new style of Table of Contents, new style of Chapter and new style of section. I there is one more: how to change itemize native symbol for a black square? Table of Contents: text on the left side in the middle of two lines. And the

• ### Table of contents, chapter titles, section titles, etc.. are centered and chapter titles start in the middle of the page January 21

I am beginning my Thesis and this is only the second time I've used TEX. I'm not sure how to get my Table of Contents, Chapter Titles, Sections and Subsections to appear on the left indent. In addition, the table of contents and chapters all begin ne

I'm using book style, but it happens with a report style, too. I'm using the \chapter* command and I want that the chapter section appears in the table of contents, but it doesn't appear. This is the code: \documentclass[14pt,a4paper,twoside,spanish,

• ### Change Colour on Chapter/Section headings {Lyx}October 7

I am using Lyx and Layout report for my thesis. I would like to change the colour of chapters sections and subsections (only the headings) from black to blue. I attach a screenshot in order to understand what colours i am trying to achieve only on he

• ### Converting to mixture of HTML (chapter/section headers) and PDF (individual chapters/sections)December 19

I have a large collection of notes that currently consists of a large number of individual "chapters" that I manually number and keep track of. E.g. visit http://www.stat.sfu.ca/~cschwarz/CourseNotes with a manually created and maintained HTML i

• ### Numbering new environment with chapter/sectionMay 16

If I have a new environment defined (with, say, trivfloat), is it possible to get that section to number with chapter/section? I use \numberwithin for equations, figures, and tables. For example, my equations and figures are numbered 1.1, 1.2, 1.3, 2

• ### Listing Chapter/Section/Subsection numbers with the previewJune 11

After compiling all the content of the book, I use Adobe reader to preview the content. Note that the legend that I use to navigate through the book (the listing on the left (usually) with the option '+' on which one clicks, and it offers the content

I am using the tocloft package to design my table of contents. I know how to set the width of the chapter numbers in the toc using \setlength{\cftchapnumwidth}{2em} However this sets a fixed width of 2em for all chapter numbers. Some chapter numbers

• ### How to split with chapter, section, - Titles in the index part?October 2

Maybe the title isn't clear. In fact, I'm taking note during my course, and sometimes, teachers said that a thing is a pipe (tip, stuff to know) for the examination. Since the tex have a few of them, and more then 1000 lines when finished, I'm using

• ### Content summaries - sectionsMarch 22

I'm currently writing up my thesis and I have a section "content summary" in my introduction section. This gives an indication to what each section contains and is about. At the minute, each chapter / section is in text files, "introduction

• ### Create summary section from marked text at the end of chapter/section?April 3

I am trying to automatically create a summary section/subsection at the end of a chapter/section, by marking text within the main text as part of the summary. Is there a package that does that? I am trying to do this manually. The text in the summary

• ### Frame/Box around \chapter-, \section-headings,May 19

Does anyone know how to put a frame around \chapter and \section-headings? I'm using Koma-Script (scrbook) but there it's rather difficult to find a solution ... Now I found the package 'titlesec'. I think it must be possible to solve my problem with

How to get the table of contents chapter wise (beginning of each chapter with sections and subsections with page numbers) and the main table of contents containing only chapter title with page range not sections and subsections tiles. --------------S

• ### Same style (eg., Bt Charter, no bold style) between chapter/section/etc and ToC/LoF/LoTJuly 21

I recently noticed the difference between the chapter/section/subsection font style and those in ToC, and also the style in LoF and LoT, it seems that bold style is dominant in the latter. What is the right syntax to change the style of the latter ac

• ### How to center chapter, section and subsection using memoir?November 29


• ### Automatically insert "in the next [chapter/section/subsection]" if reference is sequentialJune 9

I'm aware of the cleveref package \cref which adds the correct reference name (see: Automatically inserting "Section", "Subsection", etc). I have a few references which refer to the very next section and some find it odd to give the nu

• ### Redefining \chapter*, \section* and \subsection*June 19

My problem is this one: I'm creating a LaTeX template for reports, my goal is to make a .tex file that is the simplest possible. I use a .cls file, where I'd like to redefine \chapter* (and so on), but not \chapter. I didn't find a way to do this pre

• ### how to give chapter, section and subsection headings identical flushleft indentation in a TOCSeptember 21

How do I change the indentations of \section \subsection in the Table of Contents so that they line up flush left at the same indentation of the chapter heading? I am using book class format. My code looks like this \renewcommand*{\contentsname}{\nor

• ### Indent for second line of chapter/section titleOctober 5

I have got a simple problem concerning multi-line chapter/section titles, that I could not fix. This is how it is: and this is how I want it to be: (I want the second line of the title to line up with the first one) I have read somehow relevant answe

• ### How to center glossary title without messing up chapter/sections?October 19

My problem is that the glossary title should be normal size, bold, all caps and centered. While Chapter, section and subsection must be all left aligned. So I cannot change section style to suit glossary because it will break the sections original st