6

Both \the\prevgraf show zero. I expected it to show current line counter.

\documentclass[varwidth]{standalone}
\usepackage{expl3}
\begin{document}
  \parbox{40mm}
  { \parshape 3 0mm 40mm 5mm 35mm 10mm 30mm
    This is sentence 1. This is sentence 2.
    \the\prevgraf
    This is sentence 3. This is sentence 4.
    \par
  }
  \the\prevgraf
\end{document}

9

TeX cannot know the number of already typeset lines, when in the middle of a paragraph, for the simple reason it has not yet typeset it.

When a paragraph starts up, the value of \prevgraf is reset to 0; it is updated only when a paragraph or a “paragraph-so-far” has been split into lines (the latter case happens when a paragraph is interrupted by a displayed equation).

After a displayed equation is typeset, the value of \prevgraf is updated adding 3 to the value it was assigned when typesetting the “paragraph-so-far”.

Why does your last command show 0 as well? Because the paragraph was typeset in a group (the \parbox) and so the value of \prevgraf is forgotten as soon as the group ends.

\documentclass{article}

\begin{document}

  \parbox{40mm}
  { \parshape 3 0mm 40mm 5mm 35mm 10mm 30mm
    This is sentence 1. This is sentence 2.
    \[a=b\]
    \the\prevgraf
    This is sentence 3. This is sentence 4.
    \par
  \the\prevgraf
  }
\end{document}

enter image description here

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.