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 new to LaTeX, tentatively using it to prepare a complicated industrial document (laboratory test report). Thanks to help recently obtained here, I have discovered the magnificent capabilities of siunitx such as the S column option for tables. I have just begun to use this option in the table attached. I have seen that tolerancing was another option of siunitx, but apparently only for symmetrical values, i.e., +-X. I wonder how to improve the visual appearance of the toleranced temperatures, as I do not think my current solution is optimal. Any help appreciated, as I have a large number of such tables in my document.

\documentclass[a4paper, oneside,11pt, english]{report} % Mode production
\usepackage[top=25mm, bottom=25mm, left=20mm, right=20mm]{geometry} %Layout of page
%Source encoding--------------------------------------------------------------------
\usepackage[utf8]{inputenc} % UTF-8 encoding for code editing
%end source encoding---------------------------------------------------------------
%fonts--------------------------------
\usepackage[T1]{fontenc} % Usual fonts
\usepackage{tgheros,textcomp}% Fonts
\usepackage[helvet]{sfmath} % Using helvetica font for maths, instead of default.

%SI Units--------------------------------------------------
\usepackage{siunitx}% Handling Si units
%end SI units----------------------------------------------------
%document layout-----------------------
\usepackage{float} % Floating figures and tables
\usepackage[margin=10pt, font=bf]{caption} % Setting options for captions
%end document layout------------------------
%------------------------------------------------------------------------
% [DEFINITION OF GLOBAL CONFIGURATION AND VARIABLES  ]-------------------
%------------------------------------------------------------------------
% Special options for SI units and tolerancing---------------------------
\sisetup{output-decimal-marker={,}}% Selection of coma for separator
\sisetup{detect-all}% Complement to Si units, aligning format of numbers with text
\sisetup{exponent-product=\cdot}
\newcommand{\tol}[3]{\ensuremath{\si{#1}^{\thinspace+\num{#2}}_{-\num{#3}}}} %Formula for tolerancing
% End special options for SI units and tolerancing---------------------------------
% Font option selection-------------------------
\renewcommand{\familydefault}{\sfdefault}%selecting default font (clone of helvetica)
%\renewcommand{\familydefault}{phv}\selectfont %selecting default font (helvetica)
% End font option selection--------------
% [END DEFINITION OF GLOBAL CONFIGURATION AND VARIABLES  ]----------------------------
%------------------------------------------------------------------------------------
\begin{document}
\begin{table}[H]
\noindent \begin{center}
\caption{\label{Fluids}Fluids}
\begin{tabular}{|l|c|c|S|S|c|}
\hline
Fluid&Fluid \#&Immersion&{Fluid}&{Stowing}& Number\\
Category&per&Duration&{temperature} &{temperature}&of\\ &MIL-XXX&(minutes)&{(\si{\degreeCelsius})}&{(\si{\degreeCelsius})}&cycles\\
\hline\hline
Fluid type 1 &2&\phantom{1} \tol{5}{2}{0}&25&85&4\\ 
Mineral hydraulic fluid&5&\tol{15}{5}{0}&80&100&6\\
Synthetic hydraulic fluid&3&\tol{15}{5}{0}&85&100&5\\ 
Mineral lubricant&7&\tol{15}{5}{0}&120&125&6\\
Cooling fluid&19&\tol{15}{5}{0}&50&25&5\\ 
\hline
\end {tabular} 
\end{center} 
\end{table}

\end{document}
share|improve this question

1 Answer 1

I would simply define the tolerance as follows:

  \def\tol#1#2#3{\hbox{\rule{0pt}{15pt}${#1}^{+{#2}}_{-{#3}}$}}

The macro adds a strut to space out the rows a bit. This is just a rule with a zero width.

Also for complicated tables, it is worth defining shorthand macros for \phantom; I normally use \Z, \ZZ for one or two phantom spaces.

  \def\Z{\phantom{1}}
  \def\ZZ{\phantom{11}}

Inserting into your code produced this,

enter image description here

Joseph Wright might have a better solution using the siunitx.

share|improve this answer
    
Thanks. In fact I had mistakenly removed the following line: \renewcommand{\arraystretch}{1.2} in order to make a minimal example. My concern was primarily the vertical alignment. In your example, the lower and upper tolerances appear perfectly aligned, and the minus sign seems to have about the same length as the plus sign. (It is much longer in my configuration). Perhaps my problem is created by the option: \usepackage[helvet]{sfmath}, which I need to eliminate math fonts from my document, as they do not fit well in an industrial document, and particularly in the mid of a table... –  Yves Feb 4 '12 at 18:26
    
@Yves I did remove the sfmath as it was not in my distribution. From the sfmath manual ... the font metrics are not adjusted to maths usage, so it is better to remove them. –  Yiannis Lazarides Feb 4 '12 at 18:32
    
An alternative to sfmath is the mathastext package -- which is still a bit of a hack but gives pretty good alignment when I tried it (to be specific I put \usepackage[scaled=0.92]{helvet}\renewcommand*\familydefault{\sfdefault}\usepac‌​kage{mathastext}) –  Ant Feb 6 '12 at 19:06
    
@Ant Thanks for the comment, never used mathastext I will give it a try. –  Yiannis Lazarides Feb 6 '12 at 21:25
    
Thanks to Ant and all. Ironically, mathsastext is not included in my distribution (while sfmath is) However when I had tried to compile on my office computer the file calling sfmath, I had to install it manually. I therefore anticipate I will find mathastex available on my office distribution, and will certainly try your suggestion. –  Yves Feb 7 '12 at 18:22

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.