# Why are \twoheadleftarrow and \leftarrow so different? [Sweave, listings]

I am wondering why the \twoheadleftarrow in the code below looks so much different from (worse than) the \leftarrow, although according to the LaTeX symbol list, the arrow heads should be of the same height etc.

\documentclass{article}

\usepackage{amssymb}
\usepackage{bm}
\usepackage{Sweave}
\usepackage{listings}

\lstset{
language=R,
basicstyle=\ttfamily,
literate={<-}{{$\bm\leftarrow$}}2{<<-}{{$\bm\twoheadleftarrow$}}2
}

% undefine Sinput, and Soutput (due to missing 'lstrenewenvironment')
\expandafter\let\csname Sinput\endcsname\relax
\expandafter\let\csname endSinput\endcsname\relax
\expandafter\let\csname Soutput\endcsname\relax
\expandafter\let\csname endSoutput\endcsname\relax

\lstnewenvironment{Sinput}[1][]{#1}{}

\begin{document}
<<foo>>=
x <- 1
x <<- 1
@
\end{document}

-

Your minimal example could have been more minimal:-)

Looking at the log from

\documentclass{article}

\usepackage{amssymb}

\begin{document}
\showoutput
$a \leftarrow b$

$x \mathrel{\leftarrow\mkern-14mu\leftarrow} y$

$c \twoheadleftarrow d$

\end{document}


You see that the single arrow comes from the original CM font but the double arrow comes from the AMS font and the arrow head doesn't really match.

Your choice is to cast around for a font set that does have matching arrows or fake double arrows by over-printing single arrows as in my example. Once you have the arrows matching bm and sweave packages can do their stuff but if the basic underlying arrow definitions don't match, bm and sweave can't make them match.

-
Many thanks for helping, David, as usual. I tried to minimalize it, but didn't realize that the problem already appeared. Thanks again, works great. –  Marius Hofert Nov 13 '12 at 12:31
@DavidCarlisle -- the ams symbol fonts were based on the shapes of the original am (pre-cm) fonts, and not updated when knuth changed some of the cm shapes, including those of arrowheads. the overlay approach is a good choice in this situation. –  barbara beeton Nov 13 '12 at 14:39