TransWikia.com

ToC style, using ToCloft

TeX - LaTeX Asked on July 1, 2021

I’m preparing my thesis in LYX. Previously I asked a question about article class, but then I’ve found that it would be better to use report class instead. I use a tocloft package and code looks as follows:

documentclass[14pt]{extreport}
renewcommand{familydefault}{rmdefault}
usepackage[LGR,T1,T2A]{fontenc}
usepackage[koi8-r]{inputenc}
usepackage[a4paper]{geometry}
geometry{verbose,tmargin=2cm,bmargin=2cm,lmargin=2.5cm,rmargin=1.1cm,headheight=17pt}
usepackage{fancyhdr}
pagestyle{fancy}
setcounter{secnumdepth}{1}
setcounter{tocdepth}{1}
usepackage{float}
usepackage{units}
usepackage{textcomp}
usepackage{amsmath}
usepackage{stmaryrd}
usepackage{graphicx}
usepackage{setspace}
usepackage{esint}
usepackage{subscript}
onehalfspacing

makeatletter

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
newcommand*LyXZeroWidthSpace{hspace{0pt}}
DeclareRobustCommand{greektext}{%
  fontencoding{LGR}selectfontdefencodingdefault{LGR}}
DeclareRobustCommand{textgreek}[1]{leavevmode{greektext #1}}
ProvideTextCommand{~}{LGR}[1]{char126#1}

DeclareRobustCommand{cyrtext}{%
  fontencoding{T2A}selectfontdefencodingdefault{T2A}}
DeclareRobustCommand{textcyr}[1]{leavevmode{cyrtext #1}}

newcommand{lyxmathsym}[1]{ifmmodebegingroupdefb@ld{bold}
  text{ifxmath@versionb@ldbfseriesfi#1}endgroupelse#1fi}

ProvideTextCommandDefault{guillemotleft}{%
  {usefont{U}{lasy}{m}{n}char'50kern-.15emchar'50}%
penalty10000hskip0ptrelax%
}
ProvideTextCommandDefault{guillemotright}{%
  penalty10000hskip0pt%
  {usefont{U}{lasy}{m}{n}char'51kern-.15emchar'51}%
}
DeclareTextSymbolDefault{textquotedbl}{T1}
%% Because html converters don't know tabularnewline
providecommand{tabularnewline}{}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
usepackage[koi8-r]{inputenc}
usepackage{mathtext}
usepackage{titlesec}
usepackage[english, russian]{babel}
%usepackage[T1,T2A]{fontenc}
usepackage{tocloft}
addcontentsline{toc}{chapter}{Введение}
renewcommand{cfttoctitlefont}{hfilLargebfseries}
renewcommand{cftaftertoctitle}{hfill}
renewcommand{cftchappresnum} {Глава }
setlength{cftchapnumwidth}{5em}
setlength{cftsecnumwidth}{3em}
renewcommand{headrulewidth}{0}

makeatother

usepackage[style=gost-numeric,bibencoding=utf8, sorting=none]{biblatex}

addbibresource{0C__Users_1_Documents_My_diss_All_bib.bib}
begin{document}

lhead{}
rhead{}
chead{thepage}
cfoot{}
begin{center}
{large{}Титульная}vspace{28pt}
parend{center}

noindent begin{center}
Специальность 01.04.11 -- физика магнитных явлений
parend{center}    

newpage{}  

tableofcontents 
clearpage

newpage{}

chapter*{{large{}Введение }}

section*{{normalsize{}Цели диссертационной работы}}

section*{{normalsize{}Апробация работы} }
  Основные результаты диссертационной..

newpage{}

chapter{{large{}Литературный обзор}}

vspace{42pt}

section{{normalsize{}Природа обменного взаимодействия}}

section{{normalsize{}Обменные взаимодействия в соединениях РЗМ с Fe, Ni,
Mn}}

section{{normalsize{}Кристаллическая структура...}}

newpage{}

chapter{{large{}Технология приготовления и аттестация образцов }}

vspace{42pt}

section{{normalsize{}Микроструктура }}

section{{normalsize{}Методика измерения магнитокалорического эффекта в малых
полях и больших полях}}

section{{normalsize{}Измерение магнитной восприимчивости}}

newpage{}

chapter{{large{}Результаты}}

vspace{42pt}

section{{normalsize{}Гигантская объёмная ...  }}

vspace{42pt}

section{{normalsize{}Магнитные свойства...}}

vspace{42pt}

newpage{}

chapter{{large{}Выводы}}

newpage{}

chapter*{{large{}Литература}}

addcontentsline{toc}{chapter}{Литература}

nocite{*}
printbibliography

end{document}

There are 2 points still looking not like they should.
First one- the header of ToC is not centered. However I used a command renewcommand{cfttoctitlefont} that should provide centering.

And I need the chapter (‘Глава ‘) name to be followed by dots just like section name.

How can I edit these?

One Answer

Please use minimal working examples (MWE) to simplify troubleshooting.

Firstly, you're on the right track with centering the TOC title. Adding this command to the preamble should produce the desired output.

renewcommand{cfttoctitlefont}{hfill}
renewcommand{cftaftertoctitle}{hfill}

Secondly, you can get generate leading dots after section entries in the table of contents by adding the following command to your preamble.

renewcommand{cftchapdotsep}{cftdotsep}

Putting it all together into a MWE.

documentclass{extreport}
usepackage{fancyhdr}
pagestyle{fancy}
setcounter{secnumdepth}{1}
setcounter{tocdepth}{1}

usepackage{tocloft}
addtocontents{toc}{protectthispagestyle{fancy}}

% centre toc title
renewcommand{cfttoctitlefont}{hfillLarge}
renewcommand{cftaftertoctitle}{hfill}

% add leading dots to chapters in TOC
renewcommand{cftchapdotsep}{cftdotsep}

begin{document}

tableofcontents

chapter{First}
section{Some Section}

chapter{Second}
section{Another Section}

end{document}

enter image description here

Correct answer by CatThatKilledCuriosity on July 1, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP