Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- documentclass{scrbook}
- usepackage{chemmacros} % this loads xparse, which supplies NewDocumentCommand{func}{argspec}{code}
- NewDocumentCommand{aeq}{m}{#1~eq.} % equivalents
- begin{document}
- aeq{2.5} % prints 2.5~eq.
- aeq{0.03} % prints 0.03~eq., but I want to have it print 3~mol-%
- end{document}
- documentclass{scrbook}
- usepackage{xparse}
- usepackage{calculator}
- usepackage{ifthen}
- NewDocumentCommand{aeq}{m}{
- ifthenelse{lengthtest{#1pt > 0.1pt}}{#1~eq.}{
- MULTIPLY{#1}{100}{myaeq} % multiply #1 by 100 and store into myaeq
- ROUND[0]{myaeq}{myaeq} % round myaeq to 0 decimal places, because multiply does weird calculations
- myaeq~mol-% % print result
- }
- } % equivalents
- begin{document}
- aeq{2.5} % prints 2.5~eq
- aeq{0.03} % prints 3~mol-%
- aeq{0.9} % prints 0.9~eq
- aeq{0.1} % prints 10~mol-%
- end{document}
Add Comment
Please, Sign In to add comment