TransWikia.com

How to reduce spacing between chapters in table of content?

TeX - LaTeX Asked by Louise on March 9, 2021

I wold like to reduce the spacing between the chapter entries in my table of content. I havent been able to find a problem similar to what I would like solved.

A minimal work of my report is below. This gives a large spacing in the table of content between eg. results and conclusion, between conclusion and Appendix A and so on.

documentclass[12pt,a4paper,fleqn]{report}

begin{document}

tableofcontents 

chapter{introduction}
section{first section}
section{second section}

chapter{Main matter}
chapter{Results}
chapter{Conclusion}
chapter{Appendix A}
chapter{Appendix B}

end{document}

enter image description here

4 Answers

You can use the tocloft package and its cftbeforechapskip command to achieve your desired spacing:

documentclass[12pt,a4paper,fleqn]{report}
usepackage[titles]{tocloft}
setlength{cftbeforechapskip}{3pt}
begin{document}

tableofcontents 

chapter{introduction}
section{first section}
section{second section}

chapter{Main matter}
chapter{Results}
chapter{Conclusion}
chapter{Appendix A}
chapter{Appendix B}

end{document}

OUTPUT:
enter image description here

Correct answer by Vahid Damanafshan on March 9, 2021

Or you could use package tocbasic:

documentclass[12pt,a4paper,fleqn]{report}

usepackage{tocbasic}
DeclareTOCStyleEntry[
  beforeskip=.2em plus 1pt,% default is 1em plus 1pt
  pagenumberformat=textbf
]{tocline}{chapter}

begin{document}
tableofcontents 
chapter{introduction}
section{first section}
section{second section}
chapter{Main matter}
chapter{Results}
chapter{Conclusion}
chapter{Appendix A}
chapter{Appendix B}
end{document}

Result:

enter image description here

Answered by esdd on March 9, 2021

You can do that in a simple way with titletoc. In the following code, the vertical spacing aboce the entrys is set in the first mandatory argument of the titlecontents command. I set it to medskip for chapters, but you change it at will:

documentclass[12pt,a4paper,fleqn]{report}

usepackage[utf8]{inputenc}
usepackage{titletoc}

    titlecontents{chapter}
    [0em] %
    {medskipbfseries}
    {thecontentslabelquad}%numbered chapters
    {}%numberless chapter
    {hfillcontentspage}

    titlecontents{section}[1.72em]{smallskip}%
    {thecontentslabel.enspace}%numbered sections
    {}%numberless section
    {titlerule*[1.2pc]{.}contentspage}%

begin{document}

tableofcontents

chapter{introduction}
section{first section}
section{second section}

chapter{Main matter}
chapter{Results}
chapter{Conclusion}
chapter{Appendix A}
chapter{Appendix B}

end{document} 

enter image description here

Answered by Bernard on March 9, 2021

With titletoc the following did the trick for me:

usepackage{titletoc}

titlecontents{chapter}
    [0em] %
    {bfseries}
    {Chapter thecontentslabelquad}%numbered chapters
    {}%numberless chapter
    {hfillcontentspage}

titlecontents{section}[1.72em]{vspace{-10pt}}%
    {thecontentslabel.enspace}%numbered sections
    {}%numberless section
    {titlerule*[0.5pc]{.}contentspage}%

Note the negative vspace.

Answered by qed on March 9, 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