3

Consider the following example:

\documentclass{article}

\begin{document}

\fbox{$\longrightarrow$}

\end{document}

output

As can be seen, the height of the box is too small.

How do I correct this?

9

In 1992, the Computer Modern arrows were changed to make for a larger head; already in the old version the bounding box didn't cover the whole tip and it was not changed after the modification to the tips, for backwards metric compatibility.

With the old-arrow package one can see the difference:

\documentclass{article}
\usepackage[old]{old-arrows}

\begin{document}

\setlength{\fboxrule}{0.1pt}
\setlength{\fboxsep}{0pt}

x \fbox{$\varrightarrow$} (old style)

x \fbox{$\rightarrow$} (new style)

\end{document}

enter image description here

You can fix the bounding box using the fact that the stem is at the math axis and the lower part of the tip sits on the baseline.

\documentclass{article}

\newcommand{\srightarrow}{%
  \mathrel{\mathpalette\strutarrow\rightarrow}%
}
% define similarly the other arrows you need

% the generic macro
\newcommand{\strutarrow}[2]{%
  \vrule width 0pt height 2\fontdimen22
  \ifx#1\displaystyle\textfont\else
    \ifx#1\textstyle\textfont\else
      \ifx#1\scriptstyle\scriptfont\else
  \scriptscriptfont\fi\fi\fi 2
  {#2}%
}

\begin{document}

\fbox{$\rightarrow$} \fbox{$\srightarrow$}

\setlength{\fboxrule}{0.1pt}
\setlength{\fboxsep}{0pt}

x \fbox{$\rightarrow$} (normal)

x \fbox{$\srightarrow$} (with strut)

\end{document}

enter image description here

  • Thank you, Enrico! (Btw. when I zoom in it is easy to see that the long arrow (when I switch to \longrightarrow) is composed of a short arrow and a line segment. Can this be "smoothed" out?) – Svend Tveskæg Jan 17 '18 at 0:57
  • @SvendTveskæg That’s how long arrows are made, some viewers may have issues at certain resolutions. It has nothing to do with the bounding box. – egreg Jan 17 '18 at 6:59
6

You can add a strut or perhaps better add a zero width rule similarly centred on the math axis, of whatever size you wish.

enter image description here

\documentclass{article}

\begin{document}

\fbox{.} \fbox{$a$} \fbox{$\longrightarrow$} \fbox{\strut$\longrightarrow$}

\fbox{$\vcenter{\hrule height 15pt width 0pt}{\longrightarrow}$}

\end{document}
  • Hmmm! When I zoom in it is easy to see that the long arrow is composed of a short arrow and a line segment. Can this be "smoothed" out? – Svend Tveskæg Jan 17 '18 at 0:27
  • @SvendTveskæg one way would be to use a font that has long arrows eg stix, or you could tweak the definition of \joinrel to have more overlap – David Carlisle Jan 17 '18 at 1:05
  • @SvendTveskæg much as it pains me to say so, I suspect you should move the tick in the general direction of egreg – David Carlisle Jan 17 '18 at 9:13
  • Okay; I will. :-) – Svend Tveskæg Jan 17 '18 at 17:57
4

Here is a solution:

\documentclass[12pt]{article}

\begin{document}

hkl \raisebox{2\fontdimen22\textfont2}{ \fbox{\raisebox{-2\fontdimen22\textfont2}{$ \longrightarrow $}}} amn 

\end{document} 

enter image description here

  • Thanks! Hmmm! When I zoom in it is easy to see that the long arrow is composed of a short arrow and a line segment. Can this be "smoothed" out? – Svend Tveskæg Jan 17 '18 at 0:29
  • I didn't notice that – thought it was a glyph on its own. You can use this: \newcommand\mylongrightarrow{\mathrel{\relbar\mkern-4mu\rightarrow}}. The difference in length is very small: about 0.7pt. – Bernard Jan 17 '18 at 0:42
  • When I define \newcommand*\mylongrightarrow{\mathrel{\relbar\mkern-4mu\righ‌​tarrow}} \newcommand*\reaktionspil{$\vcenter{\hrule height 60pt width 0pt}{\mylongrightarrow}$} and compile, I get the error \mylongrightarrow ...el {\relbar \mkern -4mu\righ ‌​tarrow} l.126 \fbox{\reaktionspil}. – Svend Tveskæg Jan 17 '18 at 0:49
  • @SvendTveskæg: Strange… I've just tested your code and I have no problem. Could you post a complete example reproducing your problem? – Bernard Jan 17 '18 at 0:56
  • I'm very tired ... going to bed now. I'll post tomorrow. Thank you for your help so far. – Svend Tveskæg Jan 17 '18 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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