Open tk-100 opened 1 year ago
A bit tricky because jgm/texmath handles the math conversion, but doesn't have access to the lang metadata.
Oh, I see. Would it be possible to pass pandoc variables to jgm/texmath?
I would suggest something like:
siunitx-locale or siunitx-lang with default "en-US" (or similar)
This variable would then affect the following lines in SIunitx.hs:
parseComma = str "." <$ char ','
parseExp = (\n -> str ("\xa0\xd7\xa0" <> "10") <> superscript n)
Another solution might be to add support for \sisetup
I would like to convert LaTeX files (using siunitx) to Word files and change the standard symbols for "times" (× to ·) and decimal sign (. to ,) , therefore downloaded the source files of pandoc and compiled locally, but I have no idea, where the default symbols are defined within the source. Could you guide me in the right direction? Many thanks in advance!
Another approach, I suppose, would be to have pandoc resolve the sinunitx macros, converting them to regular TeX math, before passing the math to texmath for conversion. In this context pandoc would have access to lang
metadata.
As for \times
, you can simply add a macro definition in your source \newcommand{\times}{\cdot}
or whatever. Pandoc will handle that. But the decimal point can't be remapped so easily.
Unfortunately, redefining \times
did not work for me (and it would not help on changing the decimal sign either).
So in a next step I downloaded texmath
and changed parseNumPart
, ParseComma
and parseExp
accordingly in src/Text/TeXMath/Readers/TeX.hs
. Now (after stack install
) by running texmath
in the command line, the substitutions work perfectly, but not when calling pandoc
. Is there a way to tell pandoc
to use the locally installed version of texmath
? How could I link the local version of texmath
to pandoc
during the compilation of pandoc
?
Sorry for that stupid kind of questions, but I am not used to Haskell and friends. Many thanks in advance!
Is there a way to tell pandoc to use the locally installed version of texmath?
Yes. You'd need to add something to cabal.project (assuming you're using cabal and not stack to compile).
Something like
source-repository-package
type: git
location: https://github.com/jgm/typst-hs
tag: 7e0e80548aae9f3d3059f0dae333e93c8d67f290
but with the location of your texmath for location and the appropriate commit hash for tag.
For stack.yaml, if you're using stack, replace the existing texmath item in extra-deps with something like this, appropriately modified:
- git: https://github.com/jgm/typst-hs
commit: 7e0e80548aae9f3d3059f0dae333e93c8d67f290
Thanks for the quick reply. I was able to use my local install of texmath
to compile a version of pandoc
now using my changed locale settings. Thanks for your help!
Would it be possible to take the language of the current document into account?
Example markdown file:
Used command for conversion:
Output:
I would expect (for locale de-DE):
If a general implementation is too complex - would it be possible to offer options for siunitx? So the users could change the decimal separator and multiplication sign by themselves.