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 do we do this in LaTeX? The main problem is having two rows of values as upper indices.

enter image description here

share|improve this question

5 Answers 5

up vote 5 down vote accepted

Without any package:

MWE

\documentclass{article}
\begin{document}
$\mathrm{shaft}=20^{\begin{array}{@{}c@{}}
\scriptscriptstyle +0.080\\[-7pt]
\scriptscriptstyle +0.005
\end{array}}\mathrm{mm}$
\end{document}
share|improve this answer
2  
If you define the argument of array as @{}c@{} instead of simply as c, you can dispense with the \!\! directives. –  Mico Aug 28 at 5:39
    
@Mico You're absolutely right, what nonsense! –  Fran Aug 28 at 5:50

Sometimes the low-level commands are just nicer in my opinion:

\documentclass{article}
\begin{document}
\[ \mathrm{shaft = 20^{+0.080\atop +0.005} mm} \]
\end{document}

enter image description here

If you use amsmath, it will nag but does compile. However, it has been said it's better to use the higher-level macros with LaTeX, and so borrowing from Gonzalo's answer from a previous question, one might use something like the following with amsmath:

\documentclass{article}
\usepackage{amsmath}
\newcommand\scriptstack[2]{\genfrac{}{}{0pt}{}{#1}{#2}}
%\genfrac{<left-delim>}{<right-delim>}{<thickness>}{<mathstyle>}{<numerator>}{<denominator>}
\begin{document}
\[
  \mathrm{shaft = 20^{\scriptstack{+0.080}{+0.005}} mm}
\]
\end{document}
share|improve this answer
    
You can easily add an amsmath complying answer using \genfrac. –  egreg Aug 28 at 9:17
    
@egreg: thanks, I added that. –  morbusg Aug 28 at 9:27

Try

\documentclass[12pt,preview,border=3mm]{standalone}
\usepackage{amsmath}
%---------------------------------------------------------------%
        \begin{document}
\[\text{shaft} = 20^{\substack{+0.080\\+0.005}}\,\text{mm}\]
        \end{document}

But this is not standard notation for tolerance. For it see siunitx package. Edit: As mentioned Mico, third line arise substack for one line and \scriptscriptstyle make indices smaller: enter image description here Corrected code:

\documentclass[12pt,preview,border=3mm]{standalone}
\usepackage{amsmath}
%---------------------------------------------------------------%
        \begin{document}
\[\text{shaft} = 20^{\substack{\scriptscriptstyle+0.080\\\scriptscriptstyle+0.005\\~}}\,\text{mm}\]
        \end{document}
share|improve this answer
    
I think you may have to add \scriptscriptstyle in front of each element in the substack to make the numbers sufficiently small. Adding a third, empty, row may also be needed to raise the entire substack a bit more. –  Mico Aug 28 at 4:42
    
@Zarko Your solution is good but I prefer the other one –  user11206 Aug 28 at 8:52

Another solution using low level functions:

\documentclass{article}
\usepackage{amsmath,siunitx,xparse}

\NewDocumentCommand{\mySI}{O{}mom}{%
  \IfNoValueTF{#3}
   {\SI[#1]{#2}{#4}}
   {\SI[parse-numbers=false,#1]{\num[parse-numbers=true]{#2}\douncert{#3}}{#4}}%
}

\NewDocumentCommand{\douncert}{m}{%
  ^{%
   \vbox{
     \def\myrow##1{\num{##1}}
     \let\\=\cr\tiny
     \offinterlineskip\lineskip=1pt
     \halign{\myrow{##}\hfil\cr#1\crcr}
   }%
  }%
}

\NewDocumentCommand{\tvar}{m}{\textnormal{#1}}

\begin{document}
\[
\tvar{shaft}=\mySI{20}[+0.080\\+0.005]{mm}
\]
\end{document}

enter image description here

If you use \vcenter instead of \vbox, the result would be

enter image description here

share|improve this answer

If you want something that produces the same vertical spacing as the O.P.'s example, you can try the stackengine package:

\documentclass[12pt,preview,border=3mm]{standalone}
\usepackage{amsmath}
\usepackage{stackengine}
\setstackEOL{\\}

\begin{document}

\[\text{shaft} = 20^{\,\setstackgap{L}{2ex}\everymath{\scriptscriptstyle}\Vectorstack{+0.080\\+0.005}}\,\text{mm}\]

\end{document} 

enter image description here

share|improve this answer

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.