brucemiller / LaTeXML

LaTeXML: a TeX and LaTeX to XML/HTML/ePub/MathML translator.
http://dlmf.nist.gov/LaTeXML/
Other
899 stars 96 forks source link

mathsvg option still not working in 0.8.1 (even using github distribution) #649

Closed gpetty closed 9 years ago

gpetty commented 9 years ago

I just processed a 200+ page book using the following commands:

latexml --destination=book.xml book.tex latexmlpost --format=xhtml --mathsvg --destination=book.xhtml book.xml

Both operations completed, but during the latexmlpost phase, there were many, many warnings of the form "Couldn't find image for 'LaTeXML::Post::MathImages::svg:/begin....'

When I inspect the resulting XHTML file, which is otherwise apparently fine, there is only MathML code, no SVG whatsoever.

Is this a bug, or have I not configured something correctly? Is there an additional software prerequisite needed for the SVG generation?

I'm running this under Ubuntu 14.04 with LaTeXML 0.8.1

brucemiller commented 9 years ago

On 08/15/2015 11:10 AM, gpetty wrote:

I just processed a 200+ page book using the following commands:

latexml --destination=book.xml book.tex latexmlpost --format=xhtml --mathsvg --destination=book.xhtml book.xml

Both operations completed, but during the latexmlpost phase, there were many, many warnings of the form "Couldn't find image for 'LaTeXML::Post::MathImages::svg:/begin....'

When I inspect the resulting XML file, which is otherwise apparently fine, there is only MathML code, no SVG whatsoever.

Is this a bug, or have I not configured something correctly? Is there an additional software prerequisite needed for the SVG generation?

Yes, you need dvisvgm to convert the math to svg. If it isn't present, you should have had an error message before all the warnings about missing images.

gpetty commented 9 years ago

Thanks, I just checked, and dvisvgm is present. I re-ran latexml and latexmlpost again (same options as above) and captured the diagnostic output. It shows some errors, but to my untrained eye, they don't seem related to dvisvgm:

https://dl.dropboxusercontent.com/u/1653737/latexml_log.txt (latexml logged output) https://dl.dropboxusercontent.com/u/1653737/latexmlpost_log.txt (latexmlpost logged output)

dginev commented 9 years ago
Error:shell:latex LaTeX command 'latex ltxmlimg > ltxmlimg.ltxoutput' failed
    Postprocessing LaTeXML::Post::MathML::Presentation book.xhtml
    returned code 256 (!= 0): 
    Re-run with --verbose to see TeX log
gpetty commented 9 years ago

Re-ran with --verbose; here's the revised output: https://dl.dropboxusercontent.com/u/1653737/latexmlpost_log.txt

There's now a reference to the following log file: https://dl.dropboxusercontent.com/u/1653737/ltxmlimg_log.txt

Again, there are errors, but I don't know whether they're related.

brucemiller commented 9 years ago

On 08/15/2015 02:12 PM, gpetty wrote:

Re-ran with --verbose; here's the revised output: https://dl.dropboxusercontent.com/u/1653737/latexmlpost_log.txt

There's now a reference to the following log file: https://dl.dropboxusercontent.com/u/1653737/ltxmlimg_log.txt

Ah, yes; there was a mistranslation of spacing into \hskip{dim} instead of \hskip dim which causes this. It's been fixed in the repository.

Unfortunately, there's not really a sensible workaround other than to fetch the development version of LaTeXML from github, or wait for the next release (in about a month?).

Thanks for the report and sorry for the inconvenience.

gpetty commented 9 years ago

Thanks, Bruce. I just downloaded the distribution from github, and it seemingly eliminated the \hskip errors, but otherwise the outcome is indistinguishable from before.

Here are links to the latest diagnostics:

https://dl.dropboxusercontent.com/u/1653737/latexml_log.txt https://dl.dropboxusercontent.com/u/1653737/latexmlpost_log.txt https://dl.dropboxusercontent.com/u/1653737/ltxmlimg.log

Grant

l8l commented 4 years ago

Hey! I just noticed that the --mathsvg command at least on my distribution only works with the command latexmlc. Running first latexml and then latexmlpost ... did not work - does anybody know why? Maybe this also resolves the problem of the OP.

dginev commented 4 years ago

Hi @l8l ! Thanks for catching that -- I looked into it and somewhat funnily the bug is the reverse to your report.

To use the --mathsvg option, you need to provide a destination (--dest or --destination) option, so that the main result is written to a file. That option is needed so that latexml can properly host the created SVG files for the math formulas inside, and relative to, the main destination directory.

And as you say - latexmlc currently will happily write the SVG files in the current directory when you do not provide a --destination, which feels correct when that's what you may have wanted -- but it is quite wrong if you e.g. are running that code in some batch job.

latexmlpost provides a big warning at the beginning of the conversion run, maybe we should elevate that to a Real latexml Warn() call so that it becomes more visible:

WARNING: must supply destination to support auxilliary files;
  disabling: --nomathimages --nographicimages --nopictureimages

I'll make a small pull request that aligns the executables, thanks again for reporting!

l8l commented 4 years ago

Hi @dginev ! Thanks for looking into that. But actually what you write does not fit to what I experience. I do provide a destination each time and in my comment above just did not include it for brevity. More specifically, my commands are: 1) With latexml and then latexmlpost: 1.1) latexml --destination=index.xml input.tex 1.2) latexmlpost --format=html5 --mathsvg --dest=index.html index.xml This does not produce svg images but mathml as can be seen in the source code. 2) With latexmlc: 2.1) latexmlc --format=html5 --mathsvg --dest=index.html input.tex This does produce svg graphics.

As you are reading this: I know this is not the place to ask but could you give me any hint how to use tikz-cd with latexml? I only found support for usual tikz and tikz-cd is quite important for diagrams and if there is no support I might have to go for another converter. Sorry for the misplaced question and thanks a lot.

dginev commented 4 years ago

Hey @l8l ,

Got it, you are hitting another usability snag then -- parallel markup. Of course it wasn't meant to be a snag, but I can certainly see how you only expect math svg when you provide the --mathsvg option as you use it for the first time.

If you make a document with a single formula, and convert it with the commands you mention in your point 1. you will see a presentation MathML element with an annotation altimg="mi/mi1.svg". And then you should indeed be able to verify the mi/m1.svg file exists and contains that formula.

If you want to fully disable MathML, you'd need to add --nopmml to the option set as:

latexmlpost --format=html5 --nopmml --mathsvg --dest=index.html index.xml

in which case the formulas will only get an <img> tag.

I think the second action item for me is to refactor to a point where --mathsvg and --mathimages when provided standalone always act as single math processors, rather than implicitly turning on parallel markup.

As for tikz-cd, I would welcome you to open a new issue, and would like to add or help add a binding for it, but it's not on the top of the priority list. I have been meaning to take a look into tikz-qtree at some point for quite some time now ( #341 ), but the difficulty of the bindings makes it hard to jump into without a big chunk of allocated time and the right incentive.

l8l commented 4 years ago

Ah thanks @dginev ! Now everything makes sense! Will take care of the --nopmml option next time!

Regarding tikz-cd: Thanks for the remark, I did open a new issue here: https://github.com/brucemiller/LaTeXML/issues/1280 Would be great to have an option for conversion, even if it just involves svg images at the beginning.

Thanks again for your kind and fast answers.