2

I'm trying to compile a part of my thesis with tex4ht (to use LibreOffice grammar checker). It was working well few weeks ago but now it fails with the error:

! Undefined control sequence.
\H@refstepcounter #1->\sf@Hrefstepcounter 
                                      {#1}\@ifundefined {c@sub#1}{}{\if@...
l.42  \centering

It seems related to the subfig package.

I use TeXLive 2010 on Ubuntu 11.04.

Here is MWE with the way I load hyperref (the photo is the one from this wikipedia article):

\documentclass[12pt,a4paper,twoside,openright,titlepage,fleqn,headsepline,headinclude,footinclude]{scrbook}

\usepackage{graphicx}
\usepackage{subfig}
\usepackage[unicode=true,bookmarks=true,bookmarksnumbered=false,bookmarksopen=false,breaklinks=false,colorlinks=true]{hyperref}
\usepackage[all]{hypcap}

\begin{document}

\begin{figure}
 \centering
 \subfloat[Who's that?]{\includegraphics[width=0.45\textwidth]{Einstein_1921_portrait2.jpg}}%
 \qquad
 \subfloat[Who's that?]{\includegraphics[width=0.45\textwidth]{Einstein_1921_portrait2.jpg}}
 \caption{A famous scientist and his twin brother.}
\end{figure}

\end{document}
  • 1
    Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. The error might be caused by loading subfig after hyperref. With a few exceptions, hyperref has to be loaded last, subfig is not among the exceptions. – egreg Jul 28 '11 at 10:26
  • Thanks but subig is loaded before hyperref. – Mathieu Dubois Jul 28 '11 at 13:11
  • So a minimal working example is needed. – egreg Jul 28 '11 at 13:12
  • I'm working on it :) – Mathieu Dubois Jul 28 '11 at 13:42
  • If I Remove hyperref and hypcap the document compiles. – Mathieu Dubois Jul 28 '11 at 14:06
  • I have tried to use this trick to load hyperref only for pdflatex and not tex4ht but I still have issues when compiling my real document because it needs hyperref. – Mathieu Dubois Jul 28 '11 at 14:22
  • So I guess there is an option in hyperref that is incompatible with tex4ht. If you have some clue... – Mathieu Dubois Jul 28 '11 at 14:22
  • It seems that hypcap is responsible. – egreg Jul 28 '11 at 14:24
  • If I load hyperref without option, the error is \caption@prepareslc ...tepcounter \measuring@true \let \caption@makeanchor \... l.17 ...s[width=5cm]{Einstein_1921_portrait2.png}} – Mathieu Dubois Jul 28 '11 at 14:26
  • Thanks. I have used \@ifpackageloaded to avoid hypcap with tex4ht but now I'm facing: ! LaTeX Error: No counter 'Item' defined. – Mathieu Dubois Jul 28 '11 at 14:45
  • Playing a bit more with \@ifpackageloaded I finally compiled my long document... which is invalid. Inspecting the xml files in the odt showed that some files are not correct. For instance style.xml did contain . I probably use too much tricks which finally confuse tex4ht. – Mathieu Dubois Jul 28 '11 at 15:03
  • Tex4ht is a cannon, and you're using it as a flyswatter. Here http://www.cse.ohio-state.edu/~gurari/TeX4ht/mn.html is a list of software that can convert tex/latex to other formats (see "Resources"). I would suggest using something much simpler. BTW, I know you asked about grammar checking rather than spell checking, but for spell checking, ispell with the -t option works great. –  Jul 28 '11 at 17:09
  • The real document that I want to compile is much more complicated (> 100 pages) and the OO is sometime more convenient. Nevertheless you're right I could avoid TeX4HT. – Mathieu Dubois Jul 29 '11 at 13:35

2 Answers2

2

As far as I can see there are more than one problem.

  1. As one can see in the log hyperref stopped early. This means that quite a lot commands are not defined. One of this now undefined commands is \H@refstepcounter and so the code of subfig

     \let\sf@Hrefstepcounter\H@refstepcounter
     \def\H@refstepcounter#1{% 
    

    fails. That's probably easy to go around this by using \makeatletter\let\H@refstepcounter\refstepcounter in the preamble.

  2. caption doesn't realize that hyperref has stopped early as it test for \hyper@makecurrent and the tex4ht style for hyperref (hyperref.4ht) defines it. So caption asume that commands exist (measuring@true) which are actually undefined.

I can't think about a sane way around this problem. In both cases I think that packages which use internal commands of other packages shouldn't assume they exist but actual test the existence - it is always possible that the names changes.

Ulrike Fischer
  • 327,261
1

It seems that subfig and hypcap are not compatible with TeX4ht. If I load subfigure instead (changing \subfloat into \subfigure) and delete the call to hypcap, the document compiles.

egreg
  • 1,121,712
  • I did some trick like that (see my comments above) but in the end the document is unusable. I think I will give up. Thanks for your time. – Mathieu Dubois Jul 28 '11 at 15:30
  • The subfig package usually loads the caption package. And if the caption package is loaded, the hypcap package isn't needed at all. (See caption package documentation for details.) –  Jul 29 '11 at 06:34
  • @Axel The document doesn't compile also when hypcap is not loaded. – egreg Jul 29 '11 at 07:55
  • Initially I started to use subfig because according to this page subfigure is obsolete but I have just realized that subfig is considered obsolete too. – Mathieu Dubois Jul 29 '11 at 13:39