1

I've been experimenting with determining the height of lines by using \vsplit to break up a paragraph. I've set pretty much every penalty associated with page breaking to 0. It's not the end of the world if it can't be split off, but I'd like to know why.

\documentclass{article}
\usepackage{amsmath}

\newcounter{count}
\newlength{\size}
\newlength{\total}
\newlength{\prev}

\begin{document}

\setbox0=\vbox{This is the first line of a paragraph, so there is a penalty for
splitting here.  This is the line before a display, so ditto.
\begin{equation}
x=a
\end{equation}
Everything should return to normal now.}

\noindent\usebox0

\bigskip
\total=\ht0
\advance\total by \dp0
total height = \the\total

\clubpenalty=0
\widowpenalty=0
\displaywidowpenalty=0
\predisplaypenalty=0
\postdisplaypenalty=0
\interlinepenalty=0

\total=0pt
\loop\prev=\dimexpr \ht0+\dp0\relax
  \setbox1=\vsplit0 to \baselineskip
  \stepcounter{count}%
  \size=\dimexpr \prev-\ht0-\dp0\relax
  \advance\total by \size
  \thecount{ = }\the\size\par 
  \ifdim\ht0>0pt\repeat

total height = \the\total

\end{document}
3
  • 2
    You have to set the penalties before building the box – egreg Feb 20 '16 at 23:27
  • \noindent\begin{document] ? – David Carlisle Feb 21 '16 at 1:31
  • @DavidCarlisle -Oops, partial edit. – John Kormylo Feb 21 '16 at 3:21
2

enter image description here

the penalties are part of the box structure, so changes after the box is set have no effect, setting them earlier produces four lines rather than 3.

\documentclass{article}
\usepackage{amsmath}

\newcounter{count}
\newlength{\size}
\newlength{\total}
\newlength{\prev}

\begin{document}


\clubpenalty=0
\widowpenalty=0
\displaywidowpenalty=0
\predisplaypenalty=0
\postdisplaypenalty=0
\interlinepenalty=0

\setbox0=\vbox{This is the first line of a paragraph, so there is a penalty for
splitting here.  This is the line before a display, so ditto.
\begin{equation}
x=a
\end{equation}
Everything should return to normal now.}

\usebox0

\bigskip
\total=\ht0
\advance\total by \dp0
total height = \the\total

\total=0pt
\loop\prev=\dimexpr \ht0+\dp0\relax
  \setbox1=\vsplit0 to \baselineskip
  \stepcounter{count}%
  \size=\dimexpr \prev-\ht0-\dp0\relax
  \advance\total by \size
  \thecount{ = }\the\size\par 
  \ifdim\ht0>0pt\repeat

total height = \the\total

\end{document}

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.