TransWikia.com

Indenting only some sections in TOC

TeX - LaTeX Asked on April 8, 2021

I want to indent some sections in the TOC but leave the fact that they’re unnumbered and not indented in the body unchanged. Example follows.

In the example below I would want “Test” in the TOC to be aligned with “1.1 Section Foo” so that the “T” is right under the “S”, while leaving the formatting of the body unchanged and still no numbering of “Test” in the TOC.

documentclass{book}

usepackage{bookman}
usepackage{tocstyle}
usetocstyle{standard}
renewcommand{numberline}[1]{#1~}
setcounter{tocdepth}{1}
newenvironment{test}[1]{%
  subsection*{#1}}

begin{document}

tableofcontents

chapter{Chapter Foo}
section{Section Foo}
subsection{Subsection Foo}
begin{test}{Test}
addcontentsline{toc}{section}{Test}
subsubsection*{Subsection Foo Star}
end{test}

end{document}

One Answer

I figured it out. Here are the changes to make to my original example:

  1. Change tocdepth argument from 1 to 2 to show subsections.
  2. Change subsections I do want in the TOC from subsection to subsection*.
  3. Change the addcontentsline argument from section to subsection.

Answered by E2R0NS on April 8, 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