1

Is there a way to get the exact spacing between different parts of a document?

I know the question may sound a bit vague, so here's the context in which the question arose.

Here there is a code snippet to let ntheorem split a long theorem name in multiple lines. The code seems to be working fine, but introduces an extra spacing after the theorem name. On the other hand I tried to redefine the break theoremstyle using parbox. The spacing appears the same as in the default case but is smaller in case the theorem name is longer than a line. Here's a MWE of what I'm talking about

\documentclass[11pt]{article}
\usepackage[framed,thmmarks,thref, hyperref]{ntheorem}

\theoremstyle{break}
\theoremseparator{:}
\newtheorem{testt}{theorem}

\begin{document}


\begin{testt}[default style]
    body
\end{testt}

\makeatletter
\let\nobreakitem\item
\let\@nobreakitem\@item
\patchcmd{\nobreakitem}{\@item}{\@nobreakitem}{}{}
\patchcmd{\nobreakitem}{\@item}{\@nobreakitem}{}{}
\patchcmd{\@nobreakitem}{\@itempenalty}{\@M}{}{}
\patchcmd{\@xthm}{\ignorespaces}{\nobreak\ignorespaces}{}{}
\patchcmd{\@ythm}{\ignorespaces}{\nobreak\ignorespaces}{}{}

\renewtheoremstyle{break}%
  {\item{\theorem@headerfont
          ##1\ ##2\theorem@separator}\hskip\labelsep\relax\nobreakitem}%
  {\item{\theorem@headerfont
          ##1\ ##2\ (##3)\theorem@separator}\hskip\labelsep\relax\nobreakitem}
\makeatother

\begin{testt}[short name]
     solution I found online
\end{testt}

\begin{testt}[very very very very very very long theorem name, should be longer than one line]
     solution I found online
\end{testt}

\makeatletter
\renewtheoremstyle{break}%
  {\item[\rlap{\vbox{\hbox{\hskip\labelsep \theorem@headerfont
          ##1\ ##2\theorem@separator}\hbox{\strut}}}]}%
  {\item[\parbox{\textwidth}{\leftskip\labelsep \theorem@headerfont
          ##1\ ##2\ (##3)\theorem@separator}\hbox{\strut}]}
\makeatother

\begin{testt}[short name]
     my solution
\end{testt}

\begin{testt}[very very very very very very long theorem name, should be longer than one line]
     my solution
\end{testt}

\end{document}

And here is the results. enter image description here

Now, I don't want to say "ok the spacing looks the same/looks different" but rather "ok the spacing is the same/is different". Is there a way to get the exact spacing between the lines without having to guess it?

3
  • In general, you want some variation because stretchy glue is what TeX uses to get good breaks. Otherwise, you end up with ugly spaces, breaks etc. So, mostly, spaces should not be defined as rigid lengths, but should include a bit of give either way. The result of this is that the spacing will not be precisely the same throughout by design, However, I'm not sure this is what you mean.
    – cfr
    Sep 24 '17 at 1:35
  • @cfr thanks for your comment. I know in general TeX uses glues and flexible spacings to get a good result. My problem is: after I typeset a document there are spaces that look similar but may or may not be equal. E.g. consider the spacing between the header and the body in thm 1 and thm 4. So I am looking for a way to get the nominal space between these elements, something like a method that tells me "the space here is 1.2ex", so that I can be sure that two spaces are exactly the same and don't just look similar. I know very little of TeX programming, so I'm not even sure if this is possible.
    – Manlio
    Sep 25 '17 at 9:14
  • Why? Why do you not want glue, if you know that is needed for a good result? Is this some institutional requirement for a bad result?
    – cfr
    Sep 26 '17 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.