Getting arrows underneath numbers
One possibility is the \curvearrowbotleft
mentioned by Qrrbrbirlbel along with the accents
package:
\documentclass{minimal}
\usepackage{mathabx}
\usepackage{accents}
\usepackage{xcolor}
\newcommand*{\uarr}[1]{\underaccent{\color{red}\curvearrowbotleft}{#1}}
\begin{document}
$\uarr{7}$.
$10.\uarr{5}\uarr{5}\uarr{6}$.
\end{document}
Here is a version with more visible arrow heads and less overlap with adjacent arrows, at the cost of more complication and a somewhat goofy-looking arrow head.
\documentclass{amsart}
\usepackage{mathabx} % for \curvearrowbotleft
\usepackage{accents} % for \underaccent
\usepackage{xcolor} % for \color
\usepackage{graphicx} % for \resizebox
\usepackage{calc} % for \widthof
\usepackage{bm} % for \bm (bold symbol)
\newcommand*{\uarr}[1]{\underaccent{\resizebox{\widthof{#1}}{\height}{$\color{red}\bm{\curvearrowbotleft}$}}{#1}}
\begin{document}
$\uarr{7}$.
$10.\uarr{5}\uarr{5}\uarr{6}$.
\end{document}
The command must be used in math mode (since \underaccent
is math-only), but has $ inside since \resizebox
leaves math mode.
Edit: Originally, I had \widthof{0}
in the above definition. This allowed the arrows to fit different font sizes and fonts, like so:
This depends on the fact that all digits are the same width, which is true in most math fonts but not all. I realized that simply changing it to \widthof{#1}
would not only take care of the case of different-width digits, but allow putting arrows under more than one digit.
For instance, $\uarr{00}$. $\uarr{007}$.
would have originally given , but now gives
Here is an option adapted form How to draw arrows from cell to cell at the borders of a table. The results are not quite as good as I had hoped due to the small amount of space available. Perhaps more tweaking on the setting will yield better results. One tweak that can be done is to change the line and arrow style when drawing between subsequent digits as I have done for the first case below by setting:
\tikzset{BottomArrowStyle/.style={thin, -stealth}}
If you can alter the location to above and below the digits, or span multiple digits then this is more useful as the last two images illustrate:
Note:
This does require two runs. First one to determine the locations, and the second to do the drawing.
The
\tikzmark
is from Adding a large brace next to a body of text.See follow up question Arrows underneath numbers (Part 2 question) for drawing arrows in both directions
Code:
\documentclass{article}
\usepackage{xparse}
\usepackage{tikz}
\usetikzlibrary{calc}
%% Set these if you want to globally atler the arrow styles
%% for the top and bottom arrows.
\tikzset{TopArrowStyle/.style={}}
\tikzset{BottomArrowStyle/.style={}}
\newcommand{\tikzmark}[2]{%
\tikz[overlay,remember picture,baseline] \node [anchor=base] (#1) {\phantom{#2}};#2% <-- important
}
\newcommand*{\XShift}{0.5ex}
\newcommand*{\ArcDistance}{0.075cm}
\newcommand*{\OutAngle}{}
\newcommand*{\InAngle}{}
\newcommand*{\AnchorPoint}{}
\newcommand*{\ShortenBegin}{}
\newcommand*{\ShortenEnd}{}
%
\NewDocumentCommand{\DrawArrow}{s O{} m m}{%
\IfBooleanTF {#1} {% starred variant - draw arrows below
\renewcommand*{\OutAngle}{-95}%
\renewcommand*{\InAngle}{-85}%
\renewcommand*{\AnchorPoint}{south}%
\renewcommand*{\ShortenBegin}{-3.5pt}%
\renewcommand*{\ShortenEnd}{-3.5pt}%
\tikzset{Arrow Style/.style={BottomArrowStyle}}% <-- important
}{% non-starred - draw arrows above
\renewcommand*{\OutAngle}{95}%
\renewcommand*{\InAngle}{85}%
\renewcommand*{\AnchorPoint}{north}%
\renewcommand*{\ShortenBegin}{-3.5pt}%
\renewcommand*{\ShortenEnd}{-3.5pt}%
\tikzset{Arrow Style/.style={TopArrowStyle}}% <-- important
}%
\begin{tikzpicture}[overlay,remember picture]
\draw[
->, thick, distance=\ArcDistance,
shorten <=\ShortenBegin, shorten >=\ShortenEnd,
out=\OutAngle, in=\InAngle, Arrow Style, #2
]
($(#3.\AnchorPoint)+(2.0*\XShift,0)$) to
($(#4.\AnchorPoint)+(0.4*\XShift,0)$);
\end{tikzpicture}% <-- important
}
\begin{document}
\tikzset{BottomArrowStyle/.style={thin, -stealth}}%
10.\tikzmark{Three}{5}\tikzmark{Two}{6}\tikzmark{One}{6}%
\DrawArrow*[red]{One}{One}%
\DrawArrow*[brown]{Two}{Two}%
\DrawArrow*[blue]{Three}{Three}%
\tikzset{BottomArrowStyle/.style={}}% restore to default
\bigskip
10.\tikzmark{ThreeB}{5}\tikzmark{TwoB}{6}\tikzmark{OneB}{6}%
\DrawArrow*[red]{OneB}{OneB}%
\DrawArrow[brown]{TwoB}{TwoB}%
\DrawArrow*[blue]{ThreeB}{ThreeB}%
\bigskip
10.\tikzmark{Three}{5}\tikzmark{Two}{6}\tikzmark{One}{6}%
\DrawArrow*[red,in=-85, out=-95, distance=0.2cm]{One}{Three}%
\end{document}