0

I have this array:

\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}

I would like to display an horizontal line between the 15 and 2, and between the 2y and 2, as in a division bar. How can I do this?

I tried just using underlines and the like, but they never looked right.

4
  • 1
    How or where is \shortminus defined?
    – Mico
    Feb 14, 2022 at 17:23
  • 1
    Please extend your code fragment to small compilable document.
    – Zarko
    Feb 14, 2022 at 17:24
  • @Zarko will this suffice? Feb 14, 2022 at 20:23
  • Yes, now is much better.
    – Zarko
    Feb 14, 2022 at 20:50

3 Answers 3

2

Use the \cmidrule command of the package booktabs

It has an optional argument using parentheses ( ) to specify on which side it should be reduced in length (l) or (r) or both (lr). Try \cmidrule(l{6pt}r{6pt}){2-2} to shorten both sides by 6pt.

d

\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}
3
  • I would use a dfrac, but I would like to only have the equals on the bottom (not the middle) Feb 14, 2022 at 20:15
  • @CATboardBETA Sorry for my misunderstanding. I updated my answer. Feb 14, 2022 at 20:38
  • That looks much better, thank you. Feb 14, 2022 at 20:43
2

By use of the package tabularrray. You may like :-)

\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}

enter image description here

1

In LaTeX array is implemented similarly to tabular so all the things you can do in a tabular will also work with array. In this case, you'll want to use \cline to get a partial line between rows (I'm assuming you meant horizontal and not vertical:

\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}

That said, you probably want to set this as a fraction:

& \frac{15}{2} & = & \frac{2y}{2}
1
  • Can I change the length of \cline so it doesn't span the entire column? It looks strangely long Feb 14, 2022 at 20:21

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .