[Tex/LaTex] Using computer modern \rightarrow with fourier font

fontsfouriersymbols

I am using the fourier font in a LaTeX document, but instead of the \rightarrow that fourier provides, I need the Computer Modern right arrow.

For example, I need

enter image description here

instead of:

enter image description here

I have tried using \DeclareMathSymbol to no avail and am totally stuck — any help would be much appreciated!

Best Answer

Quite easy, once you know how to do it. ;-)

\documentclass{article}
\usepackage{fourier}
\usepackage{amsmath}

% load the CM symbol font
\DeclareSymbolFont{arrows}{OMS}{cmsy}{m}{n}
% change the arrows to be taken from the CM symbol font
\DeclareMathSymbol{\leftrightarrow}{\mathrel}{arrows}{"24}
\DeclareMathSymbol{\leftarrow}{\mathrel}{arrows}{"20}
   \let\gets=\leftarrow
\DeclareMathSymbol{\rightarrow}{\mathrel}{arrows}{"21}
   \let\to=\rightarrow
\DeclareMathSymbol{\mapstochar}{\mathrel}{arrows}{"37}
% the bar for making longer arrows
\DeclareMathSymbol{\relbardash}{\mathbin}{arrows}{"00}
\DeclareRobustCommand\relbar{%
  \mathrel{\smash\relbardash}% \smash, because - has the same height as +
}

\begin{document}
$X\to Y\gets Z$

$X\longrightarrow Y\longleftarrow Z$

$x\mapsto f(x)$

$X\xrightarrow{aaaaaaaaa}Y$
\end{document}

enter image description here


How to find this solution? Here's a method.

We know that we need a new math symbol font to which assigning the arrows we want to modify. So I looked into fontmath.ltx, the file where the standard assignment are found. There I found the line

\DeclareSymbolFont{symbols}{OMS}{cmsy}{m}{n}

and assigned a new name to the symbol font (I chose arrows). Then I looked for \rightarrow, \leftarrow and \mapstochar, which are the basic ingredients for the needed arrow and copied the respective lines by changing symbols into arrows. I also put the two \let instruction to make sure that the aliases \to and \gets point to the redefined symbols.

Less easy is the question about \longrightarrow and \longleftarrow. They are built by pasting together a minus sign and an arrow:

\DeclareRobustCommand{\longrightarrow}{\relbar\joinrel\rightarrow}
\DeclareRobustCommand{\longlefttarrow}{\leftarrow\joinrel\relbar}

We need to change also \relbar, because \joinrel is just a negative spacing. Now, in fontmath.ltx we find

\DeclareRobustCommand\relbar{%
  \mathrel{\smash-}% \smash, because -has the same height as +
}

and we find a problem. This definition uses the minus sign, but we don't want to change the minus sign coming from the Fourier fonts. So I found the line for -:

\DeclareMathSymbol{-}{\mathbin}{symbols}{"00}

and defined a new symbol with the same properties; finally, I redeclared \relbar to use it instead of the minus sign:

% the bar for making longer arrows
\DeclareMathSymbol{\relbardash}{\mathbin}{arrows}{"00}
\DeclareRobustCommand\relbar{%
  \mathrel{\smash\relbardash}% \smash, because - has the same height as +
}

Doing the same with other symbol fonts can be done similarly, by looking at the style files where the correspondence of symbols with triples “math type+math font+slot” is defined.

Related Question