siunitx commands not working inside math, align and tabular modes
BishopWolf opened this issue · 13 comments
inside math or align mode mode:
$T_{1/2}=\qty{8.0197}{days}$
gives the error
[WARNING] Could not convert TeX math T_{1/2}=\qty{8.0197}{days}, rendering as TeX:
T_{1/2}=\qty{8.0197}{days}
^
unexpected control sequence \qty
expecting "%", "\\label", "\\tag", "\\nonumber" or whitespace
inside tabular mode the table is not even rendered.
The problem is the same for all siunitx commands \num ; \qty ; \unit
That's right. We have pretty good support for siunitx in pandoc in text mode:
https://github.com/jgm/pandoc/blob/master/src/Text/Pandoc/Readers/LaTeX/SIunitx.hs
But in math mode, everything is sent to this library.
We'd have to reproduce the work done in pandoc here.
Ideally, a lot of this could be factored out into a subsidiary library that both pandoc and texmath could import, or perhaps an additional exported module in texmath.
Note that we do have some support for siunitx in texmath. Just not complete, e.g. not \qty
.
I've pushed support for \qty
, \unit
, and \qtyrange
.
I've pushed support for
\qty
,\unit
, and\qtyrange
.
Could you suggest where to find the list of the supported siunitx commands ? Could one use \DeclareSIUnit
to define new units in the *.yaml header for markdown input ?
Sorry, \DeclareSIUnit
is not supported.
For current siunitx support in texmath, see https://github.com/jgm/texmath/blob/master/src/Text/TeXMath/Readers/TeX.hs#L1133
Sorry,
\DeclareSIUnit
is not supported. For current siunitx support in texmath, see https://github.com/jgm/texmath/blob/master/src/Text/TeXMath/Readers/TeX.hs#L1133
Would it be possible to support \DeclareSIUnit
in pandoc ? There are a number of units that are popular in the relevant field but not SI.
Are you talking about converting from LaTeX or from markdown with LaTeX math?
Are you talking about converting from LaTeX or from markdown with LaTeX math?
I am talking about converting from markdown with LaTeX math. (Is it correct to assume the markdown format is the best format supported by Pandoc ?)
Complex siunitex stuff will probably work better if you're converting from LaTeX, because then pandoc uses its own fairly complex LaTeX parser. For math in markdown, it goes through the texmath library, which has more limited siunitex support (jgm/texmath).
Support for \DeclareSIUnit
could, in principle, be added to the LaTeX reader, but I don't know how feasible it would be to add it to texmath.
Complex siunitex stuff will probably work better if you're converting from LaTeX, because then pandoc uses its own fairly complex LaTeX parser. For math in markdown, it goes through the texmath library, which has more limited siunitex support (jgm/texmath).
Support for
\DeclareSIUnit
could, in principle, be added to the LaTeX reader, but I don't know how feasible it would be to add it to texmath.
Many thanks for your efforts and comments !
Could you suggest whether LaTeX format is a better source format than markdown format when both Word and PDF are target formats ?
The LaTeX reader of course can only handle a subset of LaTeX. If you can stay within that subset it might work well for you.
The LaTeX reader of course can only handle a subset of LaTeX. If you can stay within that subset it might work well for you.
If markdown format is a better source format when both Word and PDF are target formats, I would think that support for \DeclareSIUnit
in texmath would be very helpful since non-SI units that are popular in specific fields could be used.
but I don't know how feasible it would be to add it to texmath.
Could you help to comment more on the feasibility that concerns you ?
Here's an example I found of the use of \DeclareSIUnit
:
\DeclareSIUnit[per-mode=symbol,per-symbol=p]{\Bps}{\byte\per\second}
It seems to me that you could achieve most of what this gives you in current pandoc using
\newcommand{\Bps}{\byte\per\second}
Have you tried that?