I need to compute the distance from the current baseline to the bottom of the next/current paragraph. (Eventually this is going to wind up in \everypar.) Is there an easier way to do this precisely?
See also How to preserve the same parskip in minipage
\documentclass{article}
\usepackage{lipsum}
\newlength\parsize
\newcommand{\testheight}[1]%
{\bgroup
\skip0=\parskip
\skip1=\parindent
\skip2=\leftskip
\skip3=\rightskip
\skip4=\parfillskip
\skip5=\baselineskip
\skip6=\lineskip
\ifdim\hfuzz<.4pt\relax\let\default=\fussy
\else\let\default=\sloppy
\fi
\sbox0{\parbox[t]{\columnwidth}{%
\parskip=\skip0
\parindent=\skip1
\leftskip=\skip2
\rightskip=\skip3
\parfillskip=\skip4
\baselineskip=\skip5
\lineskip=\skip6
\default #1}}%
\global\parsize=\dp0
\egroup}
\begin{document}
\rightskip=3in
\sloppy
\testheight{\lipsum[1]}
\noindent\llap{\smash{\rule[-\parsize]{1pt}{\parsize}} }
\hskip\parindent\lipsum[1]
\end{document}
The goal is not to draw the line. That was just a test to make sure it was working. My goal is to revise wrapfig using \pdfsavepos and adding some new options.
Postscript:
When I first switched from plain TeX to LaTeX, none of my old code using \vbox would work right. Early experiments indicated that there was no difference between \vbox, \hbox and \mbox, so I learned to make do with \parbox and tabular instead. It was only recently that I discovered that one could still use \vbox to stack \hboxes by inserting \\ between them and using \baselineskip=0pt. It should come as no surprise that \vbox now follows standard paragraph building rules.
\vboxinstead of a\parbox? – egreg Oct 06 '15 at 19:19tcolorbox– egreg Oct 06 '15 at 19:33\setbox0=\vtop{...}is definitely better, because it does not reset any parameter like\parboxdoes. – egreg Oct 07 '15 at 08:53