我大部分时间都和希尼奇包我只需要指定类似这样的单位:“用 psia 给出答案”。
为了实现这一点,每次我尝试\unit{\watt}
(例如 W),但它会产生一个!未定义的控制序列。我需要使用\SI{}{\watt}
但我担心这不是正确的方法。
我使用 PDFLatex 作为编译器,我的配置如下:
\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}
难道我做错了什么 ?
答案1
如果你有版本 2,那么\unit
不可用,旧名称是\si
。正如我所料在我的博客中提到,您可以转到较新的界面和确保新名称可用,从而涵盖 v2 和 v3
\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