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.

How can I move the summation equation that appears at the bottom of column 3 to be centered with the column 3rd column. Using \hspace hasn't been successful thus far.

\begin{tabular}{ccr@{\hspace{1pt}=\hspace{1pt}}r} 
$X_j$&$f_j$&\multicolumn{1}{r}{$f_jX_j$}\\

\hline

28&1&(1)(28)&28\\
27&0&(0)(27)&0\\
26&1&(1)(26)&26\\
25&2&(2)(25)&50\\
24&3&(3)(24)&72\\
23&4&(4)(23)&92\\
22&3&(3)(22)&66\\
21&0&(0)(21)&0\\
20&1&(1)(20)&20\\
19&2&(2)(19)&38\\
18&1&(1)(18)&18\\
17&0&(0)(17)&0\\
16&1&(1)(16)&16\\
15&0&(0)(15)&0\\
14&1&(1)(14)&14\\

\hline

&$n=20$& \multicolumn{1}{c}{$\displaystyle\sum^{k}_{j=1}f_jX_j=440$}

\end{tabular}

image

share|improve this question
    
Using & $n=20$ & $\displaystyle\sum^{k}_{j=1}f_jX_j$ & 440 for the last row seems to be what you need? –  Gonzalo Medina Aug 28 '12 at 21:20
    
That does work for this example. Thank you for the fresh eyes, I thought I had already done that. Is it possible to shift the alignment of the summation function independent of the =? I hoped there would be a way using \multicolumn –  Daniel Aug 28 '12 at 21:26
    
OT: The $k$ above the summation should be changed to $n$. –  Aditya Aug 28 '12 at 21:37
add comment

3 Answers 3

up vote 5 down vote accepted

For proper spacing in your "equation" setup, you need to use something like @{${}={}$} (in order to make it a true relation). I've updated your tabular to use this, as well as inserting the total:

enter image description here

\documentclass{article}
\begin{document}
\begin{tabular}{ccr@{${}={}$}r} 
  $X_j$ & $f_j$ & \multicolumn{1}{c}{$f_jX_j$} \\
  \hline
  28 & 1 & (1)(28) & 28 \\
  27 & 0 & (0)(27) &  0 \\
  26 & 1 & (1)(26) & 26 \\
  25 & 2 & (2)(25) & 50 \\
  24 & 3 & (3)(24) & 72 \\
  23 & 4 & (4)(23) & 92 \\
  22 & 3 & (3)(22) & 66 \\
  21 & 0 & (0)(21) &  0 \\
  20 & 1 & (1)(20) & 20 \\
  19 & 2 & (2)(19) & 38 \\
  18 & 1 & (1)(18) & 18 \\
  17 & 0 & (0)(17) &  0 \\
  16 & 1 & (1)(16) & 16 \\
  15 & 0 & (0)(15) &  0 \\
  14 & 1 & (1)(14) & 14 \\
  \hline
  & $n=20$ & $\displaystyle\sum^{k}_{j=1}f_jX_j$ & $440$
\end{tabular}
\end{document}​
share|improve this answer
    
Can be improved by correting \multicolumn{1} to \multicolumn{2} in the first row. –  Hans-Peter E. Kristiansen Aug 28 '12 at 21:35
add comment

You can add some padding before the third column and hide the width of the big summation:

\documentclass{beamer}
\usepackage{array}
\begin{document}
\begin{frame}
\begin{tabular}{cc@{\hspace{4em}}r@{}>{${}={}$\hfill}r}
$X_j$&$f_j$&\multicolumn{1}{c}{$f_jX_j$}\\
\hline
28&1&(1)(28)&28\\
27&0&(0)(27)&0\\
26&1&(1)(26)&26\\
25&2&(2)(25)&50\\
24&3&(3)(24)&72\\
23&4&(4)(23)&92\\
22&3&(3)(22)&66\\
21&0&(0)(21)&0\\
20&1&(1)(20)&20\\
19&2&(2)(19)&38\\
18&1&(1)(18)&18\\
17&0&(0)(17)&0\\
16&1&(1)(16)&16\\
15&0&(0)(15)&0\\
14&1&(1)(14)&14\\
\hline
&$n=20$&\hidewidth$\displaystyle\sum^{k}_{j=1}f_jX_j=440$\hidewidth\hfil
\end{tabular}
\end{frame}
\end{document}

Experiment with the size of the spacing until the result is satisfying

enter image description here

share|improve this answer
add comment

Make sure that all the lines have the same number of columns. -and only use \multicolumn when the cell is spanning more than one column.

\documentclass[10pt]{article}
\begin{document}

\begin{tabular}{ccr@{\hspace{1pt}=\hspace{1pt}}r} 

$X_j$&$f_j$&\multicolumn{2}{c}{$f_jX_j$}\\

\hline

28&1&(1)(28)&28\\
27&0&(0)(27)&0\\
26&1&(1)(26)&26\\
25&2&(2)(25)&50\\
24&3&(3)(24)&72\\
23&4&(4)(23)&92\\
22&3&(3)(22)&66\\
21&0&(0)(21)&0\\
20&1&(1)(20)&20\\
19&2&(2)(19)&38\\
18&1&(1)(18)&18\\
17&0&(0)(17)&0\\
16&1&(1)(16)&16\\
15&0&(0)(15)&0\\
14&1&(1)(14)&14\\

\hline

& $n=20$ & $\displaystyle\sum^{k}_{j=1}f_jX_j$ & 440

\end{tabular}
\end{document}

table

share|improve this answer
    
Werner's answer is better than mine. –  Hans-Peter E. Kristiansen Aug 28 '12 at 21:32
add comment

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.