How can I change the vertical spacing above the section heading that dont have a number (like for instance the table of contents, the list of figures and the bibliograpy) while keeping the spacing of all other chapters the same? (I am using the report class.)
[Tex/LaTex] Change the vertical spacing above unnumbered sections headings
chapterssectioningspacingstarred-version
Related Solutions
Here's a possible solution using the titlesec package; setting the value of \aftertitleunit
to \baselineskip
, you can then use *2
in the fourth mandatory argument of \titlespacing
to obtain the desired vertical spacing between the title and the following text. You didn't provide information on the spacing before the title so I used 50pt
, but you can change this value to the one that best suits your needs. To maintain consistency between the numbered and unnumbered chapters I used two \titleformat
commands with similar settings: one for the numbered chapters and another one, using the numberless
key, for the unnumbered ones:
\documentclass{book}
\usepackage{titlesec}
\setlength\aftertitleunit{\baselineskip}
\titleformat{\chapter}[display]
{\normalfont\huge\bfseries}{}{0pt}{\Huge}
\titleformat{name=\chapter,numberless}[display]
{\normalfont\huge\bfseries}{}{0pt}{\Huge}
\titlespacing*{\chapter}{0pt}{50pt}{*2}
\begin{document}
\chapter{Test Numbered chapter}
\chapter*{Test Unumbered chapter}
\end{document}
Taking into account the edit to the original question, you can add \normalsize
just before \vskip2\baselineskip
:
\makeatletter
\renewcommand{\@makechapterhead}[1]{\vspace*{50\p@}%
{\parindent \z@ \raggedright \normalfont
\hrule % horizontal line
\vspace{5pt}% % add vertical space
\interlinepenalty\@M
\Huge \scshape #1\par % chapter title
\vspace{5pt}% % add vertical space
\hrule % horizontal rule
\nobreak\normalsize
\vskip 2\baselineskip
}}
\renewcommand{\@makeschapterhead}[1]{%
\vspace*{50\p@}%
{\parindent \z@ \raggedright
\normalfont
\hrule % horizontal line
\vspace{5pt}% % add vertical space
\interlinepenalty\@M
\Huge \scshape #1\par % chapter title
\vspace{5pt}% % add vertical space
\hrule % horizontal line
\nobreak\normalsize
\vskip2\baselineskip
}}
\makeatother
And here's the same layout but using titlesec
:
\documentclass{book}
\usepackage{titlesec}
\setlength\aftertitleunit{\baselineskip}
\titleformat{\chapter}[display]
{\normalfont\Huge \scshape}{\titlerule}{-33pt}{\Huge}[\vspace{-4pt}\titlerule]
\titleformat{name=\chapter,numberless}[display]
{\normalfont\Huge \scshape}{\titlerule}{-33pt}{\Huge}[\vspace{-4pt}\titlerule]
\titlespacing*{\chapter}{0pt}{50pt}{*2}
\usepackage{lipsum}
\begin{document}
\chapter{test}
\end{document}
UPDATED ANSWER
Do \usepackage[nostruts]{titlesec}
, which will remove the struts like my answer below did.
The feature was added with version 2.11, released 2019-07-16.
ORIGINAL ANSWER
The package titlesec
adds \strut
in some places. In your case you have to defeat this behavior in three places:
\documentclass[11pt]{article}
\usepackage{geometry}
\geometry{margin=5mm, paper=a6paper, showframe=true}
\usepackage{titlesec}
\usepackage{etoolbox}
\makeatletter
\patchcmd{\ttl@select}{\strut}{}{}{}
\patchcmd{\ttlh@hang}{\strut}{}{}{}
\patchcmd{\ttlh@hang}{\strut}{}{}{}
\makeatother
\titleformat*\section{\Large}
\titleformat*\subsection{\large}
\usepackage{lipsum}
\begin{document}
\section*{Using titlesec}
\subsection*{Lorem Ipsum}
\lipsum[3]
\end{document}
The macros involved are \ttl@select
and \ttlh@hang
(in the second one \strut
appears twice. If other styles are selected it may be necessary to patch \ttlh@display
or \ttlh@runin
.
Best Answer
This answer was taken mostly verbatim from How to remove top margin above
\tableofcontents
.In the standard document classes (like
book
andreport
),\tableofcontents
(and friends) is set as a\chapter*
:So, it would be possible to temporarily modify the chapter heading macro to not insert as much vertical space. Here's a look at the
\chapter*
heading macro\@makeschapterhead
:Note the insertion of vertical space (
\vspace*{50\p@}
) before setting the heading. So, we can temporarily redefine this macro to not insert the vertical space (or modify it to whatever you need):The grouping of the redefinition makes it local. Therefore, all modifications are restored after
\endgroup
. The same idea goes for\listoffigures
,\listoftables
, etc. Of course, a global change to\@makeschapterhead
would also suffice as the ToC, LoF and LoT are typically all unnumbered chapters.Here is another suggestion that patches
\@makeschapterhead
usingetoolbox
:Since the
\chapter*
header macro only uses\vspace*{..}
to insert the gap between the text block and chapter header, you could also redefine\vspace
to gobble the two arguments (*
and{50\p@}
):While the above suggestion may seem simple, it may have negative effects elsewhere in your document where you use
\vspace
(perhaps indirectly) if the change is made global (rather than the suggested localization through grouping). It is therefore not advised in the global use case.Other packages (including
titlesec
) can also be used to obtain this result.