Verse 및 Tufte-Handout 비호환성

Verse 및 Tufte-Handout 비호환성

tufte-handout패키지 와 함께 문서 클래스를 사용하려고 합니다 verse. 그러나 기본적으로 tufte-handout로드되는 것으로 보이며 hyperref이로 인해 다음 오류가 발생합니다 verse.sty.

! LaTeX Error: Command \theHpoemline already defined.

해결 방법을 조사한 결과 다음과 같은 답을 얻었습니다. Tufte 유인물 클래스에서 하이퍼참조 옵션을 사용하는 올바른 방법은 무엇입니까?

nohyper문서 클래스 에 옵션을 사용하여 로드하면 패키지가 작동 tufte-handout할 수 있지만 패키지도 필요합니다. ( 사실 이후에 로드하면 여전히 동일한 오류가 발생합니다.)versehyperrefhyperref

이 명백한 비호환성을 어떻게 관리합니까?

MWE:

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

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

답변1

이렇게 하면 작동합니다. 의 로딩을 일시적으로 비활성화 hyperref하고 verse. verse(불필요하게?) \theHpoemline내 관점에서는 카운터 형식을 정의합니다.

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

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

직접적인 변경 없이 더러운 해결 방법verse.sty

verse.stycounter를 정의 poemline하므로 자동 으로 정의를 hyperref수행합니다 \theHpoemline. 그러나 이것은 나쁘다.

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

에서 사용됩니다 verse.sty.

해결 방법은 기존 명령에 대해 불평하지 않는 \providecommand대신 임시로 사용 하고 로드된 후 다시 로 전환하는 것입니다 .\newcommandverse\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}

답변2

저도 같은 문제가 있었는데 \hyperref로드하기 전에 패키지를 로드하여 깔끔하게 해결했습니다 \verse.

관련 정보