Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there any way to redefine all arrows in math mode (\rightarrow, \leftarrow, \Rightarrow, \Leftarrow, \to, etc.) to another arrows that finish with angle 90 TikZ option?

I have done some tries and I've got good results with normal math size: enter image description here

Using the following code:

\documentclass{minimal}

\usepackage{tikz}
\usetikzlibrary{arrows}

%Redefine \rightarrow
\renewcommand{\rightarrow}{\mathbin{\tikz[baseline]\draw[arrows={-angle 90},yshift=0.75ex] (0,0) -- (.95em,0);}}

\begin{document}

%\mathchar"3221 is just the original code of \rightarrow
\noindent $x^2 - 2x + 1 = 0 \mathchar"3221 (x-1)^2 = 0 \mathchar"3221 x = 1$\\
$x^2 - 2x + 1 = 0 \rightarrow (x-1)^2 = 0 \rightarrow x = 1$

\end{document}

But I have problems when I use that arrow in special cases like limits, and I would like that all those arrows work in that situation (if possible):

enter image description here

I know that in this question is also explained how to get symbols that are like mine, but the package doesn't include the arrows that I would like to have. Also, I would like that that new arrows behave like normal characters, so if I put $2x \textcolor{red}{\rightarrow} 0$, I would obtain a red arrow.

Any idea or suggestion?

share|improve this question

2 Answers 2

up vote 4 down vote accepted

The problem is that the tikz definition you gave doesn't scale with the smaller math styles. To overcome that, we use the scalerel package to scale (on the fly) the good normal-sized arrow to the same vertical extent as the original arrow that you are replacing, in the current math style.

\documentclass{minimal}
\usepackage{scalerel}
\usepackage{tikz}
\usetikzlibrary{arrows}
\let\svrightarrow\rightarrow
\newcommand{\TSrightarrow}{\mathbin{\tikz[baseline]\draw[arrows={-angle 90},yshift=0.75ex] (0,0) -- (.95em,0);}}
\renewcommand\rightarrow{\mathrel{\scalerel*{\TSrightarrow}{\svrightarrow}}}
\parindent 0pt
\begin{document}
$x^2 - 2x + 1 = 0 \svrightarrow (x-1)^2 = 0 \svrightarrow x = 1$\\~\\
$x^2 - 2x + 1 = 0 \rightarrow (x-1)^2 = 0 \rightarrow x = 1$\\~\\
\( \lim_{h\svrightarrow0}\frac{f(x+h)-f(x)}{h} \)\\~\\
\( \lim_{h\rightarrow0}\frac{f(x+h)-f(x)}{h} \)
\end{document}

enter image description here

share|improve this answer
    
Thank you, I could expand you code to generate \leftarrow and \leftrightarrow too, but, how can I do \Leftarrow, \Rightarrow and \Leftrightarrow? –  JnxF Aug 29 '13 at 17:44
    
@JnxF I'm not a tikz guy, so I couldn't tell you how to draw the initial arrows. But if you could do that in tikz, then scalerel should be able to scale it to the given math size. –  Steven B. Segletes Aug 29 '13 at 17:50
    
@JnxF Perhaps tex.stackexchange.com/questions/72784/… would help with double arrows in tikz (repeating, I'm not a tikz person). –  Steven B. Segletes Aug 29 '13 at 18:15

The problem is that your arrow doesn't scale appropriately, depending on the math style. Simply using \text or \mathchoice alleviates a little the situation, but leaves a problem with the arrow tip not scaling appropriately.

Here's a definition using \mathchoice and a decoration, to be able to scale down the arrow tip appropriately. Perhaps some adjustments are still needed.

\documentclass{article}

\usepackage{tikz}
\usepackage{amsmath}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.markings}

%Redefine \rightArrow
\newcommand\rightArrow{%
\mathchoice
  {\mathrel{%
    \tikz[baseline]
    \draw[decoration={markings,mark=at position 1 with {\arrow[scale=0.88]{angle 90}}},postaction=decorate,yshift=0.75ex] 
      (0,0) -- (.95em,0);}%
  }
  {\mathrel{%
    \tikz[baseline]
    \draw[decoration={markings,mark=at position 1 with {\arrow[scale=0.88]{angle 90}}},postaction=decorate,yshift=0.75ex] 
      (0,0) -- (.95em,0);}%
  }
  {\mathrel{%
    \tikz[baseline]
    \draw[decoration={markings,mark=at position 1 with {\arrow[scale=0.6]{angle 90}}},postaction=decorate,yshift=0.43ex] 
      (0,0) -- (.65em,0);}\mkern1.8mu}
  {\mathrel{%
    \tikz[baseline]
    \draw[decoration={markings,mark=at position 1 with {\arrow[scale=0.5]{angle 90}}},postaction=decorate,yshift=0.38ex] 
      (0,0) -- (.58em,0);}\mkern1.5mu}
}

\begin{document}

$x^2 - 2x + 1 = 0 \mathchar"3221 (x-1)^2 = 0 \mathchar"3221 x = 1$

$x^2 - 2x + 1 = 0 \rightArrow (x-1)^2 = 0 \rightArrow x = 1$

$\lim_{x\rightarrow 0}\quad A_{\lim_{x\rightarrow 0}}$

$\lim_{x\rightArrow 0}\quad A_{\lim_{x\rightArrow 0}}$

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.