The spacing is not uniform for exactly the same reason why you need the \par
before exiting the \footnotesize
section: a paragraph is typeset with only one baseline skip, the one which is in force when the paragraph ends.
If you leave out the \par
, a \par
is seen at the empty line following the closing brace, when the \footnotesize
setting has been undone. With the \par
, also the first line is typeset with the \footnotesize
baseline skip.
What's a way out? Use \par
also to separate the first line from the rest (and \nobreak
to avoid a page break):
\documentclass{memoir}
\begin{document}
{
\parindent0pt
\setlength{\parskip}{\baselineskip}
1. Setup:\par\nobreak\vspace{-\parskip}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
2. Core steps:\par\nobreak\vspace{-\parskip}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
3. Wrapping up:\par\nobreak\vspace{-\parskip}
{\footnotesize
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material}
\par}
4. Final steps:\par\nobreak\vspace{-\parskip}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
}
\end{document}
The \vspace{-\parskip}
is necessary because of the \parskip
setting.
What if there is no "introductory line"? Use a strut outside the group (it's an invisible, zero width object that ensures uniform space. The strut is recomputed when a size changing command is issued, but putting it outside the group (or just before \footnotesize
) will ensure it is the one for the normal size:
\documentclass{memoir}
\begin{document}
{
\parindent0pt
\setlength{\parskip}{\baselineskip}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
\strut{\footnotesize
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material}
\par}
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
}
\end{document}
A \strut
in the same position may or may not be needed also in the first form; it depends on the visual interaction between the normal size line and the following with small type size.
Notice that I used \setlength
rather than \addtolength
, so as not to make assumptions about the actual value of \parskip
. It may be better to add some flexibility to it:
\setlength{\parskip}{1\baselineskip plus 2pt minus 1pt}
to help TeX form a good page; the spaces between the blocks will be the same: all of them will be stretched or shrunk by the same amount.
However, I'd prefer to insert explicit spaces rather than relying on the automatic \parskip
, maybe using some macro or environment.
Without the
\parindent0pt
\setlength{\parskip}{\baselineskip}
you could do
\documentclass{memoir}
\begin{document}
\noindent 1. Setup:\par\nobreak\noindent
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
\bigskip
\noindent 2. Core steps:\par\nobreak\noindent
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
\bigskip
\noindent 3. Wrapping up:\par\nobreak\noindent
\strut{\footnotesize
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material} \\
\textit{some really long technical formula-like material}\par}
\bigskip
\noindent 4. Final steps:\par\nobreak\noindent
\textit{some technical formula-like material} \\
\textit{some technical formula-like material} \\
\textit{some technical formula-like material}
\end{document}
Notice the \bigskip
to get the spacing between blocks. I've kept the initial strut for the "small type" block, in order to avoid that the lines are too near to each other. (As above, the strut would also be necessary if there were no "introductory lines".)
COMMENTS ON LATEST EDIT:
In response to Mr. Clark's stipulation that he didn't like the \vskip
s, those have been successfully removed. Further, all spacings are issued through the titlesec
package and are now specified in terms of \baselineskip
, which should provide more flexigility for fontsize changes. Significant changes in this edit were several. First, changing the titlesec format from "display" to "hang" accomplished a great deal. However, the issue of \lineskiplimit
proved to be decisive. The \boxedsection
command created by Jeff was of a size not close to an even multiple of \baselineskip
and so LaTeX kept adding a line to correct a perceived problem. Setting the line-skip-limit to a more negative value resolved the issue. And it allowed me to use just the titlesec
parameters to achieve the result, without any vspaces.
Nonetheless, there remained the issue of glue, to which I alluded in one of the comments. I was largely able to remedy it by setting \parskip
to 0 and setting \textfloatsep
so that it couldn't grow (I'm not wholly sure I'm using that command properly). However, a super-zoom on the flushed section headings can still occasionally perceive some glue-gap.
Maybe there's another glue parameter that can help.
COMMENTS ON AN EARLIER EDIT:
In response to the comment that there probably needs to be no separate commands used for the flushed sub- and subsub-section headings, I have remedied that problem, with one proviso. The method works by counting how many \par
s have been issued after the higher-level section invocation. It starts by assuming you have a flush-heading sub*section. Then it starts counting \pars
. Once it reaches a critical number, it concludes that you have added text to the section , and changes the \sub*section
heading for the next lower heading level. Therefore, the user must be consistent in how they add text to a section. Currently, the triggers are set up for the following structure
\section{name}
<blank line>
text
<blank line>
\subsection{name}
<blank line>
text
<blank line>
\subsubsection{name}
or for flush headings
\section{name}
<blank line>
\subsection{name}
<blank line>
\subsubsection{name}
Thus, there remains the requirement for the user to type his section headings consistently. And because of the feature of texexchange to squeeze blank lines out of listings, the needed blank lines in the body do not show up in the below listing.
\documentclass{scrbook}
\usepackage[letterpaper,asymmetric,left=108pt,right=54pt,top=41pt,bottom=41pt,headsep=13pt,headheight=14pt,footskip=23pt,marginparwidth=72pt]{geometry}
\usepackage[compact,explicit,calcwidth]{titlesec}
\usepackage{tikz,lipsum}
\usetikzlibrary{calc}
\usepackage{ifthen}
%
\usepackage{setspace}\onehalfspacing
%
\setkomafont{sectioning}{\normalfont}
%
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
%
\newlength\titlemarginwidth
\setlength\titlemarginwidth{54pt}
%
\newcommand\boxedsection[6]{{%
\usekomafont{sectioning}\usekomafont{#2}%
\begin{tikzpicture}[inner sep=0, inner ysep=0.7ex, node distance=0]%
\node[anchor=base west,rectangle,text
width=\titlemarginwidth-\columnsep-1pt,color=#3] at (0,0) (numnode)
{\vphantom{yZ}\hspace{1ex}#6};%
\node[anchor=base west,rectangle,text width=\textwidth-.5pt] at
($(numnode.base east)+(\columnsep,0)$) (textnode) {\vphantom{yZ}#1};%
\begin{pgfonlayer}{background}%
\fill[color=#4] (0,0|-numnode.north) rectangle (numnode.south
east|-textnode.south east);%
\draw[#5,semithick] (0,0|-numnode.north) -- (textnode.north
east);%
\draw[#5,semithick] (0,0|-textnode.south west) -- (textnode.south
east);%
\end{pgfonlayer}%
\end{tikzpicture}%
}}%
\newcommand\flushboxedsection[6]{{%
\usekomafont{sectioning}\usekomafont{#2}%
\begin{tikzpicture}[inner sep=0, inner ysep=0.7ex, node distance=0]%
\node[anchor=base west,rectangle,text
width=\titlemarginwidth-\columnsep-1pt,color=#3] at (0,0) (numnode)
{\vphantom{yZ}\hspace{1ex}#6};%
\node[anchor=base west,rectangle,text width=\textwidth-.5pt] at
($(numnode.base east)+(\columnsep,0)$) (textnode) {\vphantom{yZ}#1};%
\begin{pgfonlayer}{background}%
\fill[color=#4] (0,0|-numnode.north) rectangle (numnode.south
east|-textnode.south east);%
\draw[#5,semithick] (0,0|-textnode.south west) -- (textnode.south
east);%
\end{pgfonlayer}%
\end{tikzpicture}%
}}%
%
\titlespacing*{\chapter}{-0.7\titlemarginwidth}{50pt}{40pt}
\titleformat{\chapter}[hang]%
{\usekomafont{sectioning}\usekomafont{chapter}}%
{\emph{\chaptertitlename\ \thechapter}}%
{0em}%
{\emph{#1}}%
\titlespacing*{\section}{-\titlemarginwidth}{.6\baselineskip}{*0}%
\titleformat{\section}[hang]%
{\setstretch{1.6}}%
{}{0pt}{\boxedsection{#1}{section}{white}{black}{black}{\thesection}%
}
\def\tsubsectionbox{%
\titlespacing*{\subsection}{-\titlemarginwidth}{.8\baselineskip}{*0}%
\titleformat{\subsection}[hang]%
{}%
{}{0pt}{%
\boxedsection{##1}{subsection}{black}{gray!30}{black}{\thesubsection}}%
}
%
\def\fsubsectionbox{%
\titlespacing*{\subsection}{-\titlemarginwidth}{*0}{.2\baselineskip}%
\titleformat{\subsection}[hang]%
{\setstretch{1.38}}%
{}{0pt}{%
\flushboxedsection{##1}{subsection}{black}{gray!30}{black}{\thesubsection}}%
}
%
\newcounter{subparcounter}
\let\savesection\section
\def\section{\fsubsectionbox\setcounter{subparcounter}{0}\savesection}
%
\def\tsubsubsectionbox{%
\titlespacing*{\subsubsection}{-\titlemarginwidth}{.8\baselineskip}{*0}%
\titleformat{\subsubsection}[hang]%
{}%
{}{0pt}{%
\boxedsection{##1}{subsubsection}{black}{white}{black}{\thesubsubsection}}%
}
%
\def\fsubsubsectionbox{%
\titlespacing*{\subsubsection}{-\titlemarginwidth}{*0}{0\baselineskip}%
\titleformat{\subsubsection}[hang]%
{\setstretch{1.1}}%
{}{0pt}{%
\flushboxedsection{##1}{subsubsection}{black}{white}{black}{\thesubsubsection}}%
}
%
\newcounter{subsubparcounter}
\let\savesubsection\subsection
\def\subsection{\fsubsubsectionbox\setcounter{subsubparcounter}{0}%
\savesubsection}
%
\let\savepar\par
\def\par{%
\savepar%
\addtocounter{subsubparcounter}{1}%
\addtocounter{subparcounter}{1}%
\ifthenelse{5 = \value{subsubparcounter}}%
{\tsubsubsectionbox}%
{}%
\ifthenelse{5 = \value{subparcounter}}%
{\tsubsectionbox}%
{}%
}%
%
% SEE: http://www.tug.org/TUGboat/tb28-1/tb88bazargan.pdf
\lineskiplimit = -12pt % <--MAY NEED TO BE MADE MORE NEGATIVE!
\parskip 0ex
\setlength{\textfloatsep}{20pt plus 0pt minus 4pt}
%
\begin{document}
\chapter{Test}
\section{Section}
\lipsum[2]
text
\subsection{Subsection}
Text
\subsubsection{Subsubsection}
Text
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
Text
\section{Section}
Text
\subsection{Subsection}
Text
\subsubsection{Subsubsection}
Text
\lipsum[2]
\section{Section}
\lipsum[2]
text
\subsection{Subsection}
Text
\subsubsection{Subsubsection}
Text
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
Text
\section{Section}
Text
\subsection{Subsection}
Text
\subsubsection{Subsubsection}
Text
\lipsum[2]
\section{Section}
\lipsum[2]
text
\subsection{Subsection}
Text
\subsubsection{Subsubsection}
Text
\section{Section}
\subsection{Subsection}
\subsubsection{Subsubsection}
Text
\section{Section}
\subsection{Subsection}
Text
\subsubsection{Subsubsection}
Text
\lipsum[2]
\end{document}
Best Answer
LaTeX treats text on a page very differently according to its spacing options. Some classes want LaTeX to fill out the white space on a page best possible, others want it to just keep the text where it is.
The two main options are:
\flushbottom
: in-/decreases text spacing as needed to fill page,\raggedbottom
: there is no "correction" of text spacingYou will need option
\raggedbottom
to ensure that paragraph spacing is equal at all points (and on all pages).