3

Is there an option or package, to show the amount of stretching or shrinking TeX has done to justify each line? If there is none, how could this be implemented?

It should look like the black bars the draft option puts besides overfull lines, but with varying width corresponding to the amount of stretching or shrinking done. Shrink in the left margin, stretch in the right. The amount of available stretch and shrink might also be shown.

I often insert linebreaks \\ and recompile simply to see this, while fine-tuning the layout.

2
  • Which LaTeX engine to you use: pdfLaTeX, XeLaTeX, or LuaLaTeX? If LuaLaTeX, you may want to check out the lua-visual-debug package.
    – Mico
    Oct 11, 2013 at 21:18
  • I am using pdflatex currently. The package looks very nice. Maybe a reason to switch to LuaLatex. Oct 11, 2013 at 21:24

2 Answers 2

5

If switching from pdfLaTeX to LuaLaTeX is an option for you, you may want to do so in order to avail yourself of the lua-visual-debug package. As its name suggests, it provides all kinds of neat visual clues as to where rigid and variable-length spaces ("glues" in TeX parlance) occur, where explicit kerns are inserted, and which lines of text have average, loose, and tight interword spacing (marked with grey, blue, and pink bars).

enter image description here

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures={TeX,Common}]{EB Garamond}
\usepackage{lua-visual-debug,lipsum}
\usepackage{microtype}
\author{Peter Christen Asbjørnsen and Jørgen Moe}
\title{Dapplegrim}
\date{1890}
\frenchspacing
\begin{document}
\maketitle

Once on a time there was a rich couple who had twelve sons; but the youngest when he was grown up said he wouldn't stay any longer at home, but be off into the world to try his luck. His father and mother said he did very well at home, and had better stay where he was. But no, he couldn't rest; away he must and would go. So at last they gave him leave. And when he had walked a good bit, he came to a king's palace, where he asked for a place, and got it.

Now the daughter of the king of that land had been carried off into the hill by a Troll, and the king had no other children; so he and all his land were in great grief and sorrow, and the king gave his word that any one who could set her free should have the Princess and half the kingdom. But there was no one who could do it, though many tried.

So when the lad had been there a year or so, he longed to go home again and see his father and mother, and back he went; but when he got home his father and mother were dead, and his brothers had shared all that the old people owned between them, and so there was nothing left for the lad.

``Shan't I have anything at all, then, out of father's and mother's goods?'' said the lad.

``Who could tell you were still alive, when you went gadding and wandering about so long?'' said his brothers. ``But all the same; there are twelve mares up on the hill which we haven't yet shared among us; if you choose to take them for your share, you're quite welcome.''
\end{document}
2

Add \showoutput to your document and then a symbolic representation of the output is shown

Lines of text look typically like

..\vbox(548.5+0.0)x390.0, glue set 360.12822fil
...\hbox(8.33331+2.33331)x390.0, glue set 0.5529
...\hbox(8.33331+2.33331)x390.0, glue set - 0.191
...\hbox(8.33331+2.33331)x390.0, glue set - 0.3458
...\hbox(8.33331+2.33331)x390.0, glue set - 0.07698
...\hbox(8.33331+2.33331)x390.0, glue set - 0.43228
...\hbox(8.33331+2.33331)x390.0, glue set 139.01372fil

it is the glue set value that you are interested in. Note this is a measure of the factor by which glue is stretched rather than the difference between the natural width of the text without stretching, although that latter can also be calculated by looking at the box contents.

7
  • I wasn't able to lacate any documentation for \showoutput. It is a LaTeX 2e command, right? To make it more readable I tried to limit the outputted depth. Could this be transformed into a symbolic representation in the pdf document? Oct 11, 2013 at 21:42
  • @TobiasSimon you can limit the depth with \showboxdepth=2 It is a latex command, but just a very simple macro that turns on the primitive TeX box tracing. Oct 11, 2013 at 21:55
  • Thanks. That should prove useful. Now I "just" need to use something like \everyhbox and a whole lot of magic, to get the visual representation I wanted. No idea how, though Oct 11, 2013 at 22:24
  • @TobiasSimon \everyhbox tokens are not inserted into hboxes coming from the paragraph line breaker Oct 11, 2013 at 22:30
  • Ah. Then I'm lost again. Oct 11, 2013 at 22:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .