Thu Aug 25 11:23:38 2022, comment #6:
I think that I've fixed this issue finally. We need to make the problematic commands robust. So for the future reference, instead of
\def\:temp#1{...}
\HLet\foo\:temp
it is better to use the following code for the commands that can be used in captions or sectioning commands:
\ProvideDocumentCommand\foo:temp{m}{...}
\HLet\foo\foo:temp
|
Tue May 28 17:26:35 2019, comment #2:
Thank you, Michal. Will try the \protect thing. If that works, it may be worthwhile to try and add some logic to do that automatically. I'm actually using tex4ebook, but it uses tex4ht internally, and that's where I ran into this issue.
|
Sun May 26 10:12:03 2019, comment #1:
Dear Joel,
this issue is caused by the nameref support, which is loaded automatically by hyperref. Each caption, section title and similar stuff is then saved to the auxilary file, in order to be available for the \nameref command. There can be expansion issues when the contents are written to the auxilary file, as in your case.
I don't know if we can fix that on the tex4ht level - we could use something like \detokenize command to write literal contents of the caption to the aux file, but in this case you wouldn't save the current value of macros, which you may want in some cases.
On the document level, you can use the \protect command to disable expansion of the command when it is written:
\caption{$\protect\left(A\protect\right)$}
BTW, if you want to make an eBook, you may want to take a look at tex4ebook: https://ctan.org/pkg/tex4ebook?lang=en
|
Fri May 24 13:39:57 2019, original submission:
Recently when trying to convert a scientific paper to an eBook using tex4ht, I ran into some confusing errors. I tracked it down to a macro that used \left and \right inside of the caption of a labeled figure, which only seems to be a problem with hyperref included. A simple example to reproduce this:
When compiled with `mk4ht htlatex main2.tex`, this gives:
Interestingly, a small change to \thefigure results in a completely different error:
Now gives:
This only seems to happen with the very specific combination of factors I have outlined above. Not including \left and \right, not having them inside a \caption, not having the \label, or not including \hyperref all seem to make this go away, and it compiles with regular LaTeX just fine. I'm afraid I don't know enough about the macros you're using to be able to debug this.
|