| 1 | initial version |
I'm trying to create something more like the command \SI{number}{units} of siunitx package but I have some trouble.
Starting with the answer of @Juanjo I'm arrived here:
\begin{sagesilent}
def SIsage(number,units=0):
if units==0:
if number in ZZ or number.parent()==QQ:
return r"\SI{"+ str(number) + "}"
else:
return r"\SI{"+ str(float(number)) + "}"
else:
if number in ZZ or number.parent()==QQ:
return r"\SI{"+ str(number) + "}" +"{"+ units + "}"
else:
return r"\SI{"+ str(float(number)) + "}" +"{"+ units + "}"
\end{sagesilent}
\sagestr{SIsage(2442,"\kilo\metre\squared")}
\sagestr{SIsage(2442)}
and it works except when using \newton witch it become "ewton" problably cause to \n
After this I want to create a new custom LaTeX command that replace \SI{}{} but I have some trouble with non-default arguments. I didn't understand how them work. I want be able to use both of \SI{number}{units} that \SI{number} without units. Probably the best choise is to create two different commands(?)
\newcommand{\SIsage_units}[1]{,"#1"}
\newcommand{\SIsage_number}[1]{\sagestr{SIsage(#1}}
\newcommand{\SISAGE}[2]{\SIsage_number{#2}\SIsage_units{#1})} #doesn't work
The command I want:
\SISAGE{21}{\kilo\metre\squared}
\SISAGE{26}{}
So my problems are:
\n\SISAGEThanks everybody
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.