Comments (5)
Hey, thanks for the issue. I'm not sure I understand what you mean by "keep the encoding complete". What are you trying to achieve? (The LaTeX code you show doesn't look valid, is that a second subscript with a missing argument or do you have a typo? What would be the output you'd have expected?)
from pylatexenc.
Thank you for your comment. I forgot to escape the underscore therefore it did not display....
I will try to specify what I am trying to achieve:
I have a bibtex string which I try to encode. The Problem is, that the latex_to_text()
function does not seem to recognize the super- and subscript encoding correctly.
f.e. When I give it the string "This is H$_{2}$O" it returns "This is H_2O" instead of either:
"This is H₂O" or "This is H$_{2}O".
More specifically I need to keep the encoding which is not possible at the moment.
I thought it might be best to insert some special other character that prevents latex_to_text()
from detecting the encoding.
this is the specification of bibtex for special characters.
(I think you are from germany hence you should be able to understand it)
Vielen Dank für deine Hilfe!
from pylatexenc.
It sounds like the math_mode='verbatim'
option of LatexNodes2Text provides the behavior you're after?
print( latex2text.LatexNodes2Text(math_mode='verbatim').latex_to_text(r"Drink lots of $H_{2}O$.") )
# prints: Drink lots of $H_{2}O$.
from pylatexenc.
Works like a charm thank you. Next time I will look further by myself before bothering someone else with my problem.
from pylatexenc.
Great! No worries.
from pylatexenc.
Related Issues (20)
- problem with ensuremath construct HOT 1
- Temporarily disable environment parsing HOT 2
- Support for Python 3.7+
- various upgrades HOT 1
- how to instantiate LatexMacroNode? HOT 3
- suggestion for simpler/more correct MacroArgs
- nodelist_to_latex() doesn't respect node.environmentname HOT 1
- how to parse `\vrule height 2pt depth -1.6pt width 23pt` HOT 1
- how to parse `\def\enorm#1{\|#1\|_2}` HOT 1
- how to parse `\lstinline|code|` HOT 1
- macroname='SS' incorrectly translated HOT 1
- parse issue with `\newcommand{\be}{\begin{equation}}` HOT 3
- adapt LatexWalker context while walking HOT 1
- Input and output differs when converting a nodelist back into latex HOT 1
- Incorrect (?) parsing of content in `lstlisting` environment HOT 3
- Deprecation warning upon installation via pip HOT 1
- Any ideas to skip specific element in LatexWalker? HOT 1
- pylatexenc import latexpp NCArgsParser doesn't work HOT 1
- Exception when parsing macro definitions with multiple arguments HOT 1
- IndexError: list index out of range HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylatexenc.