6

I would like to get the current line width in a \parshape environment.

The following variables return the full page width (345pt), where I would expect 300pt:

\documentclass{report}

\usepackage{lipsum}

\begin{document} 

\parshape=5
0pt 300pt
0pt 300pt
0pt 300pt
0pt 300pt
0pt 300pt
\noindent\the\textwidth\\ \the\linewidth\\ \the\columnwidth\\ \the\hsize\\\lipsum[1]

\end{document}

enter image description here

How can I get the expected (size) value?

  • 1
    The text width is not available anyway while the paragraph is being typeset, because TeX decides which word goes in which line only after the paragraph has ended. – egreg May 6 '16 at 10:46
  • @egreg. Thanks for your answer. I have "solved" my problem by looking for linebreaks, measuring lines individually and then comparing them to the "expected" width (set in parshape). This works okay to draw a colored trapezium behind the text at the appropriate width. – Alexed May 17 '16 at 9:47
6

You may use the e-TeX provided primitives1

\parshapeindent
\parshapelength,

each of them followed by an integer, to access the indent and length of lines under the current \parshape specification, but it's impossible to know what's the line length or indent pertaining to the line where a word will appear, because that's decided on much later, when TeX has applied its algorithm for splitting the paragraph into lines. In other words, there's no notion of “the current line”. Examples can be made of paragraphs where changing one word can lead to largely different line breaks.


1 e-TeX extensions are available when LaTeX is used (at least on TeX system releases from about 2004 on).

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.