[OS X TeX] writing twice to the same line

Samuel Lelievre samuel.lelievre.tex at free.fr
Sun Dec 13 20:13:07 CET 2009


My question 1 was a bit silly - the answer is just because
"leftbit" is shorter than "rightbit", hence no flaw there!

And to fix problem 2, one could introduce a negative space
after the leftbit to offset the title number extra length:
ask TeX the length of the title number, subtract that of a
one-digit title number (or not), and add \hspace*{-length}
where length is the length computed in this manner.

Finally, the use of clap isn't really necessary here, rlap
and llap are enough since we're not bothered by the center
bit having a nonzero length.  So, my solution to Florian's
question is pretty much the same as Herb's, whose commands
more or less redefine llap and rlap.  And I see Florian is
going for a solution that allows line breaks, which wasn't
going great in this approach.

SL

--
Date: Sun, 13 Dec 2009 19:13:35 +0100
From: Samuel Lelievre <samuel.lelievre.tex at free.fr>

Following my earlier post - an example ... and questions.

An example illustrating the use of \rlap, \clap and \llap
in section titles, to answer Florian's question.  I hoped
that would solve it perfectly, but I have to admit I note
the following flaws in the output:

1. In the titles produced this way, the spaces around the
center bit aren't quite equal - the one on the left being
slightly larger.

2. If section numbers get to 10, the center bit will move
slightly right - because the width for the section number
gets bigger and the width for the section title shorter.

Not sure how to explain (1) nor how to solve (2) - I'd be
interested in any hints!
SL


%%%%% rlap-clap-llap-in-sec-titles.tex %%%%%

\documentclass{article}

\usepackage[T1]{fontenc}
\usepackage{lmodern}

\usepackage{lipsum}

\def\clap#1{\hbox to 0pt{\hss#1\hss}}

\title{\texttt{\string\rlap}, \texttt{\string\clap}
and \texttt{\string\llap} in section titles}
\author{}
\date{}

\begin{document}
\pagestyle{empty}

\maketitle
\pagestyle{empty}

\section[]{\rlap{leftbit}\hfill\clap{centerbit}%
\hfill\llap{rightbit}}

\lipsum[65]

\section[]{\rlap{longer leftbit}\hfill\clap{centerbit}%
\hfill\llap{rightbit}}

\lipsum[66]

\section[]{\rlap{leftbit}\hfill\clap{longer centerbit}%
\hfill\llap{rightbit}}

\lipsum[75]

\section[]{\rlap{leftbit}\hfill\clap{centerbit}%
\hfill\llap{longer rightbit}}

\lipsum[101]

\end{document}




More information about the macostex-archives mailing list