Re: overlapping math symbols
- From: Enrico Gregorio <gregorio@xxxxxxxxxxxxx>
- Date: Thu, 31 May 2007 10:30:37 +0200
Lars Madsen <daleif@xxxxxxxxxxxxxxxxxxxxx> wrote:
Enrico Gregorio wrote:
Lars Madsen <daleif@xxxxxxxxxxxxxxxxxxxxx> wrote:
here is one without the use of extra lengths
\documentclass{article}
\makeatletter
\newcommand{\parallelrightarrow}{%
\mathrel{
\m@th\sbox\z@{$\rightarrow$}
\makebox[\wd\z@][c]{$\rightarrow$}
\kern-\wd\z@
\makebox[\wd\z@][c]{$\parallel$} }}
\makeatother
\begin{document}
\[
X \parallelrightarrow Y
\]
\end{document}
note though that it should not be used as X_\parallelrightarrow as it
does not scale. If you need that you will basically need to create the
macro using \mathchoice
Here is a more efficient one:
\makeatletter
\newcommand{\parallelrightarrow}{%
\mathrel{\ooalign{$\m@th\rightarrow$\cr
\hidewidth$\m@th\parallel$\hidewidth}}}
\makeatother
And a variation which works even in subscripts and superscripts
(but it has to be written $X_{\parallelrightarrow}$):
\makeatletter
\newcommand{\@parallelrightarrow}[1]{%
\ooalign{$#1\m@th\rightarrow$\cr
\hidewidth$#1\m@th\parallel$\hidewidth}}
\newcommand{\parallelrightarrow}{%
\mathrel{\mathpalette\@parallelrightarrow\relax}}
\makeatother
cool, I'll have to to study them to fully understand what is going on.
The method is clearly quite usefull.
This is Plain TeX trickery:
\def\oalign#1{\leavevmode\vtop{\baselineskip\z@skip \lineskip.25ex%
\ialign{##\crcr#1\crcr}}} \def\o@lign{\lineskiplimit\z@ \oalign}
\def\ooalign{\lineskiplimit-\maxdimen \oalign} % chars over each other
With \oalign you can put something under a character; with \ooalign you
also annihilate any baseline skip: the rows of the \ialign (which is
just \halign with zero \tabskip) are superimposed on each other. Of
course this should not be used "in the open", but in a math formula it
is OK. Plain TeX uses it for \copyright and, in fact, the definition
has an extra pair of braces.
\hidewidth, in the above macro, could be substituted with \hfil, since
\parallel is less wide than \rightarrow.
Instead of doing calculations as in your macros, we let TeX do the work
with its powerful \halign.
\mathpalette takes two arguments and expands to
\mathchoice{#1\displaystyle{#2}}{#1\textstyle{#2}}
{#1\scriptstyle{#2}}{#1\scriptscriptstyle{#2}}}
In our case, it expands to
\mathchoice{\@parallelrightarrow\displaystyle{\relax}}
{\@parallelrightarrow\textstyle{\relax}}
{\@parallelrightarrow\scriptstyle{\relax}}
{\@parallelrightarrow\scriptscriptstyle{\relax}}}
so I defined in that way \@parallelrightarrow. Probably it would be
better to change this definition into
\newcommand{\@parallelrightarrow}[2]{%
\ooalign{$#1\m@th\rightarrow$\cr
\hidewidth$#1\m@th\parallel$\hidewidth}}
so that it gobbles also the {\relax}. In any case #1 is the math style
selection.
Ciao
Enrico
.
- Follow-Ups:
- Re: overlapping math symbols
- From: Lars Madsen
- Re: overlapping math symbols
- References:
- overlapping math symbols
- From: katelman
- Re: overlapping math symbols
- From: Werner
- Re: overlapping math symbols
- From: katelman
- Re: overlapping math symbols
- From: Lars Madsen
- Re: overlapping math symbols
- From: Enrico Gregorio
- Re: overlapping math symbols
- From: Lars Madsen
- overlapping math symbols
- Prev by Date: Re: OK TeXperts... tweaking \item
- Next by Date: Re: overlapping math symbols
- Previous by thread: Re: overlapping math symbols
- Next by thread: Re: overlapping math symbols
- Index(es):
Relevant Pages
|