[tex4ht] [bug #423] \left and \right inside caption with label cause TeX capacity exceeded when used with hyperref

2022-08-25 Thread Michal Hoftich
Update of bug #423 (project tex4ht):

 Open/Closed:Open => Closed 

___

Follow-up 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

___

Reply to this item at:

  

___
  Message sent via/by Puszcza
  http://puszcza.gnu.org.ua/



[tex4ht] [bug #423] \left and \right inside caption with label cause TeX capacity exceeded when used with hyperref

2019-05-29 Thread Michal Hoftich
Follow-up Comment #3, bug #423 (project tex4ht):

The problem is, you may want to expand some macros, while others not. It is
possible to disable all expansion, but you cannot automatically detect which
macros should be expanded and which not.

___

Reply to this item at:

  

___
  Message sent via/by Puszcza
  http://puszcza.gnu.org.ua/



[tex4ht] [bug #423] \left and \right inside caption with label cause TeX capacity exceeded when used with hyperref

2019-05-28 Thread Joel Croteau
Follow-up Comment #2, bug #423 (project tex4ht):

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.

___

Reply to this item at:

  

___
  Message sent via/by Puszcza
  http://puszcza.gnu.org.ua/


[tex4ht] [bug #423] \left and \right inside caption with label cause TeX capacity exceeded when used with hyperref

2019-05-26 Thread Michal Hoftich
Follow-up Comment #1, bug #423 (project tex4ht):

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




___

Reply to this item at:

  

___
  Message sent via/by Puszcza
  http://puszcza.gnu.org.ua/



[tex4ht] [bug #423] \left and \right inside caption with label cause TeX capacity exceeded when used with hyperref

2019-05-24 Thread Joel Croteau
URL:
  

 Summary: \left and \right inside caption with label cause TeX
capacity exceeded when used with hyperref
 Project: tex4ht
Submitted by: tv4fun
Submitted on: Fri 24 May 2019 04:39:57 PM EEST
Category: None
Priority: 5 - Normal
Severity: 5 - Normal
  Status: None
 Privacy: Public
 Assigned to: None
Originator Email: 
 Open/Closed: Open
 Discussion Lock: Any

___

Details:

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:


\documentclass{article}

\usepackage{hyperref}


\begin{document}
\begin{figure}
\caption{$\left(A\right)$}
  \label{a}
\end{figure}
\end{document}

When compiled with `mk4ht htlatex main2.tex`, this gives:


--- file main2.css ---
 [1

] [2

]
LaTeX Font Info:External font `cmex10' loaded for size
(Font)  <7> on input line 8.
LaTeX Font Info:External font `cmex10' loaded for size
(Font)  <5> on input line 8.
l. 8 Writing main2.idv[1] (main20x.png)

! TeX capacity exceeded, sorry [input stack size=2].
\Picture ->\leavevmode
   \futurelet \:temp \:img
l.9   \label{a}

If you really absolutely need more capacity,
you can ask a wizard to enlarge me.


Here is how much of TeX's memory you used:
 7621 strings out of 492617
 101793 string characters out of 6129507
 880460 words of memory out of 500
 11452 multiletter control sequences out of 15000+60
 3808 words of font info for 15 fonts, out of 800 for 9000
 1141 hyphenation exceptions out of 8191
 2i,5n,11428p,758b,465s stack positions out of
2i,500n,2p,20b,8s
Output written on main2.dvi (2 pages, 9752 bytes).


Interestingly, a small change to \thefigure results in a completely different
error:

\documentclass{article}

\usepackage{hyperref}


\begin{document}
\renewcommand{\thefigure}{S\arabic{figure}}
\begin{figure}
\caption{$\left(A\right)$}
  \label{a}
\end{figure}
\end{document}


Now gives:

(./main2.aux) [1] [2]
! You can't use `\relax' after \the.
 \c@

l.10   \label{a}

?


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.




___

Reply to this item at:

  

___
  Message sent via/by Puszcza
  http://puszcza.gnu.org.ua/