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.

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!

share|improve this question
    
Welcome to TeX.SX! –  Papiro Oct 3 '13 at 22:51
    
Yah, that sucks. How about showing what you've done in the form of a (perhaps non) minimal working example (MWE)? –  Werner Oct 3 '13 at 22:58
add comment

1 Answer 1

up vote 8 down vote accepted

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.

share|improve this answer
    
How did you find out that the \rightarrow was in slot 21 (and so on for the other symbols)? Is there an easy way of doing this? Thanks! –  Andrew Bate Oct 4 '13 at 17:08
    
@AndrewBate Just find on your computer the file fontmath.ltx; I just copied from there changing symbols into arrows in order to assign the symbols to the new math font just declared. –  egreg Oct 4 '13 at 17:23
    
amsmath has its own definition of \relbar which is not robust and uses \mathpalette. It also has its definition of \longrightarrow etc... so your code reverts this to the non-amsmath status, I don't know if or where this could show up concretely under certain circumstances. –  jfbu Oct 4 '13 at 17:55
    
@jfbu The \relbar redefinition by amsmath is just to make the construction compatible with the tricks amsmath does when doing \qopname; since I don't use the minus sign, nothing bad should happen. And I don't redefine \longrightarrow nor \longleftarrow. –  egreg Oct 4 '13 at 17:59
    
@jfbu Actually, the amsmath definition uses directly \mathpalette\mathsm@sh, which is what \smash expands to when used in math mode. It would be probably slightly more efficient to use \mathpalette\mathsm@sh also here, but less direct for the beginner. –  egreg Oct 4 '13 at 19:09
show 4 more comments

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.