# Adding math operator beside \cline

## Update:

Here's what I meant. This was created in spreadsheet for demo purpose only. I just don't know how to achieve this using LaTeX.

...and here's my .tex file.

\documentclass{article}
\usepackage{mathtools}
\begin{document}

\begin{align*}
\text{Item A} &= 750 \\
\text{Item B} &= 500 \\
\text{Item C} &= 1,500\\
\cline{2-1}
\text{Total} &= 2,750 \\
\end{align*}

\end{document}


I need to add a + sign on the right side. I also need the numbers to be right-aligned like in sample image above. I've read about this somewhere online but forget the link/url.

## Original question:

How to add math operator, i.e. (+) beside \cline in an equation?

\documentclass{article}
\usepackage{mathtools}
\begin{document}

\begin{align*}
a &= 2\\
b &= 3 \\
\cline{1-2}
c &= 5
\end{align*}

\end{document}


I wouldn't use an align* environment. The array environment provides far more flexibility.

\documentclass{article}
\usepackage{amsmath} % for \text macro
\begin{document}
$\begin{array}{r@{}r} & a = 2\\ & b = 3 \\ +\,& \text{--{}--{}--{}--{}--{}}\\ & c = 5 \end{array}$
\end{document}


\documentclass{article}
\usepackage{amsmath,array}
\newcolumntype{C}{>{{}}c<{{}}}
\begin{document}
$\setlength\arraycolsep{0pt} \begin{array}{r C r @{\;} C} \text{Item A} &=& 750 \\ \text{Item B} &=& 500 \\ \text{Item C} &=& 1,500 \\ & & \text{--{}--{}--{}--{}--{}} & + \\ \textbf{Total} &=& \text{\fontseries{b}\selectfont 2{,}750} \\ \end{array}$
\end{document}

• I just updated my question. tks. – guest_5758 Mar 1 '17 at 10:54
• @guest_5758 - I've posted an addendum to my answer. – Mico Mar 1 '17 at 11:58
• The addendum version works great! I just didn't expect the code would be that long. I thought it would be as simple as using \cline and + or something like that.. :-) – guest_5758 Mar 7 '17 at 3:04

You can use a tabular, with some tricks for making the spaces correct:

\documentclass{article}
\usepackage{mathtools,array}

\begin{document}

\begin{equation*}
\begin{tabular}{@{}l@{}>{${}}c<{{}$}@{}r@{}l@{}}
\text{Item A} &=& 750 \\
\text{Item B} &=& 500 \\
\text{Item C} &=& 1,500\\
\cline{3-3}
&&&\raisebox{1.4ex}[0pt][0pt]{$\;+$}\\[-\normalbaselineskip]
\bfseries\text{Total} &=& \fontseries{b}\selectfont 2,750 \\
\end{tabular}
\end{equation*}

\end{document}


• @Mico Of course! – egreg Mar 1 '17 at 11:47