0

I'm modifying the report format in the preamble and I need to indent the following lines (circled in red) of a multi-line title in the table of contents by an additional 0.25" from the first line (hanging indent of 0.25in). From doing a bit of reading it seems like using \cftchapnumwidth from tocloft may be the answer, but \setlength{\cftchapnumwidth}{0.25in} doesn't seem to change anything. Does anyone know how to accomplish this?

enter image description here

LaTeX code to generate this is:

%Preamble
\documentclass[10pt, letterpaperpaper,]{report}\usepackage{setspace}\doublespacing %Double Spacing
\usepackage{sectsty}\allsectionsfont{\normalsize} % Make all font size 12
\usepackage[hidelinks]{hyperref}
\usepackage[left = 1in, right = 1in, top = 1in, bottom = 1in]{geometry}

%Table of Contents, List of Tables, List of Figures \usepackage[titles]{tocloft} %Load package for customizing table of contents/lists/figures (Adding titles makes it so that they are formatted the same as chapter titles) \renewcommand{\contentsname}{Table of Contents} %Rename Contents to Table of Contents \renewcommand{\cftchapleader}{\cftdotfill{\cftdotsep}} % dots for chapters in table of contents \renewcommand{\cfttoctitlefont}{\normalsize\bfseries} %Bold faced normal size font for title of Table of Contents \renewcommand{\cftloftitlefont}{\normalsize\bfseries} %Bold faced normal size font for title of List of Tables \renewcommand{\cftlottitlefont}{\normalsize\bfseries} %Bold faced normal size font for List of Tables \renewcommand{\cftchapfont}{\normalsize} %Unbold chapter titles in table of contents \renewcommand{\cftchappagefont}{\normalfont} %Unbold chapter page numbers in table of contents \renewcommand{\cftfigpresnum}{Figure~} %Precede number with "Figure" \renewcommand{\cftfignumwidth}{2cm} %Add space between figure number and caption \renewcommand{\cfttabpresnum}{Table~} %Precede number with "Table" \renewcommand{\cfttabnumwidth}{2cm} %Add space between table number and caption \renewcommand{\cftchapindent}{0in} %Set indents to increase by 0.5 inches per level \renewcommand{\cftsecindent}{0.5in} %Set indents to increase by 0.5 inches per level \renewcommand{\cftsubsecindent}{1in} %Set indents to increase by 0.5 inches per level \renewcommand{\cftsubsubsecindent}{1.5in} %Set indents to increase by 0.5 inches per level \renewcommand{\cftparaindent}{2in} %Set indents to increase by 0.5 inches per level \renewcommand{\cftsubparaindent}{2.5in} %Set indents to increase by 0.5 inches per level \setlength{\cftfigindent}{0pt} % remove indentation from figures in lof \setlength{\cfttabindent}{0pt} % remove indentation from tables in lot \setlength{\cftbeforetabskip}{\parskip} %Spacing between list of table entries \setlength{\cftbeforefigskip}{\parskip} %Spacing between list of figure entries

\makeatletter \renewcommand@tocrmarg{0.5in} % Make long titles wrap when they are 0.5 inches away from page numbers \makeatother

\newcommand{\noaddvspace}{\renewcommand{\addvspace}[1]{}} \addtocontents{lof}{\protect\noaddvspace} %Prevents gap between chapters in List of Figures \addtocontents{lot}{\protect\noaddvspace} %Prevents gap between chapters in List of Tables

%Chapter Headings \usepackage{titlesec} \titleformat{\chapter}[hang] %Make chapter number and title on same line {\normalfont\normalsize\bfseries}{\chaptertitlename\ \thechapter:}{1em}{} %Adjust title font formatting (normal, bold) \titlespacing{\chapter}{0pt}{40pt}{12pt} %{increases the left margin}{vertical space before the title}{separation between title and text} \titlespacing{\part}{0pt}{35pt}{12pt} %{increases the left margin}{vertical space before the title}{separation between title and text}

%Appendix %\usepackage[titletoc]{appendix}

\usepackage{tocloft} \usepackage{calc} \renewcommand{\cftchappresnum}{\chaptername\space} %\setlength{\cftchapnumwidth}{\widthof{\textbf{Appendix~999~}}} \setlength{\cftchapnumwidth}{2cm} \makeatletter \g@addto@macro\appendix{% \addtocontents{toc}{% \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}% }% } \newcommand*\annex{% \renewcommand{\appendixname}{Annex}% \setcounter{chapter}{0} \addtocontents{toc}{% \protect\renewcommand{\protect\cftchappresnum}{\appendixname\space}% }% }

\usepackage{blindtext}% only for dummy text %https://tex.stackexchange.com/questions/435684/how-to-include-appendix-names-in-toc

