[Tex/LaTex] Vertical addition and multiplication

math-mode

I am writing a thesis document in Latex and I want some text to be displayed as shown in the attached image:-

Math

I have created my own class file. I tried implementing the existing posts but couldn't modify them to get the result i want. Please guide me on this.

Best Answer

This can be done using an array:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\[
\renewcommand\arraystretch{1.2}
\begin{array}{c@{}c@{\,}c@{\,}c@{\,}c@{\,}ccl}
& \makebox[0pt]{\raisebox{-.5\normalbaselineskip}[0pt][0pt]{$\times$}} & & 1 & 2 & 3 \\
& & & 4 & 5 & 6 \\
\cline{3-6}
& & & 7 & 3 & 8 & & \text{(this is $123 \times 6$.)} \\
+& & 6 & 1 & 5 &  & & \text{(this is $123 \times 5$, shifted one position to the left.)} \\
& 4 & 9 & 2  & & & & \text{(this is $123 \times 4$, shifted one position to the left.)} \\
\cline{1-6}
& 5 & 6 & 0 & 8 & 8
\end{array}
\]

\end{document}

enter image description here

With the arydshln package one can get the double dashed line above the result:

\documentclass{article}
\usepackage{amsmath}
\usepackage{arydshln}

\setlength\dashlinedash{5pt}
\setlength\dashlinegap{2.5pt}

\begin{document}

\[
\renewcommand\arraystretch{1.2}
\begin{array}{c@{}c@{\,}c@{\,}c@{\,}c@{\,}ccl}
& \makebox[0pt]{\raisebox{-.5\normalbaselineskip}[0pt][0pt]{$\times$}} & & 1 & 2 & 3 \\
& & & 4 & 5 & 6 \\
\cline{3-6}
& & & 7 & 3 & 8 & & \text{(this is $123 \times 6$.)} \\
+& & 6 & 1 & 5 &  & & \text{(this is $123 \times 5$, shifted one position to the left.)} \\
& 4 & 9 & 2  & & & & \text{(this is $123 \times 4$, shifted one position to the left.)} \\
\cdashline{1-6}\\[-1.09\normalbaselineskip]\cdashline{1-6}
& 5 & 6 & 0 & 8 & 8
\end{array}
\]

\end{document}

enter image description here