Closed furutaka closed 6 years ago
Wow! (after reading the sources)
>>> print LatexNodes2Text(keep_inline_math=True).latex_to_text(latex) $γ$ >>> print LatexNodes2Text().latex_to_text(latex,keep_inline_math=True) \gamma >>> print LatexNodes2Text(keep_inline_math=True).latex_to_text(latex,keep_inline_math=True) $\gamma$
Hi, and thanks for noting this issue earlier. This behavior is indeed not at all intuitive and these options were very poorly designed. I am currently working on a new version pylatexenc 2.0 where both keep_inline_math
options for latexwalker
and latex2text
will be replaced by a single option math_mode=
in latex2text
. See updated doc here: https://pylatexenc.readthedocs.io/en/latest/latex2text/#pylatexenc.latex2text.LatexNodes2Text
E.g.:
>>> latex2text.LatexNodes2Text(math_mode='text').latex_to_text(r'If $\alpha=1$ and $\beta=2$, then $\alpha+\beta=3$')
'If α=1 and β=2, then α+β=3'
>>> latex2text.LatexNodes2Text(math_mode='with-delimiters').latex_to_text(r'If $\alpha=1$ and $\beta=2$, then $\alpha+\beta=3$')
'If $α=1$ and $β=2$, then $α+β=3$'
>>> latex2text.LatexNodes2Text(math_mode='verbatim').latex_to_text(r'If $\alpha=1$ and $\beta=2$, then $\alpha+\beta=3$')
'If $\\alpha=1$ and $\\beta=2$, then $\\alpha+\\beta=3$'
I'd be happy to hear if you have any feedback.
Is this the intended behavior of the function?
I expected
$\gamma$
...Kazuyoshi