[texhax] LuaLaTeX: increase font expansion in narrow columns

Paul Isambert zappathustra at free.fr
Wed Oct 19 08:51:42 CEST 2011



Le 18/10/2011 23:15, Arno Trautmann a écrit :
> Hi all,
>
> I just read an article an a seemingly Word-typeset document with very 
> narrow columns when a picture was inserted between the columns. I 
> don't have to tell how ugly the result was …
>
> However, I got the idea that one could increase the quality of such 
> documents by increasing the amount of font expansion for very narrow 
> columns while keeping it at a lower amount for the rest of the document.
> Consider the following document:
>
> \documentclass[english,twocolumn]{scrartcl}
> \usepackage{babel,blindtext}
> \usepackage{microtype}
> \usepackage{wrapfig}
> \microtypesetup{stretch=50}
> \begin{document}
> \blindtext
> \begin{wrapfigure}{i}{4.5cm}
> \fbox{figure}
> \end{wrapfigure}
> \blindtext
> \end{document}
>
> Without the increased stretch, the word “This” will go to the next line.
>
> Now, two problems arise:
> • The amount of stretching cannot be changed in-document with the 
> normal user interface of the microtype package.

Stretchability and shrinkability depend on the font, not some part of 
the document, and you can't change that parameter of the font once it is 
set. So you'll have to load another font with bigger expansion.

> • I want to do this automatically – I was thinking of using the 
> pre_linebreak_filter for this in LuaLaTeX – but can I access the 
> linewidth of the to-be-typeset line?

\hsize minus \WidthOfTheFigure ? :)
Honestly, I don't see what you're going to do in pre_linebreak_filter.
Plus PDFTeX/LuaTeX can't use fonts with different expansions in the same 
paragraph. So I think you'd better try something in linebreak_filter 
itself (yes, the big one!), perhaps looping until you reach satisfying 
results with several paragraphs (one for the pre-image part, one for the 
narrow column, one for the part after).

> So – any comments on this? (Please postpone stylistic comments if this 
> is a good thing to do – first I want to try before judging if it looks 
> ugly ;) )

Ah, I can't resist: much simpler, and somewhat better looking (if only 
because it respects the integrity of the glyphs, and because we're more 
used to it), you can use heavy letterspacing in narrow column: grab 
narrow lines in post_linebreak_filter and add kerns between characters 
if necessary. That won't change justification, but that will relieve 
interword spacing a bit. I thought I'd put something like that on the 
wiki but apparently not, so you're welcome to share your code with the 
outside world :) Also, you can justify an entire paragraph with 
letterspacing simply by adding glues between each nodes in 
pre_linebreak_filter, but that's another story.

Best,
Paul




More information about the texhax mailing list