Verse and Tufte-Handout Incompatibility

I am attempting to use the tufte-handout document class with the verse package. However, it seems that tufte-handout loads hyperref by default and this causes the following error in verse.sty:

! LaTeX Error: Command \theHpoemline already defined.

Researching options for resolution led me to this answer: What is the right way to use hyperref options with Tufte handout class?

Loading with the nohyper option on the tufte-handout document class does allow the verse package to function, but I also need the hyperref package. (Loading hyperref after the fact still results in the same error.)

How do I manage this apparent incompatibility?

MWE:

\documentclass{tufte-handout}
\usepackage{verse}

\begin{document}
\begin{verse}
A sprig, with its flower, I break.
\end{verse}
\end{document}
• It's a very bad mistake for any class to load hyperref unconditionally, because the user might want to load other packages and this will, in many cases, create incompatibilities, as hyperref needs to be called last (with a few exceptions). Apr 18, 2015 at 13:54
• @egreg: I agree with that, but isn't it equally bad from verse package designers to define a \theHpoemline command while it's known that \theH.... commands are introduced by hyperref automatically?
– user31729
Apr 18, 2015 at 15:59
• @ChristianHupfer Yes, of course. Apr 18, 2015 at 16:17

This should work: Temporarily disable the loading of hyperref and load it after verse. verse (unnecessarily?) defines \theHpoemline counter format, in my point of view.

\documentclass[nohyper]{tufte-book}
\usepackage{verse}
\usepackage{hyperref}

\begin{document}
\begin{verse}
A sprig, with its flower, I break.
\end{verse}
\end{document}

A dirty workaround, without direct changes in verse.sty

Since verse.sty defines a counter poemline, hyperref will do automatically a \theHpoemline definition. However, this is bad, since

\newcommand*{\theHpoemline}{\arabic{verse@envctr}.\arabic{poemline}}

is used in verse.sty.


\documentclass{tufte-book}
%\hypersetup{colorlinks=true} Not needed, just for debug
\RequirePackage{verse}
\makeatletter
% Use the original definition from verse.sty
\renewcommand*{\theHpoemline}{\arabic{verse@envctr}.\arabic{poemline}}
\makeatother

\begin{document}
\tableofcontents
\chapter{first}

\chapter{second}
\begin{verse}
A sprig, with its flower, I break.
\end{verse}
\end{document}
• Works on the MWE, but beyond this complexity, does not work. (The sample-handout.tex file included with tufte still breaks with deferred loading on hyperref when verse is also loaded.) I'll see if I can complicate my MWE to replicate.
– twip
Apr 18, 2015 at 6:00
• @twip: Yes, I feared that it wouldn't work for a larger document
– user31729
Apr 18, 2015 at 6:09
• Compiles with the updated workaround. Thank you for digging deeper.
– twip
Apr 18, 2015 at 16:10
• @twip: You're welcome. Happy TeXing ;-)
– user31729
Apr 18, 2015 at 16:11