Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Is there a way to add multiple lines of numbers using a "summation line"? Specifically, I want to create something like the below, only better looking.

\documentclass{article}
\usepackage{fontspec,booktabs}
\setmainfont{TeX Gyre Termes}

\begin{document}
\begin{tabular}{ @{} c @{ } c @{ } c @{ } c @{ } c @{ } c @{ } c @{} }
$f(x=1)$ & $=$ & $\sum_{y}f(x=1, y)$ & $=$ & $0,2 + 0,1$ & $=$ & 0,3\\
$f(x=2)$ & $=$ & $\sum_{y}f(x=2, y)$ & $=$ & $0,3 + 0,1$ & $=$ & 0,4\\
$f(x=3)$ & $=$ & $\sum_{y}f(x=3, y)$ & $=$ & $0,1 + 0,2$ & $=$ & 0,3\\
           &     &                     &     &             & $+$ &    \\\cmidrule(l){6-7}
           &     &                     &     &             &     & 1,0\\
\end{tabular}
\end{document}

I am not interested in doing row or column based mathematical operations. I just want to create a nicer looking summation rule (instead of the one on the lower right part of the table).

share|improve this question
    
I think tex.stackexchange.com/q/3851/15925 should answer your question. –  Andrew Swann Apr 17 '13 at 12:09
    
Well, no, because my question is about creating a nice looking summation rule (the one on the lower right part) rather than actually doing mathematical operations. –  laissezfaire Apr 17 '13 at 12:27
    
Thanks for the clarification. –  Andrew Swann Apr 17 '13 at 12:31

1 Answer 1

up vote 3 down vote accepted

I am used to the plus being to the right of the last line being summed. This can be acheived with:

Sample output

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{@{}c@{ }c@{ }c@{ }c@{ }c@{ }c@{ }c@{\hspace{0.5em}} c}
$f(1)$ & $=$ & $\sum_{y}f(1, y)$ & $=$ & $0{,}2 + 0{,}1$ & $=$ & 0{,}3 &         \\
$f(2)$ & $=$ & $\sum_{y}f(2, y)$ & $=$ & $0{,}3 + 0{,}1$ & $=$ & 0{,}4 &         \\
$f(3)$ & $=$ & $\sum_{y}f(3, y)$ & $=$ & $0{,}1 + 0{,}2$ & $=$ & 0{,}3 & \( + \) \\ \cmidrule(r){7-8}
       &     &                   &     &             &     & 1{,}0 &         \\
\end{tabular}

\end{document}

adding an extra column to hold the plus sign. I have also written {,} for better spacing on your decimal separator, and removed the x=.

share|improve this answer
    
Looks neat ...although this trades an extra row for an extra column. I guess there is no better way to draw this sort of thing (i.e. using math commands) –  laissezfaire Apr 18 '13 at 5:06
    
By the way, how do you make your LaTeX output appear on the webpage? –  laissezfaire Apr 18 '13 at 5:07
    
For posting output, I convert to an image and upload, see meta.tex.stackexchange.com/q/2781/15925 . As for the layout, if you can make an image/draw what you want, that would be helpful. It is not clear to me whereelse is sensible placing for the + sign. Alternatively you put something like the word "Total" or "Sum" (in the column) before the final result. –  Andrew Swann Apr 18 '13 at 7:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.