jgm / pandoc

Universal markup converter
https://pandoc.org
Other
34.85k stars 3.39k forks source link

Support of custom documentClass(.cls file) for Latex to Html conversion #9461

Open maheshbansode opened 9 months ago

maheshbansode commented 9 months ago

Describe your proposed improvement and the problem it solves.

Describe alternatives you've considered.

jgm commented 9 months ago

If you can extract the definitions you need into a .sty file, pandoc can parse these (as long as they don't have low-level TeX stuff in them). You can either \include them or just put the sty file before the tex file on the command line.

fuchtr commented 9 months ago

The question is: why does pandoc not read the elsarticle.cls file that is indicated in the \documentclass statement in the LaTeX file? \documentclass[final,5p,times,twocolumn]{elsarticle}. The definitions in that class file, like \ead, and in use in the LaTeX file, \author{Forename Surname}\corref{cor1} \cortext[cor1]{corresponding author} \ead{forename.surname@example.com}, are ignored by pandoc. Regular LaTeX compilation into a PDF will show these details in the footnote on the first page, but pandoc does not appear to output footnotes. Samples are available on request.

jgm commented 9 months ago

That could be a good enhancement to consider. However, pandoc isn't currently capable of parsing the kind of low-level TeX generally found in .cls files (including this one).

jgm commented 9 months ago

Easiest approach is to use a shim that defines the macros you need using simple LaTeX macro definitions; add this shim when you convert with pandoc (it can just be a separate .tex file on the command line before your main one).

alex180500 commented 5 months ago

This is a problem that people using premade classes for latex academic articles face. Is there a way to circumvent this?

maheshbansode commented 5 months ago

Yes @alex180500 , If you want to extract specific fields then you can add definitions for those fields in .sty file and provide that .sty file while Pandoc conversion on command line. “pandoc -s anyname.sty filename.tex -o output.html --mathml --mathjax“

alex180500 commented 5 months ago

Thanks I will try! What about .clo and .bst files?

maheshbansode commented 5 months ago

I don't have much idea about such files @alex180500 may be @fuchtr has.