2. Decimals diagram - manual๏ƒ

The LaTeX in this section is for a diagram for addition or subtraction of decimals.
The values in the diagram can be entered manually into the LaTeX code.
The snippet below from the LaTeX file shows a block in the preamble of the .tex file where the values for the backtacking diagram can be manually edited.
The values in the braces, {}, can be manually set with up to 2 digits before the decimal point and up to 3 after it.
The processes, \addsub can be + or -.
% modify values
\def\addsub{-}
\def\deca{70.256}
\def\decb{16.362}
\def\answer{53.894}
The line \begin{tabular}{d{2.3}} sets the spacing for up to 2 digits before and 3 digits after the decimal point.
If more digits are required then the 2 and the 3 can be changed to suit.
It uses the macro: \newcolumntype{d}[1]{D{.}{.}{#1}} which sets the decimal alignment and spacing.
The command \newcolumntype{d}[1]{cD{.}{.}{#1}} defines a new column type d that takes a single argument specifying the number of decimal places. The D column type is defined by the dcolumn package and is used to align numeric columns on a decimal point. The first two arguments of D specify the input and output decimal separators, respectively. In this case, both are set to .. The third argument specifies the number of decimal places.

2.1. A decimals diagram with answers๏ƒ

question

answer


2.2. A decimals diagram LaTeX๏ƒ

The manual question:
 1% asd worksheet template
 2\documentclass[border = 1mm]{standalone}
 3\usepackage{dcolumn}
 4    
 5\newcolumntype{d}[1]{cD{.}{.}{#1}}
 6
 7% modify values 
 8\def\addsub{-} 
 9\def\deca{70.256}
10\def\decb{16.362}
11\def\answer{}
12
13
14\begin{document}
15\begin{tabular}{d{2.3}}
16    &\deca \tabularnewline
17    $\addsub$&\decb \tabularnewline
18    \hline
19    &\answer \tabularnewline
20    \hline
21\end{tabular}
22\end{document}
The manual answer:
 1% asd worksheet template
 2\documentclass[border = 1mm]{standalone}
 3\usepackage{dcolumn}
 4    
 5\newcolumntype{d}[1]{cD{.}{.}{#1}}
 6
 7% modify values 
 8\def\addsub{-} 
 9\def\deca{70.256}
10\def\decb{16.362}
11\def\answer{53.894}
12
13
14\begin{document}
15\begin{tabular}{d{2.3}}
16    &\deca \tabularnewline
17    $\addsub$&\decb \tabularnewline
18    \hline
19    &\answer \tabularnewline
20    \hline
21\end{tabular}
22\end{document}