0

I use titletoc\titlesec for typesetting a book.

\documentclass[a4paper]{book}
\pdfoutput=1  %For postig in ArXiv.org
\usepackage{textcase}

\usepackage[14pt]{extsizes}
\renewcommand{\baselinestretch}{1}
\usepackage{color}
\usepackage{indentfirst}
\usepackage{microtype}
\usepackage{indentfirst}

\makeatletter
\renewcommand{\@evenhead}{}
\renewcommand{\@oddhead}{}
\renewcommand{\@evenfoot}{\centerline\thepage}
\renewcommand{\@oddfoot}{\centerline\thepage}
\makeatother

\usepackage{geometry}
\geometry{top=2cm} %поле сверху
\geometry{bottom=2.5cm} %поле снизу
\geometry{left=2.5cm} %поле справа
\geometry{right=2cm} %поле слева
\geometry{bindingoffset=0cm}


\usepackage[breaklinks, pdfpagelabels,linktoc=all, colorlinks=true,bookmarks,bookmarksnumbered=true]{hyperref}



%---------------SECTIONS TYPOS---------------
\usepackage{titlesec,titletoc,chngcntr}
\let\cleardoublepage\clearpage

    \titleformat{\chapter}[display]
    {\vspace*{-5em}\Large}
    {\titleline[l]{\textls[200]{\MakeTextUppercase{\chaptertitlename}}\ \thechapter}\vspace{6pt}\titlerule[.8pt]}
    {\dimexpr-\baselineskip+6pt\relax}
    {\bfseries\MakeUppercase}


    \titleformat{\section}[block]
    {\bfseries}
    {\S\ \thesection.}
    {\fontdimen2\font}
    {}

    \titlecontents{chapter}[0pt]
    {}
    {\textls[200]{\chaptername} \thecontentslabel.\ \bfseries}
    {}
    {\titlerule*[6pt]{.}\contentspage}
    %[\addvspace{3pt}]

    \titlecontents{section}[1.5em]
    {}
    {\S\ \makebox[1.5em][l]{\thecontentslabel.}}
    {}
    {\titlerule*[6pt]{.}\contentspage}

    \makeatletter
    \renewcommand\frontmatter{\cleardoublepage\@mainmatterfalse}
    \renewcommand\mainmatter{\cleardoublepage\@mainmattertrue}
    \makeatother
    \renewcommand{\thechapter}{\Roman{chapter}}
    \counterwithout{section}{chapter}

%---------------TOC typeseting---------------

\let\origtableofcontents\tableofcontents
\renewcommand{\tableofcontents}{%
    \begingroup 
    \titleformat{\chapter}[display]
    {\Large}
    {\titleline[l]{\textls[200]{\MakeTextUppercase{\chaptertitlename}}\ \thechapter}\vspace{6pt}\titlerule[.8pt]}
    {\dimexpr-\baselineskip+6pt\relax}
    {\bfseries\MakeUppercase}%
    \origtableofcontents
    \endgroup}

 \begin{document}
    \frontmatter
    \tableofcontents

\mainmatter
\chapter{Some one}


\section{Some one} 

Some text

\section{Some two} 
Some text

\chapter{Some two} 
\section{Some two} 
 \end{document}   

I need to change a vertical indent before chaptertitle, which is setting by \vspace*{-5em} in \titleformat. "-" sign because of \titleformat[display] adds a large unknown vertical indent. I wish to remove this indent any possible ways. I think that this can be done through command \vspace*{-5em}, but value -5em is very nonrelative thing, when I chang page geometry, the typesetting looks not so good. Thus, I need to set \vspace*{0 any unit} relative to the \geometry{top=2cm}, i.e vertical space must have the value top=2cm.

1

You can do that using \titlespacing. I also redefined the formatting of the table of contents with the numberless key and removed the \lsstyle command from the toc, as it never should be used with lowercase text. In chpter titles, I apply \lsstyle to the whole title (label+chapter title), with the default value — 0.2em is too large, in my opinion.

\documentclass[a4paper]{book}
\pdfoutput=1 %For postig in ArXiv.org
\usepackage{textcase}

\usepackage[14pt]{extsizes}
\renewcommand{\baselinestretch}{1}
\usepackage{color}
\usepackage{indentfirst}
\usepackage{microtype}
\usepackage{indentfirst}

\makeatletter
\renewcommand{\@evenhead}{}
\renewcommand{\@oddhead}{}
\renewcommand{\@evenfoot}{\centerline\thepage}
\renewcommand{\@oddfoot}{\centerline\thepage}
\makeatother

\usepackage[showframe, nomarginpar]{geometry}
\geometry{top=2cm} %поле сверху
\geometry{bottom=2.5cm} %поле снизу
\geometry{left=2.5cm} %поле справа
\geometry{right=2cm} %поле слева
\geometry{bindingoffset=0cm}


\usepackage[breaklinks, pdfpagelabels,linktoc=all, colorlinks=true,bookmarks,bookmarksnumbered=true]{hyperref}



%---------------SECTIONS TYPOS---------------
\usepackage{titlesec,titletoc,chngcntr}
\let\cleardoublepage\clearpage
\setlength\fboxsep{0pt}
\titleformat{\chapter}[display]
{\Large\centering\lsstyle}
{\MakeTextUppercase{\chaptertitlename}\ \thechapter\\\titlerule[.8pt]}%
{\dimexpr-\baselineskip +0.5ex\relax}%
{\bfseries\MakeUppercase}

\titleformat{name=\chapter, numberless}[block]
{\Large\lsstyle}{} {0pt}{\bfseries\MakeUppercase}

\titlespacing*{\chapter}{0pt}{-2.2ex}{5\baselineskip}


\titleformat{\section}[block]
{\bfseries}
{\S\ \thesection.}
{\fontdimen2\font}
{}

\titlecontents{chapter}[0pt]
{\bigskip}
{\chaptername~\thecontentslabel.\enspace\bfseries}
{}
{\titlerule*[6pt]{.}\contentspage}[\medskip]

\titlecontents{section}[1.5em]
{}
{\S\ \makebox[1.5em][l]{\thecontentslabel.}}
{}
{\titlerule*[6pt]{.}\contentspage}

\makeatletter
\renewcommand\frontmatter{\cleardoublepage\@mainmatterfalse}
\renewcommand\mainmatter{\cleardoublepage\@mainmattertrue}
\makeatother
\renewcommand{\thechapter}{\Roman{chapter}}
\counterwithout{section}{chapter}

\begin{document}
\frontmatter
\tableofcontents

\mainmatter
\chapter{Some one}


\section{Some one}

Some text

\section{Some two}
Some text

\chapter{Some two}

\section{Some two}
\end{document} 

enter image description here

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.