1

Most of the time I work with siunitx package I need to specify only units like: "give the answer in psia".

For achieving this every time I try with \unit{\watt} (W for example) but it produces a !Undefined control sequence. I need to use \SI{}{\watt} but I'm afraid this it's not the proper way.

I use PDFLatex as compiler and my config is like this:

\documentclass[UTF8]{article}

%%%%%%%   Document configuration   %%%%%%%
\usepackage[spanish,es-tabla]{babel}
\decimalpoint
\usepackage[letterpaper, margin=2.5cm]{geometry}
\setlength{\parskip}{1em}
\usepackage{ragged2e}
\usepackage{titlesec}
\titlespacing\section{0pt}{12pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsection{0pt}{8pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
\titlespacing\subsubsection{0pt}{8pt plus 4pt minus 2pt}{0pt plus 2pt minus 2pt}
%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%   Math   %%%%%%%%%%%
\usepackage{amsmath}
\usepackage{siunitx}
\sisetup{per-mode = fraction}
\usepackage{xfrac}
%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%    Custom units     %%%%%%%%%
\DeclareSIUnit\dolar{d\text{ó}lar}
\DeclareSIUnit\fahrenheit{\degree F}
\DeclareSIUnit\feet{ft}
\DeclareSIUnit\pound{lb}
\DeclareSIUnit\btu{BTU}
%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{document}

    I like to output Watt as \unit{\watt}
    
\end{document}

Am I doing something wrong ?

2
  • 1
    What version of siunitx is installed on your device? (You will usually find this in the build log.) According to section 5 in the corresponding manual, you need siunitx version 3 for the new macros to be available. Some more information is available in tex.stackexchange.com/questions/601428.
    – epR8GaYuh
    Aug 31 '21 at 5:18
  • Thank you, I had updated the package a few days ago, but for some reason it failed. and looking at the.log you mentioned, I found out that I still had v2.8 I updated an it works now Aug 31 '21 at 6:21
1

If you have version 2, then \unit is not available and the older name is \si. As I've mentioned in my blog, you can move to the newer interfaces and cover both v2 and v3 by ensuring that the newer names are available

\ifdefined\qty\else
  \ifdefined\NewCommandCopy
    \NewCommandCopy\qty\SI
  \else
    \NewDocumentCommand\qty{O{}mm}{\SI[#1]{#2}{#3}}
  \fi
\fi
\ifdefined\unit\else
  \ifdefined\NewCommandCopy
    \NewCommandCopy\unit\si
  \else
    \NewDocumentCommand\unit{O{}m}{\si[#1]{#2}}
  \fi
\fi

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.