Left-align the attribution for a quotation if it is more than a full line long

Left-align the attribution for a quotation if it is more than a full line long

This question is closely related to How can I right-align a quotation attribution, on the same line as the quotation if possible I am currently using the TeXBooks excellent solution, among those described in that question, except for a minor change in spacing a 1em gap between the quotation and the attribution instead of 2em: defattr1unskipnobreakhfilpenalty50 hskip1emhboxnobreakhfilitshape---1 parfillskip0pt finalhyphendemerits0 par However, an additional problem has arisen: I am setting this text in two columns, and some attributions end up breaking onto multiple lines. This tends to look silly right-aligned: In general, I would much rather have the attribution begin left-aligned on a new line, should it require more than one line: I need an automated solution because Im generating the text programmatically. I will be doing some manual tweaking afterwards, but as Im typesetting over 10,000 of these entries, anything that can be done to get most of them right automatically is a huge time-saver.

Heres my shot at it, using etoolbox and calc: usepackageetoolbox usepackagecalc newlengthattrlength defattr1 setlengthattrlengthwidthof1 ifdimcompattrlengthcolumnwidth shortattr1 longattr1 defshortattr1unskipnobreakhfilpenalty50 hskip1emhboxnobreakhfilemph---1 parfillskip0pt finalhyphendemerits0 par newcommandlongattr1parnoindentemph---1 newcommandlongattrnobreak1hspace1ememph---1 We set attrlength to the width of the argument which is the text we want to set as the attribution, then if its less than the width of a column we use the TeXBooks macro described in the question; otherwise we start a new paragraph and set the text there. The final macro, longattrnobreak, is used in cases where the entry looks better when the attribution starts on the same line as the quote but is left-aligned thereafter: I cant think of a clean, easy-to-implement heuristic for this from my five minutes thinking about it, it involves both the width of the last line of the quotation and the width of the last line of the attribution, plus how that lines width compares to the one above it, so Ill choose this one manually at proof time if the automatic choice of the first two options looks bad.

Комментарии

Популярные сообщения из этого блога

Skipping acquire of configured file 'contrib/binary-i386/Packages' as repository … doesn't support architecture 'i386'

Connection string for MariaDB using ODBC

Celery like system based on django channels