[Tex/LaTex] Straight math arrows

arrowssymbolstikz-pgf

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?

Best Answer

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

Related Question