Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail to extract Title in common cases in both pylatexenc V2 and V3 #114

Open
MrForExample opened this issue Sep 24, 2024 · 3 comments
Open

Comments

@MrForExample
Copy link

For example, when title in .tex file have following format:

  • \title{FlexiTex: Enhancing Texture Generation with Visual Guidance}
  • \title[DeepMimic: Example-Guided Deep Reinforcement Learning of Physics-Based Character Skills]{DeepMimic: Example-Guided Deep Reinforcement Learning\\ of Physics-Based Character Skills}

latex_to_text -> nodelist_to_text -> macro_node_to_text would fail to extract the text completely and return the empty string

@MrForExample MrForExample changed the title Fail to extract Title in common cases Fail to extract Title in common cases in both pylatexenc V2 and V3 Sep 24, 2024
@MrForExample
Copy link
Author

Update:

I dig into the https://github.com/phfaist/pylatexenc/blob/main/pylatexenc/latex2text/_defaultspecs.py#L175

Turns out value is stored in LatexNodes2Text._doc_title variable

Right now, it can work for \title{FlexiTex: Enhancing Texture Generation with Visual Guidance}
But still fail on \title[DeepMimic: Example-Guided Deep Reinforcement Learning of Physics-Based Character Skills]{DeepMimic: Example-Guided Deep Reinforcement Learning\\ of Physics-Based Character Skills}, which will return '['

@phfaist
Copy link
Owner

phfaist commented Nov 26, 2024

Yes, the latex-to-text module has an ugly kludge to output the title, author, and date together at the location of the \maketitle command. It involves setting an internal property on the LatexNodes2Text object instance. One day, I hope I'll be able to clean up this module and have something that's less messy. In the meantime, you can always override the MacroTextSpec's associated with \title, \author, and \date to produce the output you'd like.

@phfaist
Copy link
Owner

phfaist commented Nov 26, 2024

I was not aware of \title taking an optional argument. Do you use a specific nonstandard LaTeX style? If you'd like to support an optional argument to the \title command, you'll need to override the macro definition in the context you give to the latex walker as well as to the latex-to-text object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants