TransWikia.com

Dissertation formatting help, table of contents

TeX - LaTeX Asked by Priyanka Chakraborty on August 30, 2021

I need some urgent help with my dissertation formatting for the TOC which I am just not able to figure out and have a submission deadline to get my PhD.

I have manually created the TOC (I had to), and need to make the following changes in it:

  1. Triple space from title for List of Figures
  2. Have double space between each entry EXCEPT multi-line titles.
  3. Indent second line if title has two lines or more.

I have tried everything and looked everywhere, but just can’t figure this out. I would SERIOUSLY appreciate any help with this asap.

I am attaching the TeX code. I work on Overleaf.

documentclass[12pt]{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
usepackage{amssymb}
usepackage{amsmath}
usepackage{geometry}
usepackage{setspace}
usepackage{endnotes}
usepackage{sectsty}
usepackage{indentfirst}
usepackage{graphicx} % Allows including images
usepackage{footmisc}
usepackage{etoolbox}
setlength{footnotesep}{baselineskip} %use 1.67baselineskip for a double space
usepackage[utf8]{inputenc}
pagenumbering{roman}

setcounter{MaxMatrixCols}{10}


baselineskip = 21pt
renewcommand
baselinestretch{1.5}
newtheorem{defn}{Definition}
geometry{left=1in,right=1in,top=1in,bottom=1in}
doublespacing
makeatletter
def@biblabel#1{hspace*{-labelsep}}
makeatother

renewcommand{contentsname}
    {centering normalsize CONTENTS}


newcommand{addsection}[3]{addtocontents{toc}{protectcontentsline{section}{protectnumberline{#1}#2}{#3}}}
newcommand{addsubsection}[3]{addtocontents{toc}{protectcontentsline{subsection}{protectnumberline{#1}#2}{#3}}}
newcommand{addsubsubsection}[3]{addtocontents{toc}{protectcontentsline{subsubsection}{protectnumberline{#1}#2}{#3}}}


begin{document}

setcounter{page}{7}


% Construct contents
addsection{}{LIST OF FIGURES}{viii}
addsection{}{LIST OF TABLES}{ix}

addsection{}{CHAPTERS}{}

addsection{1}{IT'S A MATCH! OR IS IT? A LAB EXPERIMENT ON MENTORSHIP}{1}
addsubsection{1.1}{Introduction}{1}
addsubsection{1.2}{The Mentorship Experiment: Experiment Design}{7}
addsubsection{1.3}{Treatments}{14}
addsubsection{1.4}{Implementation}{17}
addsubsection{1.5}{Experimental Results}{18}
addsubsection{1.6}{Conclusion}{26}


addsection{2}{ GENDER DIFFERENCES IN TOP LEADERSHIP ROLES: DOES WORKER BACKLASH MATTER?}{45}
addsubsection{2.1}{Introduction}{45}
addsubsection{2.2}{The Leadership Experiment: Experiment Design}{51}
addsubsection{2.3}{Treatments}{54}
addsubsection{2.4}{Implementation}{57}
addsubsection{2.5}{Experimental Results}{58}
addsubsubsection{2.5.1}{Gender differences in the decision to be manager}{59}
addsubsubsection{2.5.2}{Gender differences in managers' decision-making}{62}
addsubsubsection{2.5.3}{Gender differences in leadership style}{67}
addsubsubsection{2.5.4}{Gender differences in the extent of received worker backlash}{68}
addsubsection{2.6}{Conclusion}{70}

addsection{3}{DEGREES OF EQUALITY: WHY ARE THERE FEWER WOMEN IN UNDERGRADUATE ECONOMICS?}{82}
addsubsection{3.1}{Introduction}{82}
addsubsection{3.2}{Literature Review}{83}
addsubsection{3.3}{Experiment Design}{89}
addsubsection{3.4}{Empirical Strategy}{91}
addsubsection{3.5}{Implementation}{92}
addsubsection{3.6}{Results}{93}
addsubsection{3.7}{Strategy for the full scale study}{95}
addsubsection{3.8}{Conclusion}{97}
    
addsection{}{APPENDIX}{106}
addsection{}{BIBLIOGRAPHY}{128}


tableofcontents

end{document}

One Answer

Any suggestions on how to have a single space for multi-line titles, with the second line indented as well?

In article.cls, l@section is defined as follows:

newcommand*l@section[2]{%
  ifnum c@tocdepth >z@
    addpenalty@secpenalty
    addvspace{1.0em @plusp@}%
    setlength@tempdima{1.5em}%
    begingroup
      parindent z@ rightskip @pnumwidth
      parfillskip -@pnumwidth
      leavevmode bfseries
      advanceleftskip@tempdima
      hskip -leftskip
      #1nobreakhfil nobreakhb@xt@@pnumwidth{hss #2}par
    endgroup
  fi}

So basically what you need to do is to modify this. In your preamble you should add

makeatletter
renewcommand*l@section[2]{%
  ifnum c@tocdepth >z@
    addpenalty@secpenalty
    addvspace{1.0em @plusp@}%
    setlength@tempdima{1.5em}%
    begingroup
      setstretch{1}%
      hangindent@tempdima
      parindent z@ rightskip @pnumwidth
      parfillskip -@pnumwidth
      leavevmode bfseries
      advanceleftskip@tempdima
      hskip -leftskip
      #1nobreakhfil nobreakhb@xt@@pnumwidth{hss #2}par
    endgroup
  fi}
makeatother

Where setstretch{1} is a command for a single space and hangindent@tempdima is a command for an indent of the second line.

Result: Result


As for subsection, there is a similar solution:

makeatletter
renewcommand*l@subsection[2]{%
  ifnum 2>c@tocdepth else
    vskip z@ @plus.2p@
    {@tempdimabaselineskip
    setstretch{1}%
    advance@tempdima-baselineskip
    setlength{parskip}{@tempdima}%
    hangindent1.5emrelax
    leftskip 1.5emrelax rightskip @tocrmarg parfillskip -rightskip
     parindent 1.5emrelax@afterindenttrue
     interlinepenalty@M
     leavevmode
     @tempdima 2.3emrelax
     advanceleftskip @tempdima nullnobreakhskip -leftskip
     {#1}nobreak
     leadershbox{$m@th
        mkern @dotsep muhbox{.}mkern @dotsep
        mu$}hfill
     nobreak
     hb@xt@@pnumwidth{hfilnormalfont normalcolor #2}%
     par}%
  fi}
makeatother

In this solution,

    @tempdimabaselineskip
    setstretch{1}%
    advance@tempdima-baselineskip
    setlength{parskip}{@tempdima}%
    hangindent1.5emrelax

is the added part to the definition of l@subsection in article.cls and latex.ltx.

Result: enter image description here


Just in case, this is for subsubsection.

makeatletter
renewcommand*l@subsubsection[2]{%
  ifnum 3>c@tocdepth else
    vskip z@ @plus.2p@
    {@tempdimabaselineskip
    setstretch{1}%
    advance@tempdima-baselineskip
    setlength{parskip}{@tempdima}%
    hangindent1.5emrelax
    leftskip 3.8emrelax rightskip @tocrmarg parfillskip -rightskip
     parindent 3.8emrelax@afterindenttrue
     interlinepenalty@M
     leavevmode
     @tempdima 3.2emrelax
     advanceleftskip @tempdima nullnobreakhskip -leftskip
     {#1}nobreak
     leadershbox{$m@th
        mkern @dotsep muhbox{.}mkern @dotsep
        mu$}hfill
     nobreak
     hb@xt@@pnumwidth{hfilnormalfont normalcolor #2}%
     par}%
  fi}
makeatother

Correct answer by domperor on August 30, 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