phfaist / pylatexenc

Simple LaTeX parser providing latex-to-unicode and unicode-to-latex conversion
https://pylatexenc.readthedocs.io
MIT License
301 stars 37 forks source link

latex2text is removing macroname from the latext- text #12

Closed chetankabra closed 6 years ago

chetankabra commented 6 years ago

encoder = LatexNodes2Text(keep_inline_math=True, keep_comments=True) print encoder.latex_to_text(r'Global well-posedness for the mass-critical stochastic nonlinear Schr\"{o}dinger equation on $\mathbb{R}$: small initial data') I have used above code to decode Latex command and I only want the latex accent command to be converted to plain text.

but Latex is removing latex macro from the output. Output: Global well-posedness for the mass-critical stochastic nonlinear Schrödinger equation on $R$: small initial data

Expected output: Global well-posedness for the mass-critical stochastic nonlinear Schrödinger equation on $\mathbb{R}$: small initial data

furutaka commented 6 years ago

I think you can get what you want by doing: encoder = LatexNodes2Text(keep_inline_math=True, keep_comments=True) print encoder.latex_to_text(r'Global well-posedness for the mass-critical stochastic nonlinear Schr\"{o}dinger equation on $\mathbb{R}$: small initial data',keep_inline_math=True)

phfaist commented 6 years ago

@furutaka's comment is indeed the correct way to go (thanks for replying!). I'm closing this issue, reopen if there are any further problems.