Page LayoutCustomize ToC (class article, package titletoc)

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
zyv
Posts: 8
Joined: Mon May 25, 2009 7:43 pm

Customize ToC (class article, package titletoc)

Post by zyv »

Hello!

I am not sure whether this is the right place to ask, but as far as I understand, this is actually a page layout issue. Let me explain you what I need. I am actually writing a thesis and I figured out that the article class suits me well, but my university has some specific requirements on how the ToC should look like. I need to
  • Add dots after part numbers
  • Add "Chapter" before the section numbers
  • The sections should be numbered with \Roman numerals.
  • I need to fill the sections line with dots just like for the subsections
  • The subsections should be all numbered with \arabic numerals and they should not include the word "Chapter"
  • The other formatting should remain as it is
So basically it should look like this:
Preface (section*) ............................ 1
Chapter I. Blah-blah-blah (section) ....... 2
1.1. Foo ........................................... 3
1.2. Bar ........................................... 4
Chapter II. Blah-blah-blah (section) ...... 5
Conclusion ...................................... 1
I figured out that it should be doable with the titletoc package, but I have read through the manual and didn't understand a word of it. I managed to apply those changes to the text itself via the titlesec package, but this one is really over my head.

So please please help me :)

Please find my preamble below:

Code: Select all

% $Id: diploma.tex 23 2009-05-24 23:11:50Z zyv $

% The extsizes classes and class options provide support for sizes eight, nine,
% ten, eleven, twelve, fourteen, seventeen and twenty points.
% http://www.ctan.org/tex-archive/macros/latex/contrib/extsizes/
\documentclass[a4paper,14pt]{extarticle}

% PDF search & cut'n'paste
\usepackage{cmap}

% Better sans-serif fonts
\usepackage{pscyr}
\renewcommand{\rmdefault}{cmr}
\renewcommand{\sfdefault}{ftx}
\renewcommand{\ttdefault}{cmtt}

% Cyrillic support
\usepackage{mathtext}
\usepackage[T2A]{fontenc}
\DeclareSymbolFont{T2Aletters}{T2A}{cmr}{m}{it}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}

% AMS font faces
\usepackage{amsmath, amsfonts, amssymb}

% Detect whether PDFLaTeX is in use
\usepackage{ifpdf}

% Graphics
\ifpdf
	\usepackage[pdftex]{graphicx}
\else
	\usepackage{graphicx}
\fi

\graphicspath{{images/}}

% Indent the first paragraph as well
\usepackage{indentfirst}

% According to GOST, sections should be called chapters in diploma
\usepackage{titlesec}
\usepackage{titletoc}

\setcounter{tocdepth}{2}

\titleformat{\section}{\bfseries\large\sffamily}
	{Глава~\Roman{section}.~}{1em}{}
\titleformat{\subsection}{\bfseries\normalsize\sffamily}
	{\arabic{section}.\arabic{subsection}.\quad}{1em}{}
\titleformat{\subsubsection}{\normalsize\sffamily}
	{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.\quad}{1em}{}

\titlespacing*{\section}      {0pt}{3.50ex plus 1ex minus .2ex}{2.3ex plus .2ex}
\titlespacing*{\subsection}   {0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}
\titlespacing*{\subsubsection}{0pt}{3.25ex plus 1ex minus .2ex}{1.5ex plus .2ex}

% Page numbering at the right topmost part of the page
\pagestyle{myheadings}

% Provides support for setting the spacing between lines in a document. Package
% options include singlespacing, onehalfspacing, and doublespacing.
% http://www.ctan.org/tex-archive/macros/latex/contrib/setspace/
\usepackage{setspace}

% Alternative geometry
\usepackage[top=2cm, bottom=2cm, left=3cm, right=1cm]{geometry}

% Hyperlinks
\ifpdf
	\usepackage[pdftex]{hyperref}
\else
	\usepackage{hyperref}
\fi

\hypersetup{
	unicode=true,
	pdftitle={},
	pdfauthor={Yury V. Zaytsev},
	colorlinks,
	citecolor=black,
	filecolor=black,
	linkcolor=black,
	urlcolor=blue
}

% Fix links to floats
\usepackage[all]{hypcap}

% Nice citations [1,2,3,4] -> [1-4]
\usepackage{cite}

% [1] -> 1. in the bibliography
\makeatletter
\renewcommand\@biblabel[1]{#1.}
\makeatother

% Russian-styled figure and table captions
\usepackage[labelsep=period]{caption}
Thanks!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
LaTeX Beginner's Guide LaTeX Cookbook LaTeX TikZ graphics TikZによるLaTeXグラフィックス
zyv
Posts: 8
Joined: Mon May 25, 2009 7:43 pm

Customize ToC (class article, package titletoc)

Post by zyv »

Hi there!

I partially figured out how to do it. Indeed, I was looking into the wrong place. What I need is the tocloft package, not titletoc.

Code: Select all

\usepackage[titles]{tocloft}

\renewcommand{\cftsecpresnum}{Глава~}
\renewcommand{\cftsecleader}{\bfseries\cftdotfill{\cftdotsep}}
\renewcommand{\cftsecaftersnum}{.}
\renewcommand{\cftsubsecaftersnum}{.}

\newlength{\zyvseclen}
\settowidth{\zyvseclen}{\bfseries\cftsecpresnum\cftsecaftersnum}
\addtolength{\cftsecnumwidth}{\zyvseclen}

\renewcommand{\thesection}{\Roman{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}}
\renewcommand{\thesubsubsection}
	{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}}
This has only one drawback though. Section titles have hanging indentation and this looks OK for the short titles, but for the long ones it looks absolutely horrible.

Could somebody please advice on how I would disable the hanging indentation for the section titles?

Thanks!
zyv
Posts: 8
Joined: Mon May 25, 2009 7:43 pm

Customize ToC (class article, package titletoc)

Post by zyv »

Uhm... yet another answer to myself. I've found a partial fix for that, but it does not affect the ToC, only the text itself :( :

Code: Select all

\titleformat{\section}[block]{\bfseries\large\sffamily\raggedright}
	{Глава~\Roman{section}.}{1ex}{}
\titleformat{\subsection}[block]{\bfseries\normalsize\sffamily\raggedright}
	{\arabic{section}.\arabic{subsection}.}{1ex}{}
\titleformat{\subsubsection}[block]{\normalsize\sffamily\raggedright}
	{\arabic{section}.\arabic{subsection}.\arabic{subsubsection}.}{1ex}{}
Post Reply