6

I've been reading almost two hours through various posts that seem to have the same problem but none of the solutions worked for me.
I want to define new units (in my case it's \thermal and \electrical).
Is it possible that scrartcl has something to do with it?
Or does a package interfere with it?
Here is my preamble:

\documentclass{scrartcl}  
\usepackage[utf8]{inputenc}  

\usepackage{amsmath}  
\usepackage{amssymb}  
\usepackage[german]{babel}  
\usepackage{graphicx}  
\usepackage{floatrow}  
\usepackage{subfigure}  
%\pagestyle{empty}  
\linespread{1.5}  
\usepackage[margin=3.5cm]{geometry}  
\usepackage{color}  

\usepackage{siunitx}  
    \sisetup{inter-unit-product =$\cdot$}  

\usepackage{cancel}  
\usepackage{float}  
\usepackage{enumitem}  
\usepackage{caption}  
\usepackage{booktabs}  
\usepackage{cleveref}  
\usepackage{colortbl}  
\usepackage{csquotes}  
\usepackage{helvet}  
\usepackage{mathpazo}  
\usepackage{listings}  
\usepackage{pgfplots}  
\usepackage{xcolor}  
\usepackage{hyperref}  

\usepackage{multirow}  

\renewcommand{\labelitemii}{$\circ$}  
\renewcommand{\labelitemiii}{$\diamond$}  
\renewcommand{\labelitemiv}{$\ast$}  

\allowdisplaybreaks  

\numberwithin{equation}{subsection} %Gleichungen bekommen die     SubKapitelnummer  

\DeclareSIUnit{\thermal}{t}  
\DeclareSIUnit{\electrical}{e}  

I get the following error:

! Missing } inserted.  
<inserted text>  
                }  
l.72 ...-1000 betrug \SI{3200}{\mega\watt\thermal}  

?  

I already tried the following:
\DeclareSIUnit{\thermal}{t}
\DeclareSIUnit\thermal{t}

and so on; spaces, no spaces, braces,... \newunit\thermal{t} isn't even recognized.
If you need additional information I'll post it. Thanks for reading this.

EDIT: Full minimal example

\documentclass{scrartcl}
\usepackage[utf8]{inputenc}  
\usepackage{siunitx}  
    \sisetup{inter-unit-product =$\cdot$}
\usepackage{amsmath}  
\usepackage{booktabs}  
\usepackage{cancel}  
\usepackage{caption}  
\usepackage{cleveref}  
\usepackage{colortbl}  
\usepackage{csquotes}  
\usepackage{helvet}  
\usepackage{mathpazo}  
\usepackage{multirow}  
\usepackage{listings}  
\usepackage{pgfplots}  
\usepackage{xcolor}  

\DeclareSIUnit{\thermal}{t}  
\DeclareSIUnit{\electrical}{e}  
\begin{document}  
\SI{3200}{\mega\watt} \\  
\SI{3200}{\mega\watt\thermal}  
\end{document}  

Error message:

! Missing } inserted.  
<inserted text>   
                }  
l.23 \SI{3200}{\mega\watt\thermal}  

?   

Update: I get an error if I include
\sisetup{inter-unit-product =$\cdot$}
I also deleted it from my original preamble and it works now.

Thank you all for helping, here is the line that I'm using now (for those who might encounter the same problem as me):
\sisetup{inter-unit-product=\ensuremath{{}\cdot{}}}

  • Do you mind making a full minimal example so we have something that we can copy and test immediately – daleif Feb 9 '16 at 21:02
  • @Cancara: Your updated MWE doesn't produce an error, but has the space. Has your problem changed now? – Werner Feb 9 '16 at 21:20
  • @Werner Thanks for your comment. Sorry, didn't make it clear in the post: The error does not occur at the MWE but at my original preamble. Now, I don't know what it is in my preamble that causes the mentioned error. – Cancara Feb 9 '16 at 21:25
  • The thin space between MW and t when using \mega\watt\thermal is placed there by design, since it is a multiplication of units. – hooy Feb 9 '16 at 21:29
  • That is why it is called a minimal example, it should of course show the problem. Creating the mwe is also a valuable debugging tool, where one often ends up finding the error. – daleif Feb 9 '16 at 21:29
8

siunitx prints the units inside \ensuremath (like the other components). This allows one to typeset the output inside math or text mode where math mode would be automatically enabled if necessary. However, forcing math mode inside \ensuremath causes a problem, as is replicated by this simple minimal example:

\documentclass{article}
\begin{document}
$x \cdot y$

\ensuremath{x \cdot y}

%\ensuremath{x $\cdot$ y}% <---- this is a problem
\end{document}

With this in mind, define your SI unit without switching to math mode:

\sisetup{inter-unit-product=\cdot}

If you wish to reduce the space between the operands of the product, then use

\sisetup{inter-unit-product=\mathord{\cdot}}

Here's a minimal example showing the different output:

enter image description here

\documentclass{article}
\usepackage{siunitx}

\DeclareSIUnit{\thermal}{t}

\begin{document}

\sisetup{inter-unit-product=\cdot}

\SI{3200}{\mega\watt\thermal}

\sisetup{inter-unit-product=\mathord{\cdot}}

\SI{3200}{\mega\watt\thermal}

\end{document}

As reference for the spacing around \cdot and the application of \mathord, see How to change default for spacing around binary relations?

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.