[texhax] Double bar? (TeXbooks)

Uwe Lueck uwe.lueck at web.de
Sun Jan 2 17:14:47 CET 2011


"Philipp Stephani" , 01.01.2011 21:49:02:
>Am 01.01.2011 um 20:15 schrieb Rodolfo Medina:
>> I wish to put a double bar onto a math symbol, in particular over `x', but
>> `$\bar \bar x$' gives error and `$\bar{\bar x}$' is not very nice because the
>> two bars are not precisely aligned.  Please help on this issue
>> (I'm a plain TeX user).
>
> The plain format has the \skew macro for exact (manual) 
> placement of double accents. See e.g. section 21.4 of
> TeX by Topic for an example.

Aha ... and the TeXbook, p. 136, *adds* that the choice 
of the first parameter of \skew is a matter of nothing 
but (i) trial and error and (ii) personal taste ...

I had thought about accents a while ago and now thought 
I could quickly ... provide a macro that shifts accents 
automatically and according to an idea of my taste 
... below: \oneacc, \twoacc, \threeacc, with limitating assumptions ...

Cheers, 

    Uwe.

_______________________________________________________
%% MATHACCS.TEX 2011/01/02 UL
\catcode`\@=11
 \def\stripslant#1#2#3#4#5\relax{#3#4}
 \def\setshift#1{%
 \dimen0 \ht#1\relax
 \multiply\dimen0 \theslant
 \divide  \dimen0 100 %
 \edef\theshift{\the\dimen0}}
 \def\foracc#1{%
 \edef\theslant{%
 \expandafter \stripslant
 \the\fontdimen1\textfont1\relax}%
 % TODO: extract font infos from #1 instead
 \setbox0\hbox{$#1\m at th$}%
 \edef\thewd{\the\wd0}%
 \setshift0
 \dimen0 \wd0
 \advance \dimen0 -\theshift
 \edef\thebasewd{\the\dimen0}%
 }
 \def\shiftacc#1#2{%
 \rlap{$\m at th
 \setbox0\hbox{$#2$}%
 \setshift0%
 \kern\theshift#1{%
 \vrule width0pt height\ht0\kern\thebasewd}$}}
 \def\forpolacc#1#2{\foracc{#1}#1\kern-\thewd#2#1}
 \def\oneacc#1#2{\forpolacc{#2}{\shiftacc#1{#2}}}
 \def\twoacc#1#2#3{%
 \forpolacc{#3}{%
 \shiftacc#2{#3}\shiftacc#1{#2{#3}}}}
 \def\threeacc#1#2#3#4{%
 \forpolacc{#4}{%
 \shiftacc#3{#4}%
 \shiftacc#2{#3{#4}}%
 \shiftacc#1{#2{#3{#4}}}%
 }%
 }
\catcode`\@=12
%% run:
\ifx\LaTeXe\undefined
 \let\END\bye
\else
 \documentclass[12pt]{article} \begin{document}
 \def\END{\end{document}}
\fi
 $\bar{\bar x}\quad \skew{6}{\bar}{\bar x}\quad 
 \skew{3.33}{\bar}{\skew{2.67}{\bar}{x}}\quad 
 \oneacc\bar{x}\quad 
 \twoacc\bar\bar{x}\quad 
 \oneacc\bar{T}\quad 
 \twoacc\bar\bar{T}\quad 
 \threeacc\bar\bar\bar{h}
 $
\END


More information about the texhax mailing list