Jesteś w: Start / Przedsięwzięcia/Projects / TeX Pearls / 2007 Pearls / marcin-wolinski / bachotex2007-marcin-wolinski-pearl2.tex

bachotex2007-marcin-wolinski-pearl2.tex

TeX document icon bachotex2007-marcin-wolinski-pearl2.tex — TeX document, 2 KB (2266 bytes)

Zawartość pliku

%%% Do you need some stretch?

% \TeX's \leaders primitive can be used to fill arbitrary space with a
% stretchable line (cf.\ \hrulefill).  It is also possible to have an
% expandable triple line:

\def\triplefil{%
  \leaders\hrule height4pt depth-3.2pt\hfil \hskip0pt plus-1fil
  \leaders\vrule height1.6pt depth0pt\hfil \hskip0pt plus-1fil
  \leaders\vrule height-.6pt depth1pt\hfil }
\def\triplefilledline#1{%
  \hbox to\hsize{%
    \vrule height4ptdepth3ptwidth.8pt \triplefil \vrule
    height10ptdepth1ptwidth.4pt \enspace\strut#1\enspace \vrule
    height10ptdepth1ptwidth.4pt \triplefil \vrule
    height4ptdepth3ptwidth.8pt } }

\bigskip
\triplefilledline{The St.\ Anford Orchestra}

\bigskip
\triplefilledline{Variations on a Theme by Tchaikovsky}

% To understand what happens here one needs to count stretchability of leaders
% and glue in \triplefil.  It is: 1fil (from \hfil) + $-1$fil (from \hskip) +
% 1fil + $-1$fil + 1fil, which sums up to 1fil.  So when \TeX\ needs to set
% \triplefil to, say, 37pt it stretches each fil of glue to that length.  The
% first leaders become 37pt wide, then comes \hskip to $-37$pt ($-1$fil), and
% so \TeX\ overprints the second \leaders on the first, and the same repeats
% with the next glue and leaders.

% This trick opens space for countless variations:

\def\lquadruple{%
    \leaders\hrule height6.2pt depth-6pt\hskip0ptplus3fil
    \hskip0pt plus-2fil
    \leaders\vrule height4.2pt depth-4pt\hskip0ptplus3fil
    \hskip0pt plus-2fil
    \leaders\vrule height2.2pt depth-2pt\hskip0ptplus3fil
    \hskip0pt plus-2fil
    \leaders\vrule height0.2pt depth0pt\hskip0ptplus3fil
}
\def\rquadruple{%
    \leaders\vrule height0.2pt depth0pt\hskip0ptplus3fil
    \hskip0pt plus-2fil
    \leaders\vrule height2.2pt depth-2pt\hskip0ptplus3fil
    \hskip0pt plus-2fil
    \leaders\vrule height4.2pt depth-4pt\hskip0ptplus3fil
    \hskip0pt plus-2fil
    \leaders\hrule height6.2pt depth-6pt\hskip0ptplus3fil
}
\def\quadfilledline#1{%
  \hbox to\hsize{%
    \lquadruple
    \enspace\strut#1\enspace
    \rquadruple
  }
}

\bigskip
\quadfilledline{The St.\ Anford Orchestra}
\bigskip
\quadfilledline{Variations on a Theme by Tchaikovsky}
\bigskip

\end