如何获取段落最后一个框的自然宽度?

如何获取段落最后一个框的自然宽度?

我想获取段落最后一行的自然宽度。例如,以下段落的最后一行

格奥尔格·弗里德里希·伯恩哈德·黎曼(1826 年 9 月 17 日 - 1866 年 7 月 20 日)是一位颇具影响力的德国数学家,他对分析、数论和微分几何做出了持久的贡献,其中一些贡献促进了后来广义相对论的发展。

可能是从somerelativity(即some of them enabling the later development of general relativity.)当发生换行时,最后一行将被放入一个hbox中,那么,我如何才能获得这个hbox?

答案1

在此处输入图片描述

\documentclass{article}

\begin{document}

Georg Friedrich Bernhard Riemann (September 17, 1826 -- July 20, 1866) was an
influential German mathematician who made lasting contributions to analysis, number
theory, and differential geometry, some of them enabling the later development of
general relativity.
$$\mbox{the last line had length \the\predisplaysize}$$

\end{document}

实际上\predisplaysize设置为比自然尺寸大 2em,因此您可能需要减去 2em,具体取决于...


为了在不留下可见显示数学的情况下获取值,您可以执行如下操作(复制自afterpage

\makeatletter
Georg Friedrich Bernhard Riemann (September 17, 1826 -- July 20, 1866) was an influential German mathematician who made lasting contributions to analysis, number theory, and differential geometry, some of them enabling the later development of general relativity.
{\abovedisplayshortskip\z@\abovedisplayskip\z@
    \belowdisplayshortskip\z@\belowdisplayskip\z@
$$\global\dimen\@ne\predisplaysize
 \xdef\tmp{%
      \predisplaysize\the\predisplaysize
      \prevgraf\the\prevgraf\relax}%
$$\vskip\dimexpr-\parskip-\baselineskip\relax}\tmp

new para in which we can use \the\dimen\@ne


and another new para

相关内容