Re: overlapping math symbols



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
.



Relevant Pages

  • Re: initialising array of unknown size (newbie)
    ... Note what the macro Arows expands to ... Note what the macro Acols expands to ... the integer returned by mat_multis now converted to a float. ...
    (comp.lang.c)
  • Re: QteAddViewMap api
    ... preprocessor that expands macros from the *INPUT file of the ... What is the MAPA0100 encoding for a macro statement in the *input/from ... For the macro line being expanded I have tried map type = 1 ... /EndMacro lines are not included in the output view the debugger does ...
    (comp.sys.ibm.as400.misc)
  • Re: More problems with complex notation
    ... The macro _Complex_I expands to a constant expression of type const ... float _Complex, with the value of the imaginary unit. ... 1.0i does seem like the obvious notation. ...
    (comp.std.c)
  • Re: Monofiles vs Splitting into many files
    ... > assembly, compile-time loops, equates, etc., that this macro ... I realize that you have an assembler that doesn't ... This macro expands to over 500 statements ...
    (alt.lang.asm)
  • Re: i++ * i++
    ... > undefined behavior. ... The variable i is therefore modified twice, ... The reason i++ is used twice is because its a macro? ... The reason i++ is used twice is because of what the macro expands to. ...
    (comp.lang.c)