Giter VIP home page Giter VIP logo

Comments (2)

phfaist avatar phfaist commented on July 29, 2024

Thanks, that's a good suggestion. I'll try to think about using math alphanumeric symbols in math expressions soon. (I'm a bit hesitant of adding functionality with options in the latex-to-text functions because I'm considering revamping some parts of latex2text and any options I add now will have to be supported later, too.) In the meantime, you can use $\mathit{x}$ which is already supported. An alternative might be to keep math latex as-is, and then somehow plug in some external unicode math renderer, there might be some useful ones around.

from pylatexenc.

gamboz avatar gamboz commented on July 29, 2024

In the hope that it may be useful, here is a piece of code that I use to translate the macro \cal to "MATHEMATICAL SCRIPT CAPITAL XXX".

def replace_macro_cal(node, l2tobj):
    r"""Script letters.

    \cal O  →  𝒪
    \cal a  →  𝒶 (not implemented; NB: "MATHEMATICAL SCRIPT SMALL O" does not exist)
    """
    letter = l2tobj.nodelist_to_text([node.nodeargd.argnlist[0]])
    ucharname = letter.upper()
    if ucharname != letter:
        logging.error(r'Invalid character "\cal %s" at pos %s.',
                      ucharname, node.pos)
        return "ERROR"
    return unicodedata.lookup("MATHEMATICAL SCRIPT CAPITAL "+ucharname)

Of course this must be plugged into the LatexContextDb for the text generation and the macro definition std_macro('cal', '{') must be added to the context db of the parser.

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.