1

I am stuck with a very strict requirement to keep the space between chapter/sections/subsections/paragraph headers the same. After a chapter header, I need to have a triple space. After section headers, I need to have a double space. I have been able to do this, however, if I do not have additional text between a chapter title and the first section header, then the spaces add (triple space + double space). Is there a way to have an if statement acknowledges that if there is text, only use a triple space, whereas if the text is displayed, then use the double space?

\titlespacing{\chapter}{0in}{\UOneInChapterSpace}{\UHeadSpace}[0in] 
\titlespacing{\section}{0in}{0in}{\UDoubleSpace}[0in]
\titlespacing{\subsection}{0in}{0in}{\UDoubleSpace}[0in]
\titlespacing{\subsubsection}{0in}{0in}{\UDoubleSpace}[0in]
\titlespacing{\paragraph}{1em}{1ex}{1ex}[1em]

\titleformat{\chapter} [display] {\color{URED}\centering\normalfont\Large\bfseries\doublespacing} {\MakeUppercase{\chaptertitlename} \Large\thechapter} {0in} {\MakeUppercase} []

\titleformat{\section} [hang] {\centering\singlespacing\normalfont\Large\bfseries} {\thesection} {1ex} {} []

\titleformat{\subsection} [hang] {\centering\singlespacing\normalfont\large\bfseries} {\thesubsection} {1ex} {} []

\titleformat{\subsubsection} [hang] {\centering\singlespacing\normalfont\normalsize\bfseries} {\thesubsubsection} {1ex} {} []

\titleformat{\paragraph} [runin] {\centering\singlespacing\normalfont\normalsize\bfseries} {\theparagraph} {1ex} {} []

\titleformat{\subparagraph} [runin] {\centering\singlespacing\normalfont\normalsize\bfseries} {\thesubparagraph} {1ex} {} []

I posted a previous question that has the entire cls file (Link). I'm just not sure how to do this.

Thank you!

  • Pleas see my answer to your previous question https://tex.stackexchange.com/a/597520/161015 – Simon Dispa May 17 '21 at 23:46
  • Are you using \documentclass{MastersDoctoralThesis} ? – Simon Dispa May 18 '21 at 13:24
  • Yes, I am using the class file mentioned in the link. I was the one who wrote it but was just not sure how to address this spacing issue. – Christopher Creveling May 18 '21 at 18:31
  • Ohh! I was preparing an answer for the preamble. Now I will see how to modify the class. – Simon Dispa May 18 '21 at 19:18
  • Thank you so much! This was the first class file I have written so if there is any advice you have regarding it please let me know. I've been scouring various StackOverflow comments the past year to get to where I am now. – Christopher Creveling May 18 '21 at 19:23
  • 1
    Did my answer to your former question helped? It was a nice challenge to find where the extra space was coming from. – Simon Dispa May 18 '21 at 19:24
  • After reading through your answer that did make sense why the additional space was showing up. I just haven't had a chance to implement it into my actual project. There are over 50 figures so I wasn't sure if I needed to add the local fix to each image. – Christopher Creveling May 18 '21 at 19:28
  • It is not needed. The problem is the addvspace in \AtBeginEnvironment{figure}{\addvspace{\UHeadSpace}} and similars. – Simon Dispa May 18 '21 at 19:56
  • Please see the updated answer to your former question – Simon Dispa May 19 '21 at 15:30

1 Answers1

1

You might incorporate these setting to your class. The grid is set to \baselineskip at doublespace. No extra space appears after title and section if there is no text.

%%***************************************************** titlespacing starts
\newlength{\Beforesec}
\setlength{\Beforesec}{2ex}
\newlength{\Aftersec}
\setlength{\Aftersec}{1ex}

\setlength{\UOneInChapterSpace}{-45pt + 1in} \setlength{\UHeadSpace}{3\baselineskip} \setlength{\UDoubleSpace}{2\baselineskip}

\titlespacing{\chapter}{0in}{\UOneInChapterSpace}{\UHeadSpace+\Beforesec}[0in] \titlespacing{\section}{0in}{\Beforesec}{\UDoubleSpace+\Aftersec}[0in] \titlespacing{\subsection}{0in}{0in}{0.5\UDoubleSpace}[0in] \titlespacing{\subsubsection}{0in}{0in}{0.5\UDoubleSpace}[0in] \titlespacing{\paragraph}{1em}{1ex}{1ex}[1em] %%***************************************************** titlespacing ends

Section after title without text in between

w

Text after title

z

Test this code

% !TeX TS-program = pdflatex

\documentclass{MastersDoctoralThesis}

\usepackage{eso-pic} \AddToShipoutPictureBG{% GRID \begin{tikzpicture}[remember picture, overlay, help lines/.append style={line width=0.05pt, color=white}, major divisions/.style={help lines,line width=0.5pt, color=blue!40} ] \draw[help lines] (current page.south west) grid[step=0.5pt] (current page.north east); \draw[major divisions] (current page.south west) grid[step=22pt] % baselineskip = 22pt at double space (current page.north east); \end{tikzpicture}% }

%%***************************************************** titlespacing starts \newlength{\Beforesec} \setlength{\Beforesec}{2ex} \newlength{\Aftersec} \setlength{\Aftersec}{1ex}

\setlength{\UOneInChapterSpace}{-45pt + 1in} \setlength{\UHeadSpace}{3\baselineskip} \setlength{\UDoubleSpace}{2\baselineskip}

\titlespacing{\chapter}{0in}{\UOneInChapterSpace}{\UHeadSpace+\Beforesec}[0in] \titlespacing{\section}{0in}{\Beforesec}{\UDoubleSpace+\Aftersec}[0in] \titlespacing{\subsection}{0in}{0in}{0.5\UDoubleSpace}[0in] \titlespacing{\subsubsection}{0in}{0in}{0.5\UDoubleSpace}[0in] \titlespacing{\paragraph}{1em}{1ex}{1ex}[1em] %%***************************************************** titlespacing ends

\begin{document} \mainMatter %% sets\doublespacing

\chapter[\uppercase{Multiline title}]{\uppercase{Multiline \protect \ title}} 1 \lipsum[1] \section{Section1} 2 \lipsum[2] \section{Section2} \section{Section3} \section{Section4} 3 \lipsum[3] \subsection{Subsection1} 4 \lipsum[4]
\subsection{Subsection2}
\subsection{Subsection3}
\subsection{Subsection4} 5 \lipsum[5]
\paragraph{Paragraph1} 6 \lipsum[6]
\paragraph{Paragraph2} \paragraph{Paragraph3} \paragraph{Paragraph4} 7 \lipsum[7] \end{document

Simon Dispa
  • 39,141
  • That is so close. However, I'm still getting slightly more space between a chapter title and no text before a section header than a chapter title with text before the section header. Using SumatraPDF it appears that there is an additional 0.9 in space before the section header when I set all spaces to 0\baselineskip. Would you by chance know how to fix that? – Christopher Creveling May 20 '21 at 23:39
  • @Christopher Creveling LaTeX does not typeset on a grid. There are al lot of glue space in that page to make nice paragraphs instead. See https://tex.stackexchange.com/a/405237/161015 – Simon Dispa May 21 '21 at 12:43