\begin{document} \setcounter{tocdepth}{6} %Table of contents goes to level 6 headings \singlespacing \tableofcontents % Create List of Tables in Latex \pagenumbering{roman}

\singlespacing \listoftables % Create List of Tables in Latex \addcontentsline{toc}{chapter}{List of Tables}

\newpage

\singlespacing \listoffigures % Create List of Tables in Latex \addcontentsline{toc}{chapter}{List of Figures}

\newpage \pagenumbering{arabic} \doublespacing

\hypertarget{a-really-long-heading-so-i-see-what-happens-when-it-takes-up-more-than-one-line-just-in-case-were-getting-crazy}{% \chapter{A Really Long Heading so I see what happens when it takes up more than one line just in case we're getting crazy}\label{a-really-long-heading-so-i-see-what-happens-when-it-takes-up-more-than-one-line-just-in-case-were-getting-crazy}}

\hypertarget{results}{% \section{Results}\label{results}}

\hypertarget{a-really-long-heading-so-i-see-what-happens-when-it-takes-up-more-than-one-line-just-in-case-were-getting-crazy-1}{% \subsection{A Really Long Heading so I see what happens when it takes up more than one line just in case we're getting crazy}\label{a-really-long-heading-so-i-see-what-happens-when-it-takes-up-more-than-one-line-just-in-case-were-getting-crazy-1}} \end{document}

ailich
  • 1
  • 3
  • Are you trying to achieve hanging indentation? Please advise. – Mico Jan 17 '22 at 04:38
  • Yes, a hanging indent seems to be the name for what I'm trying to do. I'd like the second line of a long entry to be indented an additional 0.25 inches relative to the first line of that entry. – ailich Jan 17 '22 at 14:26
  • Please provide an MWE (from \documentclass... to \end{document}) that we can compile that shows your problem. Your exhibited code has no\documentclass` or anything that would populate the ToC. Most of the code you showed had nothing to do with your problem. – Peter Wilson Jan 17 '22 at 19:02
  • Thanks Peter. I have added LaTex code that can be compiled to recreate the example. – ailich Jan 17 '22 at 20:56

1 Answers1

0

Got a response on github that was able to get this working using a combination of cftXindent, \cftXnumwidth and \cftXaftersnumb. Choosing \cftXnumwidth requires a bit of trial and error to find values that work for each heading level.

\renewcommand{\cftchapindent}{0.25in} %Set indents to increase by 0.5 inches per level (1)
\renewcommand{\cftchapaftersnumb}{\hspace*{-0.635cm}} %hanging indent for sections that take up more than one line (level 2)

\renewcommand{\cftsecindent}{0.75in} %Set indents to increase by 0.5 inches per level (2) \renewcommand{\cftsecnumwidth}{1.5cm} %off set hanging indent for long section lines below (level 2) \renewcommand{\cftsecaftersnumb}{\hspace*{-0.635cm}} %hanging indent for sections that take up more than one line (level 2)

\renewcommand{\cftsubsecindent}{1.25in} %Set indents to increase by 0.5 inches per level (3) \renewcommand{\cftsubsecnumwidth}{1.7cm} %off set hanging indent for long section lines below (level 3) \renewcommand{\cftsubsecaftersnumb}{\hspace*{-0.635cm}}%hanging indent for sections that take up more than one line (level 3)

\renewcommand{\cftsubsubsecindent}{1.75in} %Set indents to increase by 0.5 inches per level (4) \renewcommand{\cftsubsubsecnumwidth}{1.8cm} %off set hanging indent for long section lines below (level 4) \renewcommand{\cftsubsubsecaftersnumb}{\hspace*{-0.635cm}}%hanging indent for sections that take up more than one line (level4)

\renewcommand{\cftparaindent}{2.25in} %Set indents to increase by 0.5 inches per level (5) \renewcommand{\cftparanumwidth}{2.1cm} %off set hanging indent for long section lines below (level 5) \renewcommand{\cftparaaftersnumb}{\hspace*{-0.635cm}}%hanging indent for sections that take up more than one line (level 5)

\renewcommand{\cftsubparaindent}{2.75in} %Set indents to increase by 0.5 inches per level (6) \renewcommand{\cftsubparanumwidth}{2.4cm} %off set hanging indent for long section lines below (level 6) \renewcommand{\cftsubparaaftersnumb}{\hspace*{-0.635cm}}%hanging indent for sections that take up more than one line (level 6)

\renewcommand{\cftchappresnum}{\chaptername\space} %Have Toc say "Chapter" followed by number \setlength{\cftchapnumwidth}{2.5cm} %Space so caption doesn't overlap "Chapter" number in TOC (added 0.5cm to offset hanging indent)

ailich
  • 1
  • 3