kvoptions와 바벨 간의 비호환성

kvoptions와 바벨 간의 비호환성

내 문서 클래스에서 사용하고 kvoptions있으며 지금까지는 잘 작동했지만 대대적으로 다시 작성한 후 패키지를 다시 추적할 수 있는 이상한 오류가 발생하기 시작했습니다 babel.

MWE:

%% myclass.cls

\NeedsTeXFormat{LaTeX2e}[2018/04/01]
\ProvidesClass{myclass}

\RequirePackage[patch]{kvoptions}

\DeclareStringOption{title}
\ProcessKeyvalOptions*

\LoadClass{article}
\title{\myclass@title}
\RequirePackage[english]{babel}

\endinput
\documentclass[title={Here be dragons}]{myclass}

\begin{document}
Lorem Ipsum
\end{document}

로그에서 발췌(간결함을 위해 경로는 생략됨):

babel.sty:460: LaTeX Error: Missing \begin{document}. [    {}}]
babel.sty:460: Too many }'s. [    {}}]
babel.sty:475: LaTeX Error: Missing \begin{document}. [    \ifin@\edef\bbl@tempc{\bbl@tempb}\fi}]

패치가 없으면 kvoptions오류가 점점 더 심해집니다.

babel.sty:339: LaTeX Error: Missing \begin{document}. [\ProcessOptions*]
babel.sty:339: You can't use `macro parameter character #' in horizontal mode. [\ProcessOptions*]
TeX STOPPED: File ended while scanning use of \reserved@{##1,##2\reserved@b }\def \reserved@b ##1,\reserved@b ##2\reserved@b 
TeX reports the error was in file:3 
myclass.cls:13: LaTeX Error: Unknown option `english' for package `babel'. []

분석:문제는 전역 옵션( )에 공백(및 중괄호)을 사용했는데 title이 옵션이 분명히 에 전달된다는 것입니다 babel. 공백이 없으면 오류가 발생하지 않습니다.

질문:문서 클래스 옵션이 패키지에서 전역 옵션으로 사용되는 것을 방지할 수 있습니까? 아니면 \hypersetup{}옵션 대신 사용할 수 있는 것과 유사한 해결 방법이 있습니까 ? 나는 그것으로 살 수 있었다.

답변1

나는 다음에서 영감을 얻어 이 문제를 해결했습니다.다른 질문에 대한 대답. 위의 MWE에 적용하면 다음과 같습니다.

%% myclass.cls

\NeedsTeXFormat{LaTeX2e}[2018/04/01]
\ProvidesClass{myclass}

\RequirePackage{kvoptions}

\DeclareStringOption{title}
\ProcessKeyvalOptions*

\LoadClass{article}

\newcommand*{\docsetup}[1]{
  \kvsetkeys{myclass}{#1}
  \title{\myclass@title}
  \RequirePackage[english]{babel}
}

\endinput
\documentclass{myclass}
\docsetup{title={An awesome title}}

\begin{document}
Lorem Ipsum
\end{document}

관련 정보