# Strange lines in front of the document

I want to create a document with the iodhbwm class. If I compile it the first time it works fine. But if I compile it a seccond time this lines apear at the begin of the document:

id=1,dest=636861707465722E31,srcline=235C3333346265727363687269667420617566204562656E6 id=2,dest=73656374696F6E2E312E31,srcline=235C3333346265727363687269667420617566204562 id=3,dest=73756273656374696F6E2E312E312E31,srcline=235C333334626572736368726966742061 id=4,dest=73656374696F6E2E312E32,srcline=234C697374656E id=5,dest=73756273656374696F6 id=6,dest=73756273656374696F6E2E312E322E32,srcline=23426569737069656C2065696E6572204 id=7,dest=73756273656374696F6E2E312E322E33,srcline=23426569737069656C2065696E6572204

The log file shows the following error:

! Undefined control sequence. l.22 \BKM@entry {id=1,dest={636861707465722E31},srcline={23}}{5C3333346265727...

?

! LaTeX Error: Missing \begin{document}.

See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...

                                               l.22 \BKM@entry{i
d=1,dest={636861707465722E31},srcline={23}}{5C3333346265727...


? ! Undefined control sequence. l.23 \BKM@entry {id=2,dest={73656374696F6E2E312E31},srcline={23}}{5C333334626...

I already contacted the author of the iodhbwm class. But he was not able to reproduce this error. Because of this he couldn't help me.

Now I think that it must be something else. I compile this code. It is an example from the documentation of iodhbwm.

\documentclass[
auto-intro-pages = default,
debug,
language = ngerman
]{iodhbwm}
\usepackage[T1]{fontenc}

\dhbwsetup{%
author                  = my name,
thesis type             = SA,
thesis title            = Verwendung von iodhbwm,
student id              = 12345,
institute               = Masterfind Factory faltfe,
course/id               = Txxxx,
supervisor              = Pikachu und Enton,
processing period       = {01.01.17 -- 31.01.17},
location                = Dreamtown
}

\begin{document}
\Blinddocument
\end{document}


I am using MikTex 2.9.6941 on Windows 7 and I reinstalled MikTex two times.

Realy interessting is, that this lines disappear if I include hyperref. But normaly the class is doing this by it self.

Do somebody know why there are this lines? Is somebody else able to reproduce this errors?

The problem is that the KOMA-classes now load bookmark if hyperref is detected. It is doing it in a \AfterAtEndOfPackage command. The iodhbwm class loads hyperref in \AtEndPreamble, so bookmark is loaded then too and this is too late for it: bookmark can't write to the aux-file the needed line

\providecommand\BKM@entry[2]{}


An simple document to reproduce the problem:

\documentclass{scrreprt}
\usepackage{etoolbox}
\AtEndPreamble{
\usepackage{hyperref}
}

\begin{document}
\chapter{abc}
\end{document}


Probably the only work-around is to prevent that bookmark is loaded:

\documentclass[bookmarkpackage=false]{scrreprt}
\usepackage{etoolbox}
\AtEndPreamble{
\usepackage{hyperref}
}

\begin{document}
\chapter{abc}
\end{document}


## Edit

A simple work-around is to load auxhook earlier:

\documentclass{scrreprt}
\usepackage{etoolbox,auxhook}
\AtEndPreamble{
\usepackage{hyperref}
}

\begin{document}
\chapter{abc}
\end{document}

• I think I know what you mean. But wouldn't it help if I write \documentclass[bookmarkpackage=false, load-dhbw-templates, auto-intro-pages = default, add-tocs-to-toc, debug, language = ngerman]{iodhbwm} – NelDav Jan 17 '19 at 15:56
• Well, thanks for your example. I'll try your solution soon. Would there be any issue if I load bookmark by default too? – faltfe Jan 17 '19 at 15:56
• bookmark loads hyperref. If you load it in the preamble it could be too early - at least the language will perhaps not correctly be passed by the class - this could affect \autoref. – Ulrike Fischer Jan 17 '19 at 16:02
• @Ulrike The problem is not, that loading of bookmark it to late. The problem is, that loading auxhook (indirect via hyperref) via \AtEndPreamble does break this package and the \AddLineBeginMainAux code is never written to aux file—not only the lines added from bookmarks but all lines, e.g. the initial \providecommand\hyper@newdestlabel[2]{} of hyperref. auxhook is prepared to be loaded via \AtBeginDocument but not via \AtEndPreamble. So package authors should avoid this! – Schweinebacke Jan 17 '19 at 21:36

The main problem is not KOMA-Script. bookmark uses package auxhook to write the definition of a command into the aux-file. \AddLineBeginMainAux of auxhook has two different modes of working:

• If \@beginmainauxhook is \relax, it writes immediately to the aux-file.
• If \@beginmainauxhook is not \relax, \AddLineBeginMainAux adds its argument to \@beginmainauxhook.

If the package is loaded via \AtBeginDocument it initializes \@beginmainauxhook with \relax. If not, it initializes it to make itself \relax and tries to patch \document to add the execution of \@beginmainauxhook just after the opening of the main aux file.

Now, if you load hyperref via \AtEndPreamble, hyperref loads auxhook and auxhook cannot recognize, that patching of \document is to late. Because of this \@beginmainauxhook is never executed.

So the bug is, to load hyperref via \AtEndPreamble without loading auxhook before \begin{document} and without explicite executing \@beginmainauxhook. If you have a look into the aux-file you will find in this case also, that the line

\providecommand\hyper@newdestlabel[2]{}


that hyperref usually writes into the aux-file (immediately after the initial \relax) is missing. This is because of not executing \@beginmainauxhook.

So I would say, this is a bug in iodhbwm and it should be changed to load auxhook earlier. As a workaround you can load auxhook in the document preamble. Both would also bring back the line

\providecommand\hyper@newdestlabel[2]{}


into the aux-file.

Thanks to answer from Ulrike the problem is a change within KOMAScript.

At the moment there is no support to pass a key value option which does not belong to the iodhbwm class itself.

There are to possibilities to fix this issue for now. The first one is loading bookmark in the preamble itself.

\documentclass[...]{iodhbwm}
\usepackage{bookmark}


The second option is to use an internal command which is used to pass options to the base class.

\makeatletter
\newcommand{\iodhbwm@cls@baseclass@options}{bookmarkpackage=false}
\makeatother


A complete example would look like

\makeatletter
\newcommand{\iodhbwm@cls@baseclass@options}{bookmarkpackage=false}
\makeatother
\documentclass[
auto-intro-pages = default,
debug,
language = ngerman
]{iodhbwm}
\usepackage[T1]{fontenc}

\dhbwsetup{%
author                  = my name,
thesis type             = SA,
thesis title            = Verwendung von iodhbwm,
student id              = 12345,
institute               = Masterfind Factory faltfe,
course/id               = Txxxx,
supervisor              = Pikachu und Enton,
processing period       = {01.01.17 -- 31.01.17},
location                = Dreamtown
}

\begin{document}
\Blinddocument
\end{document}


But please don't abuse the internal command.

• Another possibility is to write yourself early enough \providecommand\BKM@entry[2]{} to the aux-file. – Ulrike Fischer Jan 17 '19 at 16:34
• KOMA will implement a work-around. – Ulrike Fischer Jan 17 '19 at 20:22