Pkg 'labbook' incompatible with pkg 'subcaption'?

Disclaimer: I know this is a question drawing opinionated answers. I still want to ask it, as I don't know how else I should proceed and am looking for advice.

I use labbook to write - you guessed it - a labbook. When I activate caption in the preamble, all is fine, but as soon as I add subcaption, XeLaTeX throws:

To be honest, I load caption and subcaption by default, since I use them in most of my documents and I am pretty sure I will need them in my labbook, but I haven't included any images in my document, yet. The labbook class hasn't been updated since 2003 and the maintainer seems to have been active on ctan no later than 2007, when he last updated alnumsec. The probability of labbook experiencing an update in the future is thus marginal at best. My uncoziness about this class arose when I got the error, even though my document is still pretty virgin (it's got 40 lines of code total, as of now). My question is therefore:

What class do you recommend I use instead of labbook to write my labbook?

I am - relatably, I think - not really keen on going on with an unmaintained document class to later hit some wall of unconceivable incompatibility with some important (otherwise well working) package and then have to rewrite all the structural parts of my TEX file.

I am just reading the labbook documentation again and it says

labbook.cls is based on the KOMA-Script-class scrbook.cls.

could this be the source of the incompatibility with subcaption? I don't know KOMA-script very well. In What packages are incompatible with KOMA-Script?, subcaption doesn't appear.

Furthermore, subcaption used to be incompatible with memoir, but isn't any more. I don't know if memoir is based on scrbook, but that doesn't really matter now, as it got updated to work with subcaption. Should I maybe use memoir instead of labbook?

• memoir and scrbook are NOT related. They were developed independently. – Peter Wilson Feb 14 '18 at 18:42
• @PeterWilson that's correct, they are not. By reading a bit more about it, this became clear. – thymaro Feb 14 '18 at 19:04
• In case you read German you might be interested in komascript.de/node/2166. In particular Markus Kohm mentions that it is labbook.sty itself defines the problematic \theHsubfigure messing up subcaption. You may use any document class you like for you lab journal, it just depends on what you want and need. I would probably start with scrreprt/scrbook or memoir and write a few macros. – moewe Feb 15 '18 at 14:07
• @moewe thx, I'll read this. I'll probably change the doc format, then. – thymaro Feb 15 '18 at 21:42

As already explained by moewe in a comment and by the KOMA-Script author in German on komascript.de the problem is not KOMA-Script but labbook. To use labbook with hyperref you have to load it with option hyperref. But if you load it with option hyperref it does a

\newcommand*\theHsubfigure{%
\theHfigure.\arabic{subfigure}}


just after loading hyperref. This does result in an error, because subcaption already defines \theHsubfigure. The only thing, you could do, is to undefine \theHsubfigure before loading hyperref. To do so, you can either use:

\documentclass[hyperref]{labbook}
\usepackage{subcaption}
\let\theHsubfigure\relax
\usepackage{hyperref}

\begin{document}
Test
\end{document}


or

\documentclass[hyperref]{labbook}
\BeforePackage{hyperref}{\let\theHsubfigure\relax}
\usepackage{subcaption}
\usepackage{hyperref}

\begin{document}
Test
\end{document}


However, you should note, labbook is unmaintained for several years and their is not warranty that such a hack really solves at least the issue from your question. The subcaption author has some very clear words about labbook's redefinition of \theHfigure and \theHtable and IMHO the definition of \theHsubfigure is very similar to that. So if their wouldn't be a new maintainer that fixes all issues of labbook my recommendation would be the same as in moewe's comment below the question: I would probably start with scrreprt/scrbook or memoir and write a few macros. But I would not use labbook and at least not in combination with subcaption.

• I ended up using doc-class memoir and dirty-hacking my way through it to get to an acceptable result that suits my needs more or less. Danke für die ausführlichere Antwort. – thymaro Apr 15 '19 at 14:07