Giter VIP home page Giter VIP logo

Comments (5)

phfaist avatar phfaist commented on July 29, 2024

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.

Loligplayer33 avatar Loligplayer33 commented on July 29, 2024

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.

phfaist avatar phfaist commented on July 29, 2024

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.

Loligplayer33 avatar Loligplayer33 commented on July 29, 2024

Works like a charm thank you. Next time I will look further by myself before bothering someone else with my problem.

from pylatexenc.

phfaist avatar phfaist commented on July 29, 2024

Great! No worries.

from pylatexenc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.