我的任务是获取附件。代码也已附加。任何帮助都将不胜感激。
\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}
答案1
有以下可能性:
\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}
它会给你这个:
答案2
以下类似于何塞·卡洛斯·桑托斯的回答array
但利用该包尽可能实现自动化。
它会自动\mystep
在每行的开头插入(这将步进一个计数器并将其插入),并将第一列的内容转换为数学运算。
\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}
答案3
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
以下是使用纯 TeX 和 TeX 原语的解决方案:
\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
答案4
带有包的解决方案tabularray
及其rownum
功能:
\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}