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.

I am a beginner in LaTeX, trying to use it for an industrial test report. I have numerous tables in my document, and I have recently discovered the capabilities of siunitx. I would like to use S column whenever possible. I have tentatively modified one table to experiment, but I find that the options I have choosen make a table with fairly large columns and some no longer fit the page. Also, it does not seem the S columns are well centered in the attached example. What fix can be applied?

\documentclass[a4paper, oneside,11pt, english, numbers=noenddot, captions=tableheading]{scrreprt} 
\usepackage[T1]{fontenc} % Usual fonts
\usepackage{tgheros,textcomp}% Fonts
\usepackage{siunitx}% Handling Si units
\usepackage{tabularx} % More elaborate form of tables
\usepackage{multirow} %handling of fusionned cells in tables
\renewcommand{\familydefault}{\sfdefault}%selecting default font (clone of helvetica)
%-----------------------------------------------------------------
%BEGIN CONFIG 2 CAVITIES--------------
\newcommand{\ConfigTwoGang}[3]{%
AAAAAAA &   1-20        &#1     &1-20       &#1\\
BBBBBBBB    &   1-8     &#2     &1-20       &#1\\
CCCCCCC&    1-20        &#1     &Power      &#3\\
}%
%-------------------------------------------------------
%END CONFIG 2 CAVITIES--------------
%------------------------------------------------------
% BEGIN INSERT  TABLE TWO CAV 
\newcommand{\TableIRTwoGang}[4]{%
\begin{table}[#4]%
\noindent 
\begin{center}
\sisetup{table-number-alignment=center,table-figures-integer = 4}
\caption{Insulation resistance (\si{\mega\ohm}) - 2 gang versions}
\begin{tabular}{|c|cS[table-comparator = true]|cS[table-comparator = true]|}
\hline
\multirow{2}{*}{Part number}&\multicolumn{2}{c|}{{Cavity 1}}&\multicolumn{2}{c|}{{Cavity 2}}\\
%\hline
&Position&{Ins. Res.}&Position&{Ins. Res.}\\
\hline\hline
\ConfigTwoGang{#1}{#2}{#3}%
\hline
\end{tabular}
\end{center}
\end{table}
}%
%------------------------------------------------------
\begin{document}
\TableIRTwoGang{> 1500}{> 2000}{> 5000}{H}
\end{document}
share|improve this question

1 Answer 1

up vote 5 down vote accepted

What fix can be applied?

In the MWE you provide, you make only minimal use of the capabilities of the S column type that's provided by the siunitx package. In such a case, it may be best to just use the instruction

\sisetup{table-parse-only}

and omit all further options. The following, slightly modified form of your MWE shows that with this option in place, the contents of the two S columns are nicely centered, which is what I understand you want.

enter image description here

\documentclass[a4paper, oneside, 11pt, english, 
   numbers=noenddot, captions=tableheading]{scrreprt} 
\usepackage[T1]{fontenc}
\usepackage{tgheros,textcomp}% Fonts
\usepackage{siunitx}% Handling Si units
\usepackage{tabularx} % More elaborate form of tables
\usepackage{multirow} %handling of fused cells in tables
\renewcommand{\familydefault}{\sfdefault}%select default font (clone of helvetica)

\newcommand{\ConfigTwoGang}[3]{%
  AAAAAAA  &   1-20    &#1   &1-20    &#1\\
  BBBBBBBB &   1-8     &#2   &1-20    &#1\\
  CCCCCCC  &   1-20    &#1   &Power   &#3\\
}

\newcommand{\TableIRTwoGang}[4]{%
  \begin{table}[#4]%
    \sisetup{table-parse-only}
    \caption{Insulation resistance (\si{\mega\ohm}) --- 2 gang versions}
    \centering
    \begin{tabular}{|c|cS|cS|}
      \hline
      \multirow{2}{*}{Part number}
        & \multicolumn{2}{c|}{Cavity 1}
        & \multicolumn{2}{c|}{Cavity 2}\\
        & Position & {Ins.\ Res.} 
        & Position & {Ins.\ Res.}\\
      \hline\hline
      \ConfigTwoGang{#1}{#2}{#3}%
      \hline
    \end{tabular}
  \end{table}
}

\begin{document}
\TableIRTwoGang{> 1500}{> 2000}{> 5000}{H}
\end{document}

A separate comment: With your current font choice commands, viz.,

\usepackage{tgheros}
\renewcommand{\familydefault}{\sfdefault}

you end up having (a clone of) Helvetica as the text font and Computer Modern Sans as the math font. An inspection of the weights and shapes of the characters in columns 1, 2, and 4 vs. those in columns 3 and 5 reveals some differences; these differences aren't drastic, but they are noticeable. (For instance, the glyph "1" has a "footer" in Computer Modern Sans but has no footer in Helvetica.) Some people may find the use of two different sans-serif fonts within one table a bit distracting. If you need to use sans-serif fonts throughout your document, you may want to employ the arev font package, which sets both text and math fonts in a sans-serif font which, IMHO, is very well suited for the display of numeric material in tables. The image below shows the same table as before, but now with the command \usepackage{arev} used in lieu of \usepackage{tgheros}:

enter image description here

share|improve this answer
    
Thanks a lot. This looks much better. It seems my original options were not optimum for some reason. Using S columns gave the > sign a much more suitable glyph, a more uniform alignment in tables and some other nice ways to format the numbers properly, as I use other Siunitx options in other tables, but I had not seen this problem. Concerning the math font, I use \usepackage{sfmath} in my preamble to eliminate math fonts everywhere, but this is not a standard package, and I have removed it from the MWE. –  Yves Feb 21 '12 at 20:10
    
The use of \usepackage{tgheros} had been suggested to me by Joseph Wright as a solution to a problem I had with the Ohm symbol not matching well the helvetica font. I have not heard of arev before, but will give it a try. Rgds –  Yves Feb 21 '12 at 20:20
    
Good idea to use the sfmath package, as you'll now get Helvetica consistently in both text and math. If you have very different layout needs in different tables, I'd venture to opint that it's probably a good idea to keep the global \sisetup options to a minimum and, instead, use separate \sisetup commands inside each table environment. –  Mico Feb 21 '12 at 20:20
    
I agree it is not easy to distinguish what \sisetup options should go to the preamble and which ones should go in every table... The large number of tables I have in the document leads me to try to put as much as possible in the general options.... –  Yves Feb 21 '12 at 20:22
    
Well, as the second table image shows, the arev package has its own shortcoming: no Ohm symbol either! In consequence, this symbol has to be "borrowed" from Computer Modern (Roman) as well. Not perfect, for sure. The combination of tgheros and sfmath should do the trick for you. –  Mico Feb 21 '12 at 20:23

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.