Showing posts with label TeX by Topic. Show all posts
Showing posts with label TeX by Topic. Show all posts

Friday, June 3, 2011

Inverted pyramid typesetting

University thesis committees are fairly well-known in the typesetting world for having the most absurd requirements. One example requires heading text to be typeset centered and no more than 4.5 in wide in which the lines become progressively shorter.

This is stupid. Still, I've got a solution, based on egreg's:
\newcommand\stupid[1]{%
        \vbox{%
                \hsize=4.5in
                \parindent=0pt
                \leftskip=0pt plus.5fil
                \rightskip=0pt plus-0.5fil
                \parfillskip=0pt plus1fil
                \emergencystretch=1in
                \parshape6
                0.00in 4.50in
                0.25in 4.00in
                0.50in 3.50in
                0.75in 3.00in
                1.00in 2.50in
                1.25in 2.00in
                \huge
                \bfseries
                \strut
                #1%
        }%
}
The \parshape specifies what to do for the first 6 lines by giving pairs of numbers. The first in the pair is the indentation and the second is the line length. The settings of \leftskip, \rightskip, and \parfillskip come from TeX by Topic and are used to center the last line.

Friday, January 7, 2011

Center last line in a paragraph

I'm not totally sure why one would want to center the last line in a paragraph, but the excellent TeX by Topic provides a surprising solution.
\leftskip=0pt plus.5fil
\rightskip=0pt plus-.5fil
\parfillskip=0pt plus1fil
The reason this works is that for all lines except for the last, the amount of stretch in the line is 0, so no skips are inserted. In the last line, the addition of the \parfillskip gives a skip of .5fil on the left and right so the line is centered.