7

I would like to define a unit to render

\SI{5}{\degTTh}

as

enter image description here

So far, I've been able to define a new unit

\DeclareSIUnit{\degTTh}{%
 \text{$^\circ\ 2\theta$}%
}

but there is a space between the numeral and the degree sign. Using the option \SI[space-before-unit=false]{5}{\degTTh} doesn't resolve the issue.

I've also tried declaring

\DeclareSIUnit{\TTh}{%
 \text{$\ 2\theta$}%
}

and then using \SI[space-before-unit=false]{5}{\degree\TTh}, but this also results in a space between the numeral and degree symbol.

.

How can I define such a unit?

  • Quick dirty fix: place a \! (it's a negative space in math mode) in your 1st definition ==> \text{$\!^\circ\ 2\theta$}% – alwaysask Aug 9 '16 at 6:49
11

When creating a new unit with siunitx, you can override any key-value pair option by supplying it in the <options> field in

\DeclareSIUnit[<options>]{<unit>}{<definition>}

The symbol between the number and the unit is set with number-unit-product. In your case, you want to have no symbol between number and unit, i.e. {}. The definition of your unit then becomes

\DeclareSIUnit[number-unit-product={}]{\degTTh}{\SIUnitSymbolDegree\ensuremath{~2\theta}}

Additionally, I replaced the ^\circ with the symbol \SIUnitSymbolDegree, which is defined by siunitx. Finally, I replaced the $ ... $ with \ensuremath, as suggested in the package documentation.

\documentclass{article}
\usepackage{siunitx}

\setlength{\parindent}{0pt}    % only to make all examples aligned.

\DeclareSIUnit{\degTThold}{\text{$^\circ\ 2\theta$}}
\DeclareSIUnit[number-unit-product={}]{\degTTh}{\SIUnitSymbolDegree\ensuremath{~2\theta}}

\begin{document}

\SI{5}{\degTThold} \\
\SI{5}{\degTTh} \\
$x = \SI{5}{\degTThold}$ \\
$x = \SI{5}{\degTTh}$

\end{document}

resulting output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.