Jesteś w: Start / Przedsięwzięcia/Projects / TeX Pearls / 2005 Pearls / bernd-raichle / bachotex2005-bernd-raichle-pearl1.tex

bachotex2005-bernd-raichle-pearl1.tex

TeX document icon bachotex2005-bernd-raichle-pearl1.tex — TeX document, 3 KB (3625 bytes)

Zawartość pliku

%%% Bernd Raichle: Plain TeX's accent macros revisited (LaTeX)

\NeedsTeXFormat{LaTeX2e}
\documentclass[a4paper,11pt,DIV12,smallheadings]{scrartcl}

\addtolength{\topmargin}{-3\baselineskip}
\addtolength{\textheight}{6\baselineskip}

\DeclareRobustCommand{\cs}[1]{\texttt{{\char`\\}#1}}

% ``undertilde'' accent (by WSchmi)

\makeatletter
\def\utilde#1{\oalign{\relax$#1$\crcr\hidewidth\sh@ft{29}%
    \vbox to.2ex{\hbox{$\m@th\tilde{}$}\vss}\hidewidth}}
\makeatother

\newcommand\test{%
  \quad \AA\ \quad \c{c} \c{C} \c{t} \c{T} \c{g} \c{G} \c . \c j \c p \c y
  %\quad \d o \d g \d O \d j \d q \d p \d y
  \quad \b o \b g \b O \b j \b q \b p \b y
  %\quad \utilde o \utilde g \utilde O
}

\newcommand\dotest{%
  \begin{flushleft}\Large
  \leavevmode\hphantom{cmcsc}\llap{cmr}: \test \\
  \leavevmode\hphantom{cmcsc}\llap{cmcsc}: {\sc \test} \\
  \leavevmode\hphantom{cmcsc}\llap{cmit}: {\it \test} \\
  \leavevmode\hphantom{cmcsc}\llap{cmsl}: {\sl \test}
  \end{flushleft}}

\begin{document}
\title{}%Plain \TeX's accent macros revisited}
\date{}%2005/04/05}
\author{}%Bernd Raichle}
\maketitle
\thispagestyle{empty}

\hsize400pt

\section*{Sample output using Plain TeX's accent macros.}

Here is the output when Plain TeX's accent macros \cs{AA}, \cs{c}, and \cs{b}
are used with various glyphs from different upright and slanted fonts.

\dotest


\section*{Revised macros using the \cs{accent} primitive.}

The following re-implementation does not use \cs{halign} but the \cs{accent}
primitive to position the accent glyph.

\begin{verbatim}
\def\AA{{\dimen@ 1ex%
  {\setbox\z@\hbox{A}\dimen@\ht\z@ \advance\dimen@-.35ex%
  \fontdimen5\font\dimen@}\accent'27\fontdimen5\font\dimen@ A}}

\def\c#1{{\dimen@ 1ex%
  {\setbox\z@\hbox{#1}\dimen@\ht\z@ \advance\dimen@\dp\z@
  \fontdimen5\font\dimen@}\accent24\fontdimen5\font\dimen@ #1}}

\def\b#1{{\dimen@ 1ex\setbox\z@\hbox
  {{\setbox\z@\hbox{\char22}\dimen@\ht\z@ \advance\dimen@ .25ex%
   \setbox\z@\hbox{#1}\advance\dimen@\ht\z@ \advance\dimen@\dp\z@
   \global\dimen@i\dp\z@ \global\advance\dimen@i .45ex%
  \fontdimen5\font\dimen@}\accent22\fontdimen5\font\dimen@ #1}%
  \dp\z@\dimen@i \box\z@}}
\end{verbatim}

\makeatletter
\def\AA{{\dimen@ 1ex%
  {\setbox\z@\hbox{A}\dimen@\ht\z@ \advance\dimen@-.35ex%
  \fontdimen5\font\dimen@}\accent'27\fontdimen5\font\dimen@ A}}

\def\c#1{{\dimen@ 1ex%
  {\setbox\z@\hbox{#1}\dimen@\ht\z@ \advance\dimen@\dp\z@
  \fontdimen5\font\dimen@}\accent24\fontdimen5\font\dimen@ #1}}

\def\d#1{{\dimen@ 1ex%
  {\setbox\z@\hbox{.}\dimen@\ht\z@ \advance\dimen@ .25ex%
   \setbox\z@\hbox{#1}\advance\dimen@\ht\z@\advance\dimen@\dp\z@
  \fontdimen5\font\dimen@}\accent`.\fontdimen5\font\dimen@ #1}}

\def\b#1{{\dimen@ 1ex%
  \setbox\z@\hbox
  {{\setbox\z@\hbox{\char22}\dimen@\ht\z@ \advance\dimen@ .25ex%
   \setbox\z@\hbox{#1}\advance\dimen@\ht\z@ \advance\dimen@\dp\z@
   \global\dimen@i\dp\z@ \global\advance\dimen@i .45ex%
  \fontdimen5\font\dimen@}\accent22\fontdimen5\font\dimen@ #1}%
  \dp\z@\dimen@i \box\z@}}

\def\utilde#1{{\dimen@ 1ex%
  \setbox\z@\hbox
  {{\setbox\z@\hbox{\char126}\dimen@\ht\z@ \advance\dimen@ .25ex%
   \setbox\z@\hbox{#1}\advance\dimen@\ht\z@ \advance\dimen@\dp\z@
   \global\dimen@i\dp\z@ \global\advance\dimen@i .45ex%
  \fontdimen5\font\dimen@}\accent126\fontdimen5\font\dimen@ #1}%
  \dp\z@\dimen@i \box\z@}}
\makeatother

\subsection*{Sample output using the revised macros.}

Here is the output using the new definitions.

\dotest

\noindent Do you see the differences?  How is \cs{accent} used to achieve this effect?

\end{document}

%%% Local Variables:
%%% mode: latex
%%% TeX-master: t
%%% End: