
Estou tentando usar a tufte-handout
classe document com o verse
pacote. No entanto, parece que tufte-handout
carrega hyperref
por padrão e isso causa o seguinte erro em verse.sty
:
! LaTeX Error: Command \theHpoemline already defined.
A pesquisa de opções de resolução me levou a esta resposta: Qual é a maneira correta de usar opções de hiperref com a aula de apostila do Tufte?
Carregar com a nohyper
opção na tufte-handout
classe do documento permite que o verse
pacote funcione, mas também preciso do hyperref
pacote. (Carregar hyperref
após o fato ainda resulta no mesmo erro.)
Como faço para gerenciar essa aparente incompatibilidade?
MWE:
\documentclass{tufte-handout}
\usepackage{verse}
\begin{document}
\begin{verse}
A sprig, with its flower, I break.
\end{verse}
\end{document}
Responder1
Isso deve funcionar: desative temporariamente o carregamento hyperref
e carregue-o depois do verse
. verse
(desnecessariamente?) define \theHpoemline
o formato do contador, no meu ponto de vista.
\documentclass[nohyper]{tufte-book}
\usepackage{verse}
\usepackage{hyperref}
\begin{document}
\begin{verse}
A sprig, with its flower, I break.
\end{verse}
\end{document}
Uma solução alternativa suja, sem alterações diretasverse.sty
Como verse.sty
define um contador poemline
, hyperref
fará automaticamente uma \theHpoemline
definição. No entanto, isso é ruim, pois
\newcommand*{\theHpoemline}{\arabic{verse@envctr}.\arabic{poemline}}
é usado em verse.sty
.
Uma solução alternativa é usar \providecommand
temporariamente em vez de \newcommand
, que não reclama de comandos já existentes e depois de verse
carregado, voltar para \newcommand
.
\documentclass{tufte-book}
%\hypersetup{colorlinks=true} Not needed, just for debug
\let\orignewcommand\newcommand % store the original \newcommand
\let\newcommand\providecommand % make \newcommand behave like \providecommand
\RequirePackage{verse}
\let\newcommand\orignewcommand % use the original `\newcommand` in future
\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}
Responder2
Eu tive o mesmo problema e resolvi-o ordenadamente carregando o pacote \hyperref
antes de carregar o arquivo \verse
.