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.

Using the following MWE :

\documentclass[12pt,a4paper]{report}
\usepackage[lmargin=3.81cm,tmargin=2.54cm,rmargin=2.54cm,bmargin=2.52cm]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{multirow}

\begin{document}


\begin{table}[H]
    \caption{Power levels of Background loads}
    \parskip-5pt
        \centering
    \begin{tabular}{llS[table-format=4.0]}
    \toprule
    \multicolumn{2}{c}{\textbf{Loads}} & \textbf{Power Consumption} (\si{kWh})\\
    \midrule
    \textbf{Background} & Fans (Slide) & 350\--- 600\--- 750 \\ 
    & Dehumidifier (Therm)  & 500\--- 620\--- 785  \\ 
    & Refrigerator (Therm) & 480\--- 580\--- 725 \\ 
    & Heater (Therm) & 750\--- 1000\--- 1500 \\ 
    \bottomrule
    \end{tabular} 
    \label{powertable2}
\end{table}

\end{document}

I get the following table :

enter image description here

But when I remove the dashes I get :

enter image description here

As you can see in the second pic, the numbers are centered. I want the numbers to remain centered even when I use the dashes \---. Why do they indent to the right when dashes are added ?

share|improve this question
    
why don't you use -- instead of \---? –  Mario S. E. Apr 27 '13 at 19:28
2  
The S column is meant for one number, not many. Just use three S. By the way, \--- is not the same as --- (an em-dash), in fact \--- is an optional hyphen (\-) and an en-dash --. –  Qrrbrbirlbel Apr 27 '13 at 19:28
    
@MarioS.E. I get a siuntix error if I do that –  Razor Apr 27 '13 at 19:31
    
@Qrrbrbirlbel But I don't want to split into 3 columns (is that was adding extra S's do ? ) I tried that and the table blew out of proportions. –  Razor Apr 27 '13 at 19:32
    
@Razor Well, either that, or manual adjusting. S does not work that way. –  Qrrbrbirlbel Apr 27 '13 at 19:35

1 Answer 1

up vote 3 down vote accepted

The S column does only parse one number, you will need to use three S columns with the dash between them, e.g.

\begin{tabular}{llS@{--}S@{--}S}

but the problem is the wide column heading Power Consumption (kWh) which (even combined with \multicolumn) doesn't work well with three very small columns.

For such simple values, this might be easier.

Code

\documentclass[12pt,a4paper]{report}
\usepackage[lmargin=3.81cm,tmargin=2.54cm,rmargin=2.54cm,bmargin=2.52cm]{geometry}
\usepackage{booktabs}
\usepackage{siunitx}
\usepackage{multirow}
\newcommand*{\0}{\hphantom{0}}
\begin{document}
\begin{table}[H]
    \caption{Power levels of Background loads}
%    \parskip-5pt
        \centering
    \begin{tabular}{llc}
        \toprule
            \multicolumn{2}{c}{\textbf{Loads}}     & \textbf{Power Consumption} (\si{kWh}) \\ \midrule
        \textbf{Background} & Fans (Slide)         &           350--\0600--\0750           \\
                            & Dehumidifier (Therm) &           500--\0620--\0785           \\
                            & Refrigerator (Therm) &           480--\0580--\0725           \\
                            & Heater (Therm)       &            750--1000--1500            \\ \bottomrule
    \end{tabular} 
    \label{powertable2}
\end{table}
\end{document}

Output

enter image description here

share|improve this answer
    
Thank you very much. I didn't expect it to be this difficult (compared to MS Word that is). I would have never guessed how to do this :S –  Razor Apr 27 '13 at 19:42

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.