Text FormattingRigid Spacing Demands for ToC, LoF and LoT

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
LavaTyper
Posts: 69
Joined: Sat Feb 11, 2012 2:38 am

Rigid Spacing Demands for ToC, LoF and LoT

Post by LavaTyper »

I am still in the process of writing my dissertation, and I need to have consistent vertical spacing, between entries in my Table of Contents (ToC), and within entries in the ToC... and the same for my List of Tables (LoT) and List of Figures (LoF).

Ideally I would like to just have double spacing, which is easy for me to do in Microsoft Word.

But I'd rather get it right in LaTeX. At the moment my entries are a little tight.

(I have the format that I actually need in place, so the example below contains a lot of macros which I need.)


Can anyone help?

Code: Select all

\documentclass[12pt,letterpaper]{report}

\usepackage[document]{ragged2e}

\usepackage[none]{hyphenat}
\usepackage{times}
\usepackage{ifthen}
\usepackage{calc}
\usepackage{fancyhdr}
\usepackage{setspace}
\usepackage[indentafter,newlinetospace]{titlesec}
\usepackage[dotinlabels]{titletoc}
\usepackage{ccaption}
\usepackage{lipsum}  % not for use in the actual document


\renewcommand{\contentsname}{TABLE OF CONTENTS}
\renewcommand{\listtablename}{LIST OF TABLES}
\renewcommand{\listfigurename}{LIST OF FIGURES}
\renewcommand{\bibname}{REFERENCES}



%% Margins
\setlength{\textheight}{9in}
\setlength{\topmargin}{-0.5in}
\setlength{\headheight}{16pt}
\setlength{\headsep}{0.5in-\headheight}
\setlength{\textwidth}{5.8in}
\setlength{\parindent}{0.5in}

\newcommand{\relaxedspacing}{\doublespacing}  
\doublespacing

\raggedbottom

\clubpenalty =10000
\widowpenalty =10000
\brokenpenalty=10000
\doublehyphendemerits=40000
\finalhyphendemerits =10000
\righthyphenmin=3
\lefthyphenmin=4
\renewcommand{\topfraction}{0.5}
\setlength{\emergencystretch}{2em}



\titleformat{\chapter}[display]{\normalsize\bfseries\filcenter}{Chapter~\thechapter}{0in}{}
\titlespacing{\chapter}{0pt}{-.4in}{.25in}

\titleformat{\section}[hang]{\normalsize\bfseries\raggedright}{\thesection\hspace{0.1in}}{0in}{}
\titlespacing{\section}{0pt}{.23in}{.13in}

\titleformat{\subsection}[hang]{\normalsize\bfseries\raggedright}{\thesubsection\hspace{0.1in}}{0in}{}
\titlespacing{\subsection}{0pt}{.2in}{.09in}


% MAKE SURE TEXT IN THE TOC DOES NOT EXCEED
% ABOUT 5 DOTS:
\contentsmargin[3em]{0in}	
% This doesn't always work, keep reading.




\titlecontents{chapter}[0in]    
    { \ifthenelse{\equal{\thecontentslabel}{1}}{
        \vspace{1.3\baselineskip}Chapter\\ \normalsize
      }{
        \normalsize\vspace{.2\baselineskip}\raggedright
      }
    }
    {\contentspush{\thecontentslabel.~\hspace{0.25em}}}
    {}
    {\titlerule*[.3em]{.}\thecontentspage}
    {}

\titlecontents{section}[.3in]{}
              {\contentspush{\thecontentslabel.~}}{}
              {\titlerule*[.3em]{.}\thecontentspage}{}
\titlecontents{subsection}[.6in]{}
              {\contentspush{\thecontentslabel.~}}{}
              {\titlerule*[.3em]{.}\thecontentspage}{}
\titlecontents{subsubsection}[.9in]{}
              {\contentspush{\thecontentslabel.~}}{}
              {\titlerule*[.3em]{.}\thecontentspage}{}
\titlecontents{paragraph}[1.2in]{}
              {\contentspush{\thecontentslabel.~}}{}
              {\titlerule*[.3em]{.}\thecontentspage}{}
\titlecontents{subparagraph}[1.5in]{}
              {\contentspush{\thecontentslabel.~}}{}
              {\titlerule*[.3em]{.}\thecontentspage}{}


\titlecontents{table}[0in]{}
    {\contentspush{Table~\thecontentslabel.~}}{} 
    {\titlerule*[.3em]{.}\thecontentspage}{}

\titlecontents{figure}[0in]{}
    {\contentspush{Figure~\thecontentslabel.~}}{}
    {\titlerule*[.3em]{.}\thecontentspage}{}


\setcounter{secnumdepth}{10}
\setcounter{tocdepth}{10}
\newlength{\contentslength}


\let\Oldlistoffigures\listoffigures
\renewcommand{\listoffigures}{
  \cleardoublepage
  \phantomsection
  \addcontentsline{toc}{chapter}{\listfigurename}
  {\relaxedspacing \Oldlistoffigures }
}

\let\Oldlistoftables\listoftables
\renewcommand{\listoftables}{
  \cleardoublepage
  \phantomsection
  \addcontentsline{toc}{chapter}{\listtablename}
  {\relaxedspacing \Oldlistoftables }
}

