TeX - LaTeX Asked by JRLCAR on August 1, 2020
I would like to add a vertical space in my principal TOC before the last chapter. I used addtocontents{toc}{protectvspace{1,5cm}}
before my chapter and it does the job in the principal TOC. But it also add an undesired vertical space in the TOC of the chapter I created using printcontents[chapter]{l}{1}{setcounter{tocdepth}{2}}
. Here is an exemple :
documentclass[twoside,openright,titlepage,numbers=noenddot,
footinclude,cleardoublepage=empty,abstract=on,
paper=a4,fontsize=12pt
]{scrreprt}
usepackage{titletoc}
titlecontents{lsection}
[0.8 cm]
{}
{contentslabel[thecontentslabel]{1cm}}
{}
{hspace{0.15cm}smallcontentspage}
[]
usepackage{tcolorbox}
begin{document}
tableofcontents
chapter{First Chap}
startcontents[chapter]
begin{tcolorbox}[width=10.5cm, colback=gray!20!white, colframe= gray!20!white,
title=Sommaire,coltitle=black,
fonttitle=smallbfseriessffamily]
printcontents[chapter]{l}{1}{setcounter{tocdepth}{2}}
end{tcolorbox}
section{Section a1}
section{Section b1}
chapter{Second Chap}
startcontents[chapter]
begin{tcolorbox}[width=10.5cm, colback=gray!20!white, colframe= gray!20!white,
title=Sommaire,coltitle=black,
fonttitle=smallbfseriessffamily]
printcontents[chapter]{l}{1}{setcounter{tocdepth}{2}}
end{tcolorbox}
section{Section a2}
section{Section b2}
addtocontents{toc}{protectvspace{1,5cm}}
chapter{Third Chap}
startcontents[chapter]
begin{tcolorbox}[width=10.5cm, colback=gray!20!white, colframe= gray!20!white,
title=Sommaire,coltitle=black,
fonttitle=smallbfseriessffamily]
printcontents[chapter]{l}{1}{setcounter{tocdepth}{2}}
end{tcolorbox}
section{Section a3}
section{Section b3}
end{document}
Firstly, I would like to say that I'm not quite sure if what you are trying to achieve is really possible in a clean way as you are basically reading information from the same TOC. I would say my solution to the problem really wouldn't be optimal, but it works.
I removed the addtocontents{toc}{protectvspace{1,5cm}}
from your document and added the following code instead:
usepackage{etoolbox}
pretochapter{%
ifnumvalue{chapter}=2addtocontents{toc}{vskip100pt}fi
}
This basically achieves the same thing as you were doing, without it interfering with any other spacing, which your code was doing for some reason. There is still a big space in the sommaire of chapter three, but this can be solved easily using the following code for chapter 3:
begin{tcolorbox}[width=10.5cm, colback=gray!20!white, colframe= gray!20!white,
title=Sommaire,coltitle=black,
fonttitle=smallbfseriessffamily]
vspace{-100pt}
printcontents[chapter]{l}{1}{setcounter{tocdepth}{2}}
end{tcolorbox}
All I did here was add a negative vertical spacing to compensate for the extra spacing introduced by the comment above.
I hope to have helped you with this solution!
Answered by G. de Man on August 1, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP