我有这个数组:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath, amsfonts}
\usepackage[thicklines]{cancel}
\title{shortenedExample}
\author{CATboardBETA}
\date{February 2022}
\DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39}
\begin{document}
\Huge
\begin{equation}
\begin{array}{rcccccccc}
& 45 & = & \overbrace{3x}^{\text{small}} & + & \overbrace{5y}^{\text{large}} \\[.4em]
& 10 & = & x & + & y \\
\times & \shortminus3 &&\shortminus3&&\shortminus3 \\
\hline
& \shortminus30 & = & \shortminus3x & + & \shortminus3y \\[1em]
& 45 & = & 3x & + & 5y \\
+ & \shortminus30 & = & \shortminus3x & + & \shortminus3y \\
\hline
& 15 & = & \cancel{0x} & + & 2y \\
& 15 & = & 2y \\[1em]
& 15 & = & 2y \\
& 2 && 2
\end{array}
\end{equation}
\end{document}
我想在 15 和 2 之间以及 2y 和 2 之间显示一条水平线,就像一个分隔线一样。我该怎么做?
我尝试过使用下划线之类的,但看起来不太对。
答案1
使用 \cmidrule
包的命令booktabs
它有一个可选参数,使用括号( )
指定应在哪一侧缩短长度(l)
或(r)
或两者(lr)
。尝试\cmidrule(l{6pt}r{6pt}){2-2}
将两边缩短6pt
。
\documentclass{article}
\usepackage{cancel}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{booktabs} % added <<<<<<<<<<<<<<<<
%From https://tex.stackexchange.com/a/469724/161015
\DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39}
\begin{document}
$\begin{array}{rccccc}
& 45 & = & \overbrace{3x}^{\text{small}} & + & \overbrace{5y}^{\text{large}} \\[.4em]
& 10 & = & x & + & y \\ \times & \shortminus3 & &\shortminus3 & &\shortminus3 \\
\hline
& \shortminus30 & = & \shortminus3x & + & \shortminus3y \\[1em]
& 45 & = & 3x & + & 5y \\
+ & \shortminus30 & = & \shortminus3x & + & \shortminus3y \\
\hline
& 15 & = & \cancel{0x} & + & 2y \\
& 15 & = & 2y & & \\[1em]
&15 & & 2y & & \\ \cmidrule(lr){2-2}\cmidrule(lr){4-4} % added <<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<<<<
& 2 & = & 2 & & \\ %
\end{array}$
\end{document}
答案2
通过使用包tabularrray
。你可能会喜欢 :-)
\documentclass{article}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, booktabs}
\usepackage{amssymb}
\usepackage[thicklines]{cancel}
\DeclareMathSymbol{\shortminus}{\mathbin}{AMSa}{"39}
\begin{document}
\Huge
\[
\begin{tblr}{colspec={rc cc cc},
colsep=3pt,
}
&45 & = & \overbrace{3x}^{\mathrm{small}}
& + & \overbrace{5y}^{\mathrm{large}} \\
&10 & = & x & + & y \\
\times & \shortminus 3
& &\shortminus3
& &\shortminus 3 \\
\hline
& \shortminus30
& = & \shortminus 3x
& + & \shortminus 3y \\
\addlinespace
&45 & = &3x & + & 5y \\
+ & \shortminus30
& = & \shortminus3x
& + & \shortminus 3y \\
\hline
&15 & = & \cancel{0x}
& + & 2y \\
&15 & = &2y & & \\
\addlinespace
&15 & \SetCell[r=2]{c} =
&2y & & \\
\cline{2-2}\cline{4-4}
& 2 & & 2 & &
\end{tblr}
\]
\end{document}
答案3
在 LaTeX 中,array
实现方式与 类似,tabular
因此,在 中可以执行的所有操作tabular
也适用于array
。在本例中,您需要使用\cline
来获取行之间的部分线条(我假设您的意思是水平线而不是垂直线:
\begin{array}{rcccccccc}
& 45 & = & \overbrace{3x}^{\text{small}} & + & \overbrace{5y}^{\text{large}} \\[.4em]
& 10 & = & x & + & y \\
\times & \shortminus3 &&\shortminus3&&\shortminus3 \\
\hline
& \shortminus30 & = & \shortminus3x & + & \shortminus3y \\[1em]
& 45 & = & 3x & + & 5y \\
+ & \shortminus30 & = & \shortminus3x & + & \shortminus3y \\
\hline
& 15 & = & \cancel{0x} & + & 2y \\
& 15 & = & 2y \\[1em]
& 15 & = & 2y
\cline{2-2}\cline{4-4} % ☜ Here's the change
& 2 && 2
\end{array}
也就是说,您可能希望将其设置为分数:
& \frac{15}{2} & = & \frac{2y}{2}