\let\Oldtableofcontents\tableofcontents
\renewcommand{\tableofcontents}{
  \cleardoublepage
  \phantomsection
  \pdfbookmark[0]{\contentsname}{my_toc}
  {\relaxedspacing \Oldtableofcontents} 
  \setcounter{tocdepth}{10}
}

\renewcommand{\appendixname}{Appendix}
\let\oldAppendix\appendix
\renewcommand{\appendix}{
  \oldAppendix
  \cleardoublepage
  \phantomsection
  \pdfbookmark[0]{APPENDICES}{my_apps}
  \addtocontents{toc}{\protect \setcounter{tocdepth}{0} \par}
  \titleformat{\chapter}[display]{\normalsize\bfseries\filcenter}{\appendixname~\thechapter}{0in}{}
  \titlespacing{\chapter}{0pt}{-.4in}{.25in}
  \titlecontents{chapter}[0in]{\setlength{\emergencystretch}{4.5em}\normalsize\vspace{.2\baselineskip}}
    {\contentspush{Appendix~\thecontentslabel.~}}{}
    {\titlerule*[.3em]{.}\thecontentspage}{}
}





\makeatletter
\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
                       \if@mainmatter
                         \refstepcounter{chapter}%
                         \typeout{\@chapapp\space\thechapter.}%
                         \addcontentsline{toc}{chapter}%
                                   {\protect\numberline{\thechapter}#1}%
                       \else
                         \addcontentsline{toc}{chapter}{#1}%
                       \fi
                    \else
                      \addcontentsline{toc}{chapter}{#1}%
                    \fi
                    \chaptermark{#1}%
%                    \addtocontents{lof}{\protect\addvspace{10\p@}}% NEW
%                    \addtocontents{lot}{\protect\addvspace{10\p@}}% NEW
                    \if@twocolumn
                      \@topnewpage[\@makechapterhead{#2}]%
                    \else
                      \@makechapterhead{#2}%
                      \@afterheading
                    \fi}
\makeatother






% THIS IS EXTRA FORMATTING FOR LINKS THAT I NEED LATER.

\newcommand*\LTXcontentsline{}
\let\LTXcontentsline\contentsline
\usepackage[colorlinks=true, pdfstartview=FitV, linkcolor=blue, citecolor=blue, plainpages=false, pdfpagelabels=true, urlcolor=blue]{hyperref}




% FINALLY HERE WE ARE.

\begin{document}
\raggedright
\pagenumbering{roman}


\tableofcontents


% Because I added ``Table" and ``Figure" I have to redefine the
% emergency stretch
\setlength{\emergencystretch}{3.5em}
% before I add the \listoftables and \listoffigures




\listoftables
\listoffigures

% Now I can go back to what I had before.

\setlength{\emergencystretch}{2em}


\clearpage

\pagenumbering{arabic}


\setlength{\parindent}{0.5in}

\chapter{FIRST CHAPTER TITLE SOMETIMES CHAPTER TITLES GET REALLY LONG}

\lipsum[1]



\section{First chapter First section sometimes my sections will have really long titles such as this}

Here is a table.

\begin{table}[h]
\centering
\begin{tabular}{ccc}
\hline
Code 0 & Code 1 & Code 2 \\
\hline
\end{tabular}
\caption{\label{table:referencetothreecodes}Long caption for a table because I need to include enough words to describe the table data}
\end{table}

\subsection{First chapter first section first subsection and sometimes my subsections will also have really long titles}

\begin{table}[h]
\centering
\begin{tabular}{ccc}
\hline
Code 4 & Code 5 & Code 6 \\
\hline
\end{tabular}
\caption{\label{table:referencetothreemorecodes}Another table}
\end{table}

Here is another table, Table \ref{table:referencetothreemorecodes}.




\section{And you get the idea}

\begin{figure}[!h]
\begin{center}
[ - my image would go here - ]
\caption{\label{figureplot}Flow chart to determine one's recollection of {\LaTeX}-related misconceptions vs. consistentcy with lipsum[1] data}
\end{center}
\end{figure}


More text... and I also have figures:

\begin{figure}[!h]
\begin{center}
[ - my image would go here - ]
\caption{\label{figureplot}For my project I cannot have text run over five dots so I have to have special code for emergency stretch}
\end{center}
\end{figure}



\appendix


\chapter{YES MY APPENDICES ALSO HAVE LONG TITLES THE ISSUE THAT I AM HAVING IS THAT I NEED EXACTLY CONSISTENT DOUBLE SPACING}

\begin{table}[h]
\centering
\begin{tabular}{ccc}
\hline
Code A & Code B & Code C \\
\hline
\end{tabular}
\caption{\label{table:apreferencetothreeletters}Another table again}
\end{table}

Here is another table, Table \ref{table:apreferencetothreeletters}.


\chapter{BETWEEN EACH ENTRY AND WITHIN EACH ENTRY}

You get the idea.

\chapter{AND THE SPACING SHOULD BE THE SAME AS IN lipsum[1]}

etc.


\stepcounter{chapter}
\addtocontents{toc}{\protect\LTXcontentsline {chapter}{{Appendix \thechapter}. TITLE FOR A SPECIAL APPENDIX}{TEXT} }
\end{document}
Attachments
DSToCLoTLoF.pdf
(38.87 KiB) Downloaded 369 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

Post Reply