[Tex/LaTex] Cannot define new unit with siunitx

siunitx

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{}}}

Best Answer

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?

Related Question