0

I'm writing a series of notes, and I've begun to see the vertical (line) spacing of certain paragraphs to substantially decrease compared to others. I've attached a photo to describe what I mean. The text immediately following Exercise 6.12 and the stars is much more scrunched up than the text in the paragraph following the verbatim environment. Does anyone know why, and how I can prevent it? Note that the exercise command just receives a number, the chapter identifier, and the text-to-use.

enter image description here

\newcommand{\exercise}[3]
{\noindent\textbf{Exercise {~\ref{#2}}.\theexcounter.} (\repeatstar{#1}) \\
{#3} \stepcounter{excounter}}
...
\exercise{3}{chapter-advanced-oop}{This exercise involves the interpreter we wrote in the chapter.}
Data structures are a core and fundamental feature of programming languages. A language without them, or at least one to build others on top of, suffers severely in terms of usability. We will implement a \textit{cons}-like data structure for our interpreter. In functional programming, we often use three operations to act on data structures akin to linked lists: \textit{cons}, \textit{first}, and \textit{rest}, to construct a new list, retrieve the first element, and retrieve the rest of the list respectively. We can inductively define a cons list as follows:
\begin{footnotesize}
\begin{verbatim}
A ConsList is one of:
 - new ConsList()
 - new ConsList(x, ConsList)
\end{verbatim}
\end{footnotesize}
Implement the cons data structure into your interpreter. This should involve designing the \ttt{ConsNode} class that conforms to the aforementioned data definition. Moreover, you will need to update \ttt{PrimNode} to account for the \ttt{first} and \ttt{rest} primitive operations, as well as an \ttt{empty?} predicate, which returns whether or not the cons list is empty. Finally, update the \ttt{Lvalue} class to print a stringified representation of a \ttt{ConsNode}, which amounts to printing each element, separated by spaces, inside of brackets, e.g., \ttt{[$l_0, l_1, ..., l_{n-1}]$}.
TheProgrammer
  • 404
  • 2
  • 11

1 Answers1

2

(La)TeX "freezes" several characteristics of a paragraph when the paragraph ends. One of these is the baseline separation.

You have not ended the previous paragraph when starting a new block of text in footnotesize, and the paragraph ends in that smaller size. Thus the baseline distance for the entire paragraph is suitable for that type size.

And as noted by @DavidCarlisle, footnotesize is not an environment; however, it will behave as if it is, and since environments usually end with a built-in paragraph break, the smaller baseline ends there.

You can rescue this example by revising it to use \par{\footnotesize \begin{verbatim} ... \end{verbatim}}.

  • That's interesting that it's not designed to be an environment. Thanks for the fix! – TheProgrammer Nov 29 '23 at 01:06
  • You missed out the main case here, you need a \par before the { (or before the \begin{footnotesize} it's that causing the text above to scrunch, a \par at the end won't help. as verbatim already does \par. – David Carlisle Nov 29 '23 at 01:20
  • @DavidCarlisle -- Okay, I didn't test (and should have). Fixed (and repentant). – barbara beeton Nov 29 '23 at 01:25
  • better:-)....... – David Carlisle Nov 29 '23 at 01:25
  • @DavidCarlisle That's really bizarre, because this seemed to have fixed it, but perhaps that was only in one lone occurrence of the problem... I had 83 separate \begin{footnotesize}\begin{verbatim}...\end{verbatim}\end{footnotesize} environments, so it's possible that I just didn't notice the fix across them all. – TheProgrammer Nov 29 '23 at 02:28