# Trying to create an area table for integer multiplication

I am trying to create a table like the one below. Is there a way to do this in the tabular environment? Or if there is a better way to do this, please let me know. Thank you in advance! MWE:

\begin{tabular}{c c c | c}
& 30 & + & 7  \\\hline
20 & 600 & & 140  \\
+ & & & \\\hline
3 & 90 & & 21 \\\hline
\end{tabular} • what is the role of plus signs? anyway, do you have a MWE? Jan 21, 2020 at 18:07
• The plus signs are there because the students are trying to calculate 37*23 using this table. What is a MWE? Jan 21, 2020 at 18:18
• He means, show us what you have tried so far, and what you are finding hard. See minimal working example (MWE) Jan 21, 2020 at 18:23
• \begin{tabular}{c c c | c} & 30 & + & 7 \\\hline 20 & 600 & & 140 \\ + & & & \\\hline 3 & 90 & & 21 \\\hline \end{tabular} Jan 21, 2020 at 19:37
• I updated the post Jan 21, 2020 at 19:41

I must confess I don't understand the meaning of the + symbols in a table devoted to multiplication operations. I therefore omit them from the following solution.

The solution provides two LaTeX macros. The main macro is called \mytab, and it takes four arguments: the two integers in the top row of the tabular environment, and the two integers in the left-hand column. There's also an auxiliary macro called \mply (short for "multiply", I suppose) that performs the multiplication operations. \documentclass{article}
\usepackage{array}
\newcommand\mply{\the\numexpr#1*#2}
\newcommand\mytab{%
\begingroup
\renewcommand{\arraystretch}{2}
\setlength{\tabcolsep}{12pt} % default: 6pt
\begin{tabular}{| r | r  r|}
\cline{2-3}
\multicolumn{1}{c|}{} & #1 & #2  \\
\hline
#3 & \mply{#1}{#3} & \mply{#2}{#3}  \\
#4 & \mply{#1}{#4} & \mply{#2}{#4}  \\
\hline
\end{tabular}
\endgroup}

\begin{document}
\mytab{30}{7}{20}{3}

\medskip
\mytab{10}{40}{8}{15}
\end{document}

• Thank you! I agree, I think I am going to omit the plus signs as well since it is a straight multiplication table. Much appreciated. Jan 21, 2020 at 21:08
• Why not \the\numexpr#1*#3 instead of \mply{#1}{#3}? Or xint if the argument is that the numbers may become too large.Then this would also work with pdflatex and xelatex.
– user194703
Jan 22, 2020 at 1:17
• @Schrödinger'scat - An excellent suggestion! :-) I've updated my answer to make \mply execute \the\numexpr#1*#2. (Aside: I'm maybe too familiar with the ways things can be done in LuaLaTeX...)
– Mico
Jan 22, 2020 at 6:13

Here is an MWE. I have defines three \parbox macros with different height and width to fill the cells and align its contents. The multicolumns are for removing line from some of the cells: \documentclass{article}
\usepackage[table]{xcolor}

\renewcommand{\arraystretch}{1.5}

\newcommand{\pbi}{\parbox[c][0.55cm][c]{1.1cm}{\centering #1}}
\newcommand{\pbii}{\parbox[c][1.1cm][c]{1.1cm}{\centering \textcolor{red}{#1}}}
\newcommand{\pbiii}{\parbox[c][1.1cm][c]{0.55cm}{\centering #1}}

\begin{document}

\begin{tabular}{c|c|c|}
\multicolumn{1}{c}{} & \pbi{30 \hfill  $+$ } & \multicolumn{1}{c}{\pbi{7}}  \\
\cline{2-3}
\pbiii{20 $+$ }&\pbii{600}&  \pbii{140} \\
\hline
\pbiii{3} & \pbii{90} & \pbii{21} \\
\cline{2-3}
\end{tabular}

\end{document}

• Thank you! I like this approach. Jan 21, 2020 at 21:09
• @BuddyKingsGalletti If you remove the plus signs and hte \hfill, the other number will be centred. Jan 21, 2020 at 21:26
• Perfect, thanks again! Jan 22, 2020 at 22:43