WeAreSeismica / tex2jats

SCE tools: Convert galleys from TeX to JATS XML
GNU General Public License v3.0
4 stars 4 forks source link

\siunitx package conversion to xml #16

Open abhineetgupta opened 11 months ago

abhineetgupta commented 11 months ago

Use of \siunitx package is partially supported, and can cause uncaught errors that create rendering issues.

  1. When the conversion works, it works as intended within the xml - it uses the correct unicode characters for range (--), spacing between numbers and units, and adding degree symbol. Not using the siunitx commands, and only using text does not preserve these items.
  2. Problem mainly appears to be in the combination of siunitx commands with the math mode. Examples - a. \SIrange{1}{2}{\km} is converted and rendered correctly but \$ M > \SIrange{1}{2}{\km}\$ is not. Both are rendered correctly in Latex. b. \ang{65} is converted and rendered correctly but \$ L > \ang{65}\$ is not. c. \SI{\sim 10}{\km} converts to \sim 10 km in XML, which is not as intended.
  3. Another issue was observed in unit declarations. Example - Declaring year as \DeclareSIUnit\year{yr} in the Latex file worked correctly in the PDF, but yr symbol was completely missing in the converted xml.
hfmark commented 4 months ago

I've encountered this SI + math mode issue as well - a somewhat annoying workaround is to try and regex the \SI{}{} pieces out of $$ in the tex file before running tex2jats. A simple example of this is in seismica-sce/extras/clean_tex_submission.py. It only really works when the \SI{}{} part is at the end of in-line math, though, and that specific python script will likely need ad hoc changes for what is allowed to be in the rest of the math mode section.