5

My task is to obtain what's being attached. The code too is appended. Any help is much appreciated.

enter image description here

 \begin{minipage}[]{0.5\textwidth}
\textbf{Step}
\begin{enumerate}
    \item $a=b$
    \item $a^2=ab$
    \item $a^2-b^2=ab-b^2$
    \item $(a-b)(a+b)=b(a-b)$
    \item $a+b=b$
    \item $2b=b$
    \item 2=1
\end{enumerate}
\end{minipage}
\begin{minipage}[]{0.5\textwidth}
\textbf{Reason} \\
Given\\
Multiply both sides of (1) by $a$\\
Substract $b^2$ from both sides of (2)\\
Factor both sides of (3)\\
Divide both sides of (4) by $a-b$\\
Replace $a$ by $b$ in (5) because $a=b$ and simplify\\
Divide both sides of (6) by $b$
\end{minipage}
Eureka
  • 1,013

5 Answers5

6

Here's a possibility:

\documentclass[12pt]{article}
\newcounter{aux}
\newcommand*{\al}{\stepcounter{aux}\theaux.\ }
\pagestyle{empty}
\begin{document}
\begin{center}
  \renewcommand*{\arraystretch}{1.2}
  \begin{tabular}{p{.46\textwidth}p{.46\textwidth}}
    \textbf{Step}&\textbf{Reason}\\
    \al $a=b$&Given\\
    \al $a^2=ab$&Multiply both sides of (1) by $a$\\
    \al $a^2-b^2=ab-b^2$&Subtract $b^2$ from both sides of (2)\\
    \al $(a-b)(a+b)=b(a-b)$&Factor both sides of (3)\\
    \al $a+b=b$&Divide both sides of (4) by $a-b$\\
    \al $2b=b$&Replace $a$ by $b$ in (5) because $a=b$ and simplify\\
    \al $2=1$&Divide both sides of (6) by $b$
  \end{tabular}
\end{center}
\end{document}

It will give you this:

enter image description here

6

The following is similar to the answer of José Carlos Santos but automates as much as possible utilizing the array package.

It automatically inserts \mystep at the start of each line (this will step a counter and insert it), and turns the contents of the first column into maths.

\documentclass[]{article}

\usepackage{array} \usepackage{tabularx}

\newcolumntype\math[1]{>{$}#1<{$}} \newcolumntype{L}{>{\raggedright\arraybackslash}X}

\newcounter{mystep} \renewcommand\themystep{\arabic{mystep}.} \newcommand\mystep{\refstepcounter{mystep}\themystep} \newcommand*\resetmystep{\setcounter{mystep}{0}}

\begin{document} \noindent \begin{tabularx}{\linewidth}{>{\mystep\quad}\math{l} L} \multicolumn{1}{l}{\textbf{Step}} & \textbf{Reason}\% \multicolumn cancels the \mystep\quad and the \math column a=b & Given \ a^2=ab & Multiply both sides of (1) by $a$\ a^2-b^2=ab-b^2 & Substract $b^2$ from both sides of (2)\ (a-b)(a+b)=b(a-b) & Factor both sides of (3)\ a+b=b & Divide both sides of (4) by $a-b$\ 2b=b & Replace $a$ by $b$ in (5) because $a=b$ and simplify\ 2=1 & Divide both sides of (6) by $b$ \end{tabularx} \end{document}

enter image description here

Skillmon
  • 60,462
  • 2
    +1. I would recommend using \refstepcounter instead of \stepcounter, though, just in case the OP ever wants to cross-reference list entries via the usual \label-\ref mechanism. – Mico Dec 11 '21 at 12:04
  • @Mico yes, that seems like a good idea. – Skillmon Dec 11 '21 at 12:05
3

There is a solution with OpTeX:

\newcount\trownum
\def\printrow{\ifnum\trownum>0 \hbox to1em{\hss\bf\the\trownum.}\else\tabiteml={}\fi\incr\trownum}

\table{(\printrow$)l($)l}{ \bf Step & \bf Reason \cr a=b & Given \cr a^2=ab & Multiply both sides of (1) by $a$ \cr a^2-b^2=ab-b^2 & Substract $b^2$ from both sides of (2) \cr (a-b)(a+b)=b(a-b) & Factor both sides of (3) \cr a+b=b & Divide both sides of (4) by $a-b$ \cr 2b=b & Replace $a$ by $b$ in (5) because $a=b$ and simplify \cr 2=1 & Divide both sides of (6) by $b$ } \bye

And here is a solution with plain TeX and TeX primitives:

\newcount\trownum
\def\printrow{\global\advance\trownum by1 \hbox to1em{\hss\bf\the\trownum.}}

\vbox{\halign{\printrow\enspace$#$\hfil\quad &#\hfil\cr \omit\bf Step & \bf Reason \cr a=b & Given \cr a^2=ab & Multiply both sides of (1) by $a$ \cr a^2-b^2=ab-b^2 & Substract $b^2$ from both sides of (2) \cr (a-b)(a+b)=b(a-b) & Factor both sides of (3) \cr a+b=b & Divide both sides of (4) by $a-b$ \cr 2b=b & Replace $a$ by $b$ in (5) because $a=b$ and simplify \cr 2=1 & Divide both sides of (6) by $b$ \cr }} \bye

wipet
  • 74,238
1

Here is a solution with {NiceTabular} of nicematrix. That environment has its own LaTeX counter for the rows, called iRow. Moreover, there is a mechanism of ``first row''. When the key first-row is set, the first row of the tabular correspond to the value 0 of the counter iRow (that's what you need here). Moreover, the command \OnlyMainNiceMatrix gives the ability to execute an instruction only in the main tabular (not in the so-called first row).

\documentclass{article}
\usepackage{nicematrix}

\begin{document} \noindent \begin{NiceTabular}{>{\OnlyMainNiceMatrix{\arabic{iRow}.\quad}}l X[l]}[first-row] \RowStyle{\bfseries} Step & Reason \ $a=b$ & Given \ $a^2=ab$ & Multiply both sides of (1) by $a$\ $a^2-b^2=ab-b^2$ & Substract $b^2$ from both sides of (2)\ $(a-b)(a+b)=b(a-b)$ & Factor both sides of (3)\ $a+b=b$ & Divide both sides of (4) by $a-b$\ $2b=b$ & Replace $a$ by $b$ in (5) because $a=b$ and simplify\ $2=1$ & Divide both sides of (6) by $b$ \end{NiceTabular} \end{document}

Output of the above code

F. Pantigny
  • 40,250
1

A solution with tabularray package and its rownum function:

\documentclass[margin=3mm]{standalone}
\usepackage{tabularray}

\begin{document} \begin{tblr}{colspec = {l Q[l, mode=math] X[l]}, cell{2-Z}{1} = {cmd=\the\numexpr\arabic{rownum}-1.}, row{1} = {mode=text, font=\bfseries} } & Step & Reason \ & a=b & Given \ & a^2=ab & Multiply both sides of (1) by $a$\ & a^2-b^2=ab-b^2 & Substract $b^2$ from both sides of (2)\ & (a-b)(a+b)=b(a-b) & Factor both sides of (3)\ & a+b=b & Divide both sides of (4) by $a-b$\ & 2b=b & Replace $a$ by $b$ in (5) because $a=b$ and simplify\ & 2=1 & Divide both sides of (6) by $b$ \end{tblr} \end{document}

enter image description here

Zarko
  • 296,517