Aligning the Arrows
The simple approach would be to add a \noindent
to the first line. However, that will not account for the varied width of the leading numbers, especially if you exceed one digit or if the lead were something other than a digit, such as a decimal point.
There are many ways to accomplish this. Here is one that gives proper math spacing around the arrow, and will not break across a page boundary midway through.
\documentclass{article}
\usepackage{tabstackengine}
\begin{document}
\noindent\alignLongunderstack{
1${}\longrightarrow{}$& trillion\\
7${}\longrightarrow{}$& hundred billion\\
8${}\longrightarrow{}$& ten billion\\
4${}\longrightarrow{}$& billion\\
6${}\longrightarrow{}$& hundred million\\
5${}\longrightarrow{}$& ten million\\
3${}\longrightarrow{}$& million\\
2${}\longrightarrow{}$& hundred thousands\\
0${}\longrightarrow{}$& ten thousands\\
1${}\longrightarrow{}$& thousands\\
4${}\longrightarrow{}$& hundreds\\
5${}\longrightarrow{}$& tens\\
9${}\longrightarrow{}$& ones}
\end{document}
You probably have several numbers to show the interpretation of.
\documentclass{article}
\usepackage{amsmath}
\usepackage{siunitx} % also loads xparse and expl3
\ExplSyntaxOn
\NewDocumentCommand{\shownumber}{sO{c}m}
{
\IfBooleanTF { #1 }
{
\num{#3}
}
{
\ensuremath{\forest_shownumber:nn { #2 } { #3 } }
}
}
\seq_new:N \l__forest_shownumber_seq
\cs_new_protected:Nn \forest_shownumber:nn
{
\seq_set_split:Nnn \l__forest_shownumber_seq { } { #2 }
\begin{aligned}[#1]
\seq_indexed_map_function:NN \l__forest_shownumber_seq \__forest_shownumber_digit:nn
\end{aligned}
}
\cs_new_protected:Nn \__forest_shownumber_digit:nn
{
#2 & \longrightarrow
\text { \__forest_shownumber_name:n { \seq_count:N \l__forest_shownumber_seq - #1 } } \\
}
\cs_new:Nn \__forest_shownumber_name:n
{
\int_case:nn { #1 }
{
{0}{units}
{1}{tens}
{2}{hundreds}
{3}{thousands}
{4}{ten ~ thousands}
{5}{hundred ~ thousands}
{6}{million}
{7}{ten ~ million}
{8}{hundred ~ million}
{9}{billion}
{10}{ten ~ billion}
{11}{hundred ~ billion}
{12}{trillion}
%...
}
}
\ExplSyntaxOff
\begin{document}
\shownumber*{1784653201459}
\[
\shownumber{1784653201459}
\]
\shownumber*{123456} is \shownumber[t]{123456}
\end{document}
The \shownumber
macro has a *-variant (just print the number); the optional argument is for the display version and tells what vertical alignment is passed to aligned
(values are c
, default, t
or b
).
We populate a sequence with the digits, then map it using the index to retrieve the textual meaning of the digit's place.
I stopped to “trillion”, but you can easily extend the list.
IN using tabular
i would take a step further: with use of two columns the code is a bit shorter:
\documentclass{article}
\usepackage{array}
\begin{document}
\begin{tabular}{@{} r @{${}\longrightarrow{}$} l @{}}
1 & trillion\\
7 & hundred billion\\
8 & ten billion\\
4 & billion\\
6 & hundred million\\
5 & ten million\\
3 & million\\
2 & hundred thousands\\
0 & ten thousands\\
1 & thousands\\
4 & hundreds\\
5 & tens\\
9 & ones
\end{tabular}
\end{document}