Guest User

Untitled

a guest
Oct 18th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. documentclass{scrbook}
  2.  
  3. usepackage{chemmacros} % this loads xparse, which supplies NewDocumentCommand{func}{argspec}{code}
  4.  
  5. NewDocumentCommand{aeq}{m}{#1~eq.} % equivalents
  6.  
  7. begin{document}
  8. aeq{2.5} % prints 2.5~eq.
  9.  
  10. aeq{0.03} % prints 0.03~eq., but I want to have it print 3~mol-%
  11. end{document}
  12.  
  13. documentclass{scrbook}
  14.  
  15. usepackage{xparse}
  16. usepackage{calculator}
  17. usepackage{ifthen}
  18.  
  19. NewDocumentCommand{aeq}{m}{
  20. ifthenelse{lengthtest{#1pt > 0.1pt}}{#1~eq.}{
  21. MULTIPLY{#1}{100}{myaeq} % multiply #1 by 100 and store into myaeq
  22. ROUND[0]{myaeq}{myaeq} % round myaeq to 0 decimal places, because multiply does weird calculations
  23. myaeq~mol-% % print result
  24. }
  25. } % equivalents
  26.  
  27. begin{document}
  28. aeq{2.5} % prints 2.5~eq
  29.  
  30. aeq{0.03} % prints 3~mol-%
  31.  
  32. aeq{0.9} % prints 0.9~eq
  33.  
  34. aeq{0.1} % prints 10~mol-%
  35. end{document}
Add Comment
Please, Sign In to add comment