jgm / texmath Goto Github PK
View Code? Open in Web Editor NEWA Haskell library for converting LaTeX math to MathML.
License: GNU General Public License v2.0
A Haskell library for converting LaTeX math to MathML.
License: GNU General Public License v2.0
Hi, I'm trying to install pandoc via cabal and the installation fails when trying to install texmath. Some possibly relevant version numbers:
$ cabal --version
cabal-install version 1.16.0.2
using version 1.16.0 of the Cabal library
$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 7.6.3
I'm working on Ubuntu 14.04.
Here's what I get:
$ cabal install pandoc
Resolving dependencies...
Configuring texmath-0.8.3...
Building texmath-0.8.3...
Preprocessing library texmath-0.8.3...
[ 1 of 18] Compiling Text.TeXMath.Unicode.ToASCII ( src/Text/TeXMath/Unicode/ToASCII.hs, dist/build/Text/TeXMath/Unicode/ToASCII.o )
[ 2 of 18] Compiling Text.TeXMath.TeX ( src/Text/TeXMath/TeX.hs, dist/build/Text/TeXMath/TeX.o )
[ 3 of 18] Compiling Text.TeXMath.Compat ( src/Text/TeXMath/Compat.hs, dist/build/Text/TeXMath/Compat.o )
[ 4 of 18] Compiling Text.TeXMath.Readers.MathML.EntityMap ( src/Text/TeXMath/Readers/MathML/EntityMap.hs, dist/build/Text/TeXMath/Readers/MathML/EntityMap.o )
Failed to install texmath-0.8.3
cabal: Error: some packages failed to install:
pandoc-1.15.0.6 depends on texmath-0.8.3 which failed to install.
texmath-0.8.3 failed during the building phase. The exception was:
ExitFailure 139
Does anyone have some advice? Thanks for any light you can shed on this problem.
best,
Robert Dodier
https://github.com/jgm/texmath/blob/master/Text/TeXMath/Parser.hs#L243
Shouldn't this be multline
instead of multiline
?
This MWE compiles fine in latex.
\documentclass{article}
\begin{document}
$$
{\mbox{\boldmath $\theta $}}_2||^2
$$
\end{document}
However, pandoc fails when reading it:
$ pandoc -f latex problem.tex -o test.xml
pandoc:
Error at "source" (line 5, column 33):
unexpected "^"
expecting "%", lf new-line, "\\", "{", "-", "``", "\8220", "\"`", "\"", "`", "\8216", "''", "\8221", "'", "\8217", "~", "$$", "$", "^^", "&" or \end{document}
{\mbox{\boldmath $\theta $}}_2||^2
If, however, the $$
delimiters are changed to \begin{displaymath}
, then it works fine.
(from jgm/pandoc#3164)
note to self
also extra grouping on base of superscript
The following LaTeX math does not render correct when converted through pandoc to docx:
\begin{equation} \label{eq:num} \frac{\delta^2 u}{\delta D \delta t} = \overbrace{\overbrace{u_R(\cdot)}^{+}\overbrace{R_{Dt}(\cdot)}^{?}}^{A}+ \overbrace{\overbrace{R_t(\cdot)}^{+}(\overbrace{\overbrace{u_{RR}(\cdot)}^{-}\overbrace{R_D(\cdot)}^{-}}^{+}+ \overbrace{\overbrace{K'(D)}^{+}\overbrace{u_{KR}(\cdot)}^{+}}^{+})}^{B} \end{equation}
The overbraces are missing, but the +/- signs do appear in the proper positions. I was asked in the Google Groups to submit this issue here.
Decimal point isn't properly handle.
$ pandoc --mathml <<EOF
\$0.1\$
EOF
<p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0</mn><mo>.</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">0.1</annotation></semantics></math></p>
<p><math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0.1</mn></mrow><annotation encoding="application/x-tex">0.1</annotation></semantics></math></p>
Instead of <mn>0</mn><mo>.</mo><mn>1</mn>
we should have <mn>0.1</mn>
.
$ uname -a
Linux pupunha 3.19.3-3-ARCH #1 SMP PREEMPT Wed Apr 8 14:10:00 CEST 2015 x86_64 GNU/Linux
$ cd /path/to/texmath
$ git log -1
commit f0499d0652c9e68f0e2c8ea5601a217b88528de5
Author: John MacFarlane <[email protected]>
Date: Sun Apr 12 20:35:34 2015 -0700
Updated changelog.
$ cd /path/to/pandoc
$ git log -1
commit 4b2f469994143728c2ffe22aa37370b90a054e15
Merge: 55b7afc 7031748
Author: John MacFarlane <[email protected]>
Date: Wed Apr 29 16:17:40 2015 -0700
Merge pull request #2123 from hellofloat/master
Added woff2 to MIME types
Using the MathML writer, this works:
\DeclareMathOperator{\den}{den}
but this:
\DeclareMathOperator{\den}{\mathsf{den}}
produces visible occurrences of \operatorname{\mathsf{den}}
all over the text. I thought this might be because the parser for \DeclareMathOperator
wrongly expects only a string in the second brackets, but it works as expected with the MathJax writer: the operator gets rendered in sans-serif.
I also tested this in LaTeX to make sure \DeclareMathOperator really accepts something besides simple strings for the operator name, and it does. Here is proof:
\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\den}{\mathsf{den}}
\begin{document}
$\den t = \den t'$
\end{document}
Not sure if it simply isn't ready to be commited to remote, but the head of pandoc
won't build because this is newest version is not in public repo.
See pandoc#2571. Thanks!
The input in pandoc markdown
text $a+\alpha$
when fed to the command
pandoc -f markdown t --mathml -o t.xml
results in
<p>text <math display="inline" xmlns="http://www.w3.org/1998/Math/MathML"><mrow><mi>a</mi><mo>+</mo><mo>α</mo></mrow></math></p>
i.e., the alpha is presented as operator while the MathML 3.0 spec says in 3.2.3.3:
The names of symbolic constants should be represented as mi elements:
<mi> π<!--GREEK SMALL LETTER PI--> </mi>
<mi> ⅈ<!--DOUBLE-STRUCK ITALIC SMALL I--> </mi>
<mi> ⅇ<!--DOUBLE-STRUCK ITALIC SMALL E--> </mi>
texmath's MathML output will only align the first two columns in something like this:
$$\begin{align}
a &= b & c &= d
\end{align}$$
That is, it will only align the "a" and "b" columns. It ought to align "c" and "d" as well.
Expected behavior: align
& friends allow multiple equations per line, and align each column around alternate ampersands, like AMSLaTeX does.
Here is the MML output (produced by Pandoc) of the snippet above:
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mtable>
<mtr>
<mtd columnalign="right">
<mi>a</mi>
</mtd>
<mtd columnalign="left">
<mo>=</mo>
<mi>b</mi>
</mtd>
<mtd>
<mi>c</mi>
</mtd>
<mtd>
<mo>=</mo>
<mi>d</mi>
</mtd>
</mtr>
</mtable>
<annotation encoding="application/x-tex">\begin{align} a &= b & c &= d \end{align}</annotation>
</semantics>
</math>
I think the second two mtd
's (and any others) ought also to have columnalign
attributes set.
Reference: https://groups.google.com/forum/#!topic/pandoc-discuss/faM55dIJDI0
The following example breaks;
\newcommand{\vecx}{a + b}
which results in
In these cases, it has to be grouped
when the macro is expanded.
pandoc -f markdown -t html <<<'The probability is $p=0.7$.'
<p>The probability is <span class="math"><em>p</em> = 0. 7</span>.</p>
TeXMath always considers a dot to be punctuation (ESymbol Pun "."
) even if it's inside a decimal number.
Speculation: I don't know what exactly LaTeX is doing -- if it simply never adds any space after a dot, the fix should be easy. If there are cases where it adds a space and cases where it doesn't, TeXMath might need to reproduce its algorithm.
Related: the space added after ESymbol Op
also seems a bit fishy, though I'm not sure what's the intended behavior. For example, in $\sum_{k=0}^n 2k$
I would expect a space before the 2
, not immediately after the ∑
. But I guess this is a separate issue from the decimal point problem, and depending on how complicated LaTeX's behavior is, it might not be worth emulating.
The following, which requires \usepackage{amssymb}
in LaTeX itself, doesn't seem to work in texmath:
$\boldsymbol{\alpha}$
\underset{a}{b}
should place a
under b
.
Hi,
The texmath tests run fine with xml 1.3.10. With xml 1.3.12
the texmath tests fail, the results are included below (for
ghc 7.2.2, they also fail with ghc 7.4.1-rc1). This is with:
LANG=en_AU.UTF-8
LC_CTYPE=en_AU.UTF-8
Unpacking source...
Unpacking texmath-0.5.0.4.tar.gz to /var/tmp/portage/dev-haskell/texmath-0.5.0.4/work
Source unpacked in /var/tmp/portage/dev-haskell/texmath-0.5.0.4/work
Preparing source in /var/tmp/portage/dev-haskell/texmath-0.5.0.4/work/texmath-0.5.0.4 ...
Source prepared.
Configuring source in /var/tmp/portage/dev-haskell/texmath-0.5.0.4/work/texmath-0.5.0.4 ...
/var/tmp/portage/dev-haskell/texmath-0.5.0.4/work/texmath-0.5.0.4/Setup.hs:1:1:
Warning: In the use of `runTests'
(imported from Distribution.Simple, but defined in Distribution.Simple.UserHooks):
Deprecated: "Please use the new testing interface instead!"
Linking setup ...
./setup configure --ghc --prefix=/usr --with-compiler=/usr/bin/ghc --with-hc-pkg=/usr/bin/ghc-pkg --prefix=/usr --libdir=/usr/lib64 --libsubdir=texmath-0.5.0.4/ghc-7.2.2 --datadir=/usr/share/ --datasubdir=texmath-0.5.0.4/ghc-7.2.2 --with-haddock=/usr/bin/haddock --enable-library-profiling --ghc-option=-optl-Wl,-O1 --ghc-option=-optl-Wl,--as-needed --disable-executable-stripping --docdir=/usr/share/doc/texmath-0.5.0.4 --verbose --flags=-cgi --flags=test
Configuring texmath-0.5.0.4...
Flags chosen: test=True, cgi=False
Dependency base ==4.*: using base-4.4.1.0
Dependency containers -any: using containers-0.4.1.0
Dependency parsec >=2: using parsec-3.1.2
Dependency syb -any: using syb-0.3.6
Dependency xml -any: using xml-1.3.12
Using Cabal-1.11.1.20110721 compiled by ghc-7.2
Using compiler: ghc-7.2.2
Using install prefix: /usr
Binaries installed in: /usr/bin
Libraries installed in: /usr/lib64/texmath-0.5.0.4/ghc-7.2.2
Private binaries installed in: /usr/libexec
Data files installed in: /usr/share/texmath-0.5.0.4/ghc-7.2.2
Documentation installed in: /usr/share/doc/texmath-0.5.0.4
Using alex version 3.0.1 found on system at: /usr/bin/alex
Using ar found on system at: /usr/bin/ar
Using c2hs version 0.16.3 found on system at: /usr/bin/c2hs
Using cpphs version 1.12 found on system at: /usr/bin/cpphs
No ffihugs found
Using gcc version 4.5.3 found on system at: /usr/bin/gcc
Using ghc version 7.2.2 given by user at: /usr/bin/ghc
Using ghc-pkg version 7.2.2 given by user at: /usr/bin/ghc-pkg
No greencard found
Using haddock version 2.9.4 given by user at: /usr/bin/haddock
Using happy version 1.18.8 found on system at: /usr/bin/happy
No hmake found
Using hsc2hs version 0.67 found on system at: /usr/bin/hsc2hs
Using hscolour version 1.19 found on system at: /usr/bin/HsColour
No hugs found
No jhc found
Using ld found on system at: /usr/bin/ld
No lhc found
No lhc-pkg found
No nhc98 found
Using pkg-config version 0.26 found on system at: /usr/bin/pkg-config
Using ranlib found on system at: /usr/bin/ranlib
Using strip found on system at: /usr/bin/strip
Using tar found on system at: /bin/tar
Using texmath found on system at: dist/build/texmath/texmath
Using texmath-cgi found on system at: dist/build/texmath-cgi/texmath-cgi
No uhc found
Source configured.
Compiling source in /var/tmp/portage/dev-haskell/texmath-0.5.0.4/work/texmath-0.5.0.4 ...
./setup build
Building texmath-0.5.0.4...
Preprocessing executable 'texmath' for texmath-0.5.0.4...
[1 of 6] Compiling Text.TeXMath.Types ( Text/TeXMath/Types.hs, dist/build/texmath/texmath-tmp/Text/TeXMath/Types.o )
[2 of 6] Compiling Text.TeXMath.MathML ( Text/TeXMath/MathML.hs, dist/build/texmath/texmath-tmp/Text/TeXMath/MathML.o )
[3 of 6] Compiling Text.TeXMath.Parser ( Text/TeXMath/Parser.hs, dist/build/texmath/texmath-tmp/Text/TeXMath/Parser.o )
[4 of 6] Compiling Text.TeXMath.Macros ( Text/TeXMath/Macros.hs, dist/build/texmath/texmath-tmp/Text/TeXMath/Macros.o )
[5 of 6] Compiling Text.TeXMath ( Text/TeXMath.hs, dist/build/texmath/texmath-tmp/Text/TeXMath.o )
[6 of 6] Compiling Main ( texmath.hs, dist/build/texmath/texmath-tmp/Main.o )
Linking dist/build/texmath/texmath ...
Preprocessing library texmath-0.5.0.4...
[1 of 5] Compiling Text.TeXMath.Macros ( Text/TeXMath/Macros.hs, dist/build/Text/TeXMath/Macros.o )
[2 of 5] Compiling Text.TeXMath.Types ( Text/TeXMath/Types.hs, dist/build/Text/TeXMath/Types.o )
[3 of 5] Compiling Text.TeXMath.MathML ( Text/TeXMath/MathML.hs, dist/build/Text/TeXMath/MathML.o )
[4 of 5] Compiling Text.TeXMath.Parser ( Text/TeXMath/Parser.hs, dist/build/Text/TeXMath/Parser.o )
[5 of 5] Compiling Text.TeXMath ( Text/TeXMath.hs, dist/build/Text/TeXMath.o )
[1 of 5] Compiling Text.TeXMath.Macros ( Text/TeXMath/Macros.hs, dist/build/Text/TeXMath/Macros.p_o )
[2 of 5] Compiling Text.TeXMath.Types ( Text/TeXMath/Types.hs, dist/build/Text/TeXMath/Types.p_o )
[3 of 5] Compiling Text.TeXMath.MathML ( Text/TeXMath/MathML.hs, dist/build/Text/TeXMath/MathML.p_o )
[4 of 5] Compiling Text.TeXMath.Parser ( Text/TeXMath/Parser.hs, dist/build/Text/TeXMath/Parser.p_o )
[5 of 5] Compiling Text.TeXMath ( Text/TeXMath.hs, dist/build/Text/TeXMath.p_o )
Registering texmath-0.5.0.4...
./setup haddock --hyperlink-source
Running Haddock for texmath-0.5.0.4...
Running hscolour for texmath-0.5.0.4...
Preprocessing executable 'texmath' for texmath-0.5.0.4...
Preprocessing library texmath-0.5.0.4...
Warning: The documentation for the following packages are not installed. No
links will be generated to these packages: ffi-1.0, rts-1.0, syb-0.3.6
Preprocessing executable 'texmath' for texmath-0.5.0.4...
Preprocessing library texmath-0.5.0.4...
Haddock coverage:
75% ( 3 / 4) in 'Text.TeXMath.Macros'
20% ( 1 / 5) in 'Text.TeXMath.Types'
25% ( 1 / 4) in 'Text.TeXMath.MathML'
100% ( 2 / 2) in 'Text.TeXMath.Parser'
33% ( 1 / 3) in 'Text.TeXMath'
Documentation created: dist/doc/html/texmath/index.html
./setup haddock --hoogle
Running Haddock for texmath-0.5.0.4...
Warning: The documentation for the following packages are not installed. No
links will be generated to these packages: ffi-1.0, rts-1.0, syb-0.3.6
Preprocessing executable 'texmath' for texmath-0.5.0.4...
Preprocessing library texmath-0.5.0.4...
Haddock coverage:
75% ( 3 / 4) in 'Text.TeXMath.Macros'
20% ( 1 / 5) in 'Text.TeXMath.Types'
25% ( 1 / 4) in 'Text.TeXMath.MathML'
100% ( 2 / 2) in 'Text.TeXMath.Parser'
33% ( 1 / 3) in 'Text.TeXMath'
Documentation created: dist/doc/html/texmath/texmath.txt
Source compiled.
Test phase [cabal test]: dev-haskell/texmath-0.5.0.4
./setup test
Test 01 FAILED (< expected, > actual):
13c13
< −
<mo>−</mo>
15c15
< ±<mo>±</mo>
22c22
< −<mo>−</mo>
Test 02 FAILED (< expected, > actual):
18c18
< −<mo>−</mo>
22c22
< ×<mo>×</mo>
27c27
< −<mo>−</mo>
Test 03 PASSED
Test 04 FAILED (< expected, > actual):
18c18
< −<mo>−</mo>
24c24
< −<mo>−</mo>
Test 05 FAILED (< expected, > actual):
10c10
< ∫<mo>∫</mo>
18c18
< ∫<mo>∫</mo>
34c34
< ∫<mo>∫</mo>
44c44
< −<mo>−</mo>
Test 06 FAILED (< expected, > actual):
10c10
< ∑<mo>∑</mo>
16c16
< ∞<mo>∞</mo>
19c19
< ∑<mo>∑</mo>
25c25
< ∞<mo>∞</mo>
Test 07 FAILED (< expected, > actual):
10c10
< ʺ<mo>ʺ</mo>
17c17
< ʹ<mo>ʹ</mo>
Test 08 FAILED (< expected, > actual):
9c9
< ∣<mo stretchy="false">∣</mo>
12c12
< ‾<mo accent="true">‾</mo>
14c14
< ∣<mo stretchy="false">∣</mo>
16c16
< ∣<mo stretchy="false">∣</mo>
18c18
< ∣<mo stretchy="false">∣</mo>
20c20
< ∣<mo stretchy="false">∣</mo>
24c24
< ‾<mo accent="true">‾</mo>
30c30
< ∣<mo stretchy="false">∣</mo>
32c32
< ∣<mo stretchy="false">∣</mo>
35c35
< ∣<mo stretchy="false">∣</mo>
Test 09 FAILED (< expected, > actual):
13c13
< →<mo>→</mo>
Test 10 FAILED (< expected, > actual):
10c10
< φ14c14<mi>φ</mi>
hey, can you post binary distribution as installing all the dependencies is too much
Support \providecommand
for defining macros.
E.g.
X^2 = \sum_{ij} \frac{(Y_{ij}-E_{ij})^2}{E_{ij}} \approx \chi^2_{(k-1)(m-1)} \text{under $H_0$}
(from jgm/pandoc#1178)
See pandoc 1809
$$\mathbf{V}_1 \times \mathbf{V}_2 =
\begin{vmatrix}
\mathbf{i} & \mathbf{j} & \mathbf{k} \\ \hline
\frac{\partial X}{\partial u} & \frac{\partial Y}{\partial u} & 0 \\
\frac{\partial X}{\partial v} & \frac{\partial Y}{\partial v} & 0 \\
\end{vmatrix}$$
This matrix can be correctly displayed in latex and mathjax. But when converting to docx from markdown, it fails.
Without the \hline is OK.
Commit ca1ca5f looks like it was meant to include Text/TeXMath/Pandoc.hs
, but neglected to
I think the arguments are the wrong way round somewhere in the OMML reader.
pandoc -f tex -t omml | pandoc -f omml -t tex
In:
\overset{r}{\rightarrow}
Out:
\overset{\rightarrow}{r}
e.g. \mathbf{\infty}
.
While
First off, apologies since this seems to be a bug in LibreOffice, but it's triggered by texmath's output format and has a relatively easy fix here.
The formula
\sum_{i=1}^100 x = \frac{100*101}{2}
Is rendered incorrectly in LibreOffice
Using x + 1 (in parentheses) renders to
The formula is rendered correctly when opened in MS Office.
TexMath generates the following XML:
<m:nary>
<m:naryPr>
<m:chr m:val="∑" />
<m:limLoc m:val="undOvr" />
<m:subHide m:val="off" />
<m:supHide m:val="off" />
</m:naryPr>
<m:e>
<m:r>
<m:rPr />
<m:t>x</m:t>
</m:r>
</m:e>
<m:sub>
(i = 1)
</m:sub>
<m:sup>
(100)
</m:sup>
</m:nary>
LibreOffice seems to expect the <m:e>
part to appear after the <m:sub>
and <m:sup>
part, changing the order makes the formula render correctly:
<m:nary>
<m:naryPr>
<m:chr m:val="∑" />
...
</m:naryPr>
<m:sub>
(i = 1)
</m:sub>
<m:sup>
(100)
</m:sup>
<m:e>
<m:r>
<m:rPr />
<m:t>x</m:t>
</m:r>
</m:e>
</m:nary>
Again, this seems to be a bug in LibreOffice, but the change required in texmath is relatively straightforward:
--- a/src/Text/TeXMath/Writers/OMML.hs
+++ b/src/Text/TeXMath/Writers/OMML.hs
@@ -223,7 +223,7 @@ makeNary props t s y z w =
, mnodeA "supHide"
(if z == EGrouped [] then "on" else "off") ()
]
- , mnode "e" $ showExp props w
, mnode "sub" $ showExp props y
- , mnode "sup" $ showExp props z ]
+ , mnode "sup" $ showExp props z
+ , mnode "e" $ showExp props w]
This breaks the testcases of course, but I can have a look at them & submit a pull request if you like.
Cheers,
Niko
At the moment, when there is in an equation array underneath an operator (say, a sum over two variables), it is written as an array or matrix, e.g.
\[\sum_{\begin{matrix}
{0\leq\ i\ \leq\ m} \\
{0<j<n\ } \\
\end{matrix}}^{}{P\left( {i,j} \right)}\]
That produces the ranges in full-size. amsmath provides \substack
for this, which makes the output a lot nicer.
In the MathML writer,
$$a\text{ and }b$$
renders like
aand b
The MathJax writer correctly renders it like:
a and b
The MML output is:
<math xmlns="http://www.w3.org/1998/Math/MathML" display="block">
<semantics>
<mrow>
<mi>a</mi>
<mrow>
<mtext mathvariant="normal">and</mtext>
<mspace width="0.333em"/>
</mrow>
<mi>b</mi>
</mrow>
<annotation encoding="application/x-tex">a\text{ and }b</annotation>
</semantics>
</math>
It should have another mspace
before the mtext
.
When you render
$\top \otimes t = t$
to MathML, \top
outputs as <mo>⊤</mo>
(an operator) rather than <mi>⊤</mi>
(an identifier). According to Knuth's TeXbook, Appendix F, Section 4(page 435 in my edition), \top
has type Ord(inary), so (according to my sketchy understanding of MML) it should output as mi
.
You might want to double-check the rest of the macros/symbols in the table on that page as well, such as \bot
. In particular, I also noticed that \backslash
typesets differently than /
, which might be due to the same issue; perhaps it is intended, but MathJax typesets both slashes in the same way. (n.b. \backslash
is different from \setminus
.)
John's comments:
This is all done by the texmath library (jgm/texmath on
github). I see the following in the table for control
sequences:, ("\\top", ESymbol Ord "\x22A4")
An ESymbol Ord is rendered as an mo element.
We could change this to EIdentifier "\x22A4", and it would
always be an mi. This probably makes sense. You can submit
a bug report on jgm/texmath, so I don't lose track of the
issue.(There is probably a reason it was ESymbol Ord, but I don't
recall what it was.)You can submit another issue to support \mathord.
Both of these should be fairly simple changes.
Reference: https://groups.google.com/forum/#!topic/pandoc-discuss/faM55dIJDI0
When converting from pandoc markdown to docx.
Subscript and superscript in \mathbf
, like \mathbf{x^1}
or \mathbf{x_1}
can not be recognized. _
and ^
are translated to normal text.
If using $$\mathbf{x^{1}}$$
, the conversion is failed.
I use pandoc to write notes during lectures and make heavy use of inline Tex math. While I use kokoi for live preview during editing, which produces html5 files including MathML formulas, the end result shall be saved as pdf using XeLaTex.
I encountered that math containing symbols from amsmath isn't redered to MathML.
Example:
$5 \equiv 1 (\mod{2})$
where \mod{}
is part of amsmath.
First, is it even possible to render amsmath symbols in MathML or doesn't MathML itself support it? Second, are there plans to support MathML output of amsmath in texmath?
Regards
When writing in LaTeX the next expression:
texmath does not produce the output in MathML. See the reference:
The following input is rendered to \acute{F}
when it is rendered with a hat (ie \hat{F}
) in word.
(Personal line reference: 117148)
<m:oMath>
<m:acc>
<m:accPr>
<m:ctrlPr>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:i/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
</m:ctrlPr>
</m:accPr>
<m:e>
<m:r>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<m:t>
F</m:t>
</m:r>
</m:e>
</m:acc>
</m:oMath>
somehow on certain invocations of the build process for the texmath package, if GHC is configured to use clang rather than GCC, clang will consume >= 1gb of memory on assembling/compiling certain modules, whereas GCC seems to max out at needing ~ 1/2gb.
I realize this is probably an upstream problem, but making you aware of it none the less, because it will likely impact some of your users
Please support \operatorname{\mathcal{L}}
. See pandoc#2571 for details. Thanks!
The one OMML entity that can't be translated is <m:borderBox>
, which draws a box around an expression. It's usually used for highlighting equations in textbooks and the like.
This has representations in both LaTeX and mathml. The standard LaTeX version would be \boxed{...}
, available in amsmath. In mathml, the notation is <menclose notation="box">...</menclose>
.
For the sake of completeness (so close) and because the translation is fairly straightforward, I'd love to see this in. (NB. that the OMML and mathml versions can both support only showing some edges of the box. Not sure of the best way to do this in LaTeX, or if implementing that is worth the trouble.)
When writing in LaTeX the next expression:
texmath does not produce the output in MathML. See the reference:
http://www.w3.org/TR/MathML2/chapter4.html#contm.notprsubset
Hello there. I found there is an issue about converting mathml to latex.When the mathml marks contain a line break like
<mspace linebreak="newline"/>
. There is no corresponding line break in the latex marks, so the latex marks will not break the line.
Will you fix it? THX!
At the least, these should be skipped
See jgm/pandoc#3362 where it is noted by @jgm that I should file a separate bug against the texmath package. See the zip file in the preceding pandoc bug report.
In the following example <w:sym w:font="Symbol" w:char="F0CE"/>
is ignored. This is the same issue as I patched the docx reader in pandoc to fix I think.
<m:oMath>
<m:nary>
<m:naryPr>
<m:chr m:val="∑"/>
<m:limLoc m:val="undOvr"/>
<m:supHide m:val="1"/>
<m:ctrlPr>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:bCs/>
<w:i/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
</m:ctrlPr>
</m:naryPr>
<m:sub>
<m:r>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<m:t>
n</m:t>
</m:r>
<m:r>
<m:rPr>
<m:sty m:val="p"/>
</m:rPr>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:bCs/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<w:sym w:font="Symbol" w:char="F0CE"/>
</m:r>
<m:r>
<m:rPr>
<m:scr m:val="double-struck"/>
<m:sty m:val="p"/>
</m:rPr>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math" w:cs="Lucida Sans Unicode"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<m:t>
N</m:t>
</m:r>
</m:sub>
<m:sup/>
<m:e>
<m:f>
<m:fPr>
<m:ctrlPr>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:bCs/>
<w:i/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
</m:ctrlPr>
</m:fPr>
<m:num>
<m:r>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<m:t xml:space="preserve">
</m:t>
</m:r>
<m:sSup>
<m:sSupPr>
<m:ctrlPr>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:bCs/>
<w:i/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
</m:ctrlPr>
</m:sSupPr>
<m:e>
<m:r>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<m:t>
x</m:t>
</m:r>
</m:e>
<m:sup>
<m:r>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<m:t>
n</m:t>
</m:r>
</m:sup>
</m:sSup>
</m:num>
<m:den>
<m:r>
<w:rPr>
<w:rFonts w:ascii="Cambria Math" w:hAnsi="Cambria Math"/>
<w:sz w:val="24"/>
<w:szCs w:val="24"/>
</w:rPr>
<m:t>
n!</m:t>
</m:r>
</m:den>
</m:f>
</m:e>
</m:nary>
</m:oMath>
ping @mpickering
ESymbol Rel \8594
is interpreted as \rightarrow
in limits. But for the LaTeX to be typeset correctly, it should be translated to \to
:
> let Right x = readTeXMath "\\lim_{x \\to \\infty} y"
> x
[EDown (EMathOperator "lim") (EGrouped [EIdentifier "x",ESymbol Rel "\8594",ESymbol Ord "\8734"]),EIdentifier "y"]
> toTeXMath DisplayInline x
"{\\lim}_{{x}\\rightarrow \\infty }{y}"
This probably only needs to be implemented for
EDown (EMathOperator "lim") ...
although there might be some uses for implementing it for
EDown (EMathOperator s) ... | s `elem` ["lim", "max", "min"]
(That would take care of the main things that should be typeset like that, even if off the top of my head I can't make any useful sense of "max as n approaches...")
I'd submit a pull request, but I'm not sure of the workflow here. @jgm -- would you prefer these things go through your pr queue, or to maintainer and then up to you, kernel style?
Here's the markdown clip for testing:
# Math Tests
## Test 1
### Without any ```LaTeX``` commands converted to Unicode symbols
$$ e = \int_\mathbb{R} f(x | \theta) \circ g(\mathbfit{z} |\mathbfit{\eta}) dx $$
## With ```\mathbfit{*}``` commands converted to Unicode symbols before fed to ```Pandoc```
$$ e = \int_\mathbb{R} f(x | \theta) \circ g(𝒛|𝜼) dx $$
## Test 2
### Without any ```LaTeX``` commands converted to Unicode symbols
$$ \mathsf{e} = \mathbffrak{z} $$
## With ```\mathbffrak{z}``` command converted to Unicode symbols before fed to ```Pandoc```
$$ \mathsf{e} = 𝖟 $$
below screenshot is the output generated with -s -S -t docx
option (whose LaTeX
code are partially processed by Pandoc
and TeXMath
):
In Test 1's case 1, the \mathbfit
command is just ignored (or not function) where "z" and "η are not in boldface. In Test 2, both cases are displayed correctly, as \mathbffrak
are well treated by TeXMath
's renderStr
function.
It seems that OMML ignores the "bf" part of \mathbfit
.
It would be nice (esp. for reliable round-tripping) not to have the Doubles. Perhaps ESpace
should have its widths specified in mus (1 mu or "math unit" from tex = 1/18 em). EScaled
could be a percentage, with 100 = actual size. Both Doubles could become Ints.
I'm not positive about this change. In any case it would be an API change, so I put it here to be done (if at all) with the addition of a border box element.
Please add support for the following symbols which are available without an extra usepackage in LaTeX:
Symbol | Code | LaTeX |
---|---|---|
↖ | U+2196 | \nwarrow |
↗ | U+2197 | \nearrow |
↘ | U+2198 | \searrow |
↙ | U+2199 | \swarrow |
@jgm @mpickering with your permission, i will use my trustee powers to make edits on all those release so that impact of the profiling blowup will be mitigated on all current releases that someone might use to build pandoc.
It was recently pointed out to me that my combinatorial LaTeX in http://www.gwern.net/sicp/Chapter%201.1#section-2 was apparently broken and readers were seeing raw LaTeX. The first formula goes
{3 \choose 2} = \frac{3!}{2! \times (3-2)!} = \frac{3!}{2! \times 1!} = \frac{3!}{2 \times 1} = \frac{3!}{2} = \frac{6}{2} = 3
I had checked in Texify that this worked but after some playing around in Pandoc, it seems that the problem is the \choose
operator. I don't see any use of \choose
in cgi/texmath.html
, and an attempt to use it in texmath.hs
fails:
$ runhaskell texmath.hs
3 \choose 2
"formula" (line 1, column 11):
unexpected "2"
It would be nice if this could be supported.
A build log from Linux/x86_64 with GHC 7.8.3 that shows the problem is available at http://hydra.cryp.to/build/158447/nixlog/1/raw.
This is not exactly a bug, but I suspect there may be no workaround, and is related to #83 and #85.
I'm using the MathML writer, and I have need for mathematical constants such as id
. I need this to render as a constant, not an operator, since it can serve as an argument. If I simply write $id$
, then the result is <mi>i</mi><mi>d</mi>
, which is as it should be. What I need is something that translates to <mi>id</mi>
.
I have been using \DeclareMathOperator
or \operatorname
for this, since it does indeed (wrongly) produce <mi>id</mi>
, but I think because of other bugs I've reported this will be changed to produce <mo>id</mo>
in the future...? Which leaves me with the problem of how to produce <mi>id</mi>
.
In LaTeX I get this effect by doing something like
\newcommand{\id}{\mbox{id}}
but this produces
<mstyle mathvariant="normal">
<mi>i</mi>
<mi>d</mi>
</mstyle>
in Pandoc.
Is there a way to do this, or is it a genuine issue?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.