I have planed to create SIunits based macro to support SIunits package in my XML conversion process.

In this process i have found few issues while handing the \per command i have tried the following


    \def\cubed{\ifx N\cbicperon\ensuremath{^3}\fi\let\cbicperon=Y}%
    \def\cubic{\ifx N\cbicperon\ensuremath{^3}\fi\let\cbicperon=Y}%
    \def\placesupscript{\ifx Y\cbicperon\ensuremath{^{-3}}\else\ifx Y\sqperon\ensuremath{^{-2}}\else\ifx Y\peron\ensuremath{^{-1}}\fi\fi\fi\let\peron=N\let\cbicperon=N\let\sqperon=N}%








any idea for handing such instance? required output is attached

enter image description here

  • What are all these commands for? Do you want to reimplement siunitx? And what exactly is your issue? – TeXnician May 22 at 5:55
  • yes i want the re-implement in the SIunitx. without using the package – Saravanan.O May 22 at 5:56
  • 2
    @Saravanan.O The unit processor in siunitx is several hundred lines of code: I'm guessing you don't want to do all of that. Could you elaborate on what your wider aim is: I have a feeling this is an 'xy' question. – Joseph Wright May 22 at 6:43
  • In siunitx, I collect up all of the information about units and their superscripts, etc., before creating the output in a second step. You could take the same code and alter the output approach if you want to make XML. Although it's not yet finalised, I'd look at the v3 code here: the unit processor is pretty similar to v2 but a lot clearer. – Joseph Wright May 22 at 6:49
  • 1
    github.com/josephwright/siunitx/blob/master/siunitx-unit.dtx extracts to around 1000 lines. If you don't want all the fancy stuff you could cut that down, but really you are going to struggle in half a dozen lines to cover the same ideas. For superscripts, you have to apply them after the end of the unit, so at the start of the next unit or at the very end of the input. – Joseph Wright May 22 at 7:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.