thmtools에서 Cleveref 이름을 정리 이름으로 사용하는 방법

thmtools에서 Cleveref 이름을 정리 이름으로 사용하는 방법

저는 를 사용하여 몇 가지 정리와 유사한 환경을 설정하려고 노력하고 thmtools있으며 cleverer다른 언어와의 호환성을 유지하려고 노력하고 있습니다.

cleveref나중에 로드하면 명령 thmtools에서 나오는 번역된 상호 참조가 매우 잘 작동하는 것 같습니다 \cref. "정리", "정의", "정의"를 내 언어로 번역하는 방법(번역을 제공하는 사람은 누구이며 어떻게 제공하는가?)의 조합이 이미 알고 있는 babel것 같습니다 .cleveref

그러나 환경도 마찬가지다.이름name=, 그래서 어떻게든 의 옵션 에 번역된 문자열을 제공해야 합니다 \declaretheorem. cleveref매뉴얼에서 와 같이 패키지에서 사용하는 이름을 제공하는 매크로가 있다는 것을 발견하고 \cref@theorem@name이를 사용하려고 합니다. 를 사용할 때는 모두 잘 작동했지만 amsthm로드하면 thmtools설명할 수 없는 오류 메시지가 나타납니다.

다음의 최소 예는 문제를 보여줍니다.

\documentclass[italian]{article}

\usepackage{amsthm}
\usepackage{thmtools} % Comment this line and it works
\usepackage[capitalise]{cleveref}
\usepackage{babel}

\makeatletter
\newtheorem{theorem}{\cref@theorem@name}
\makeatother

\begin{document}

\begin{theorem}
Let ABC be a triangle. If it hits your head it will hurt\ldots
\end{theorem}

\end{document}

위의 코드를 컴파일하면 오류가 발생합니다.

./mwe.tex:10: Undefined control sequence. [\makeatother]

참고로, 위의 코드에서는 행 \newtheorem에 주석을 달 경우 예제가 작동하도록 하기 위해서만 사용하고 있습니다 \usepackage{thmtools}. 을 사용하면 동일한 문제가 발생합니다 \declaretheorem(물론 없이는 사용할 수 없습니다 thmtools).

여기서 무슨 일이 일어나고 있나요?

추신: 저는 클래스 파일을 작성하고 있고 여러 언어와의 호환성을 유지하고 싶어서 정리 이름으로 "Teorema"만 쓰는 것이 아닙니다.

답변1

닭고기인가 달걀인가?;-)

\cref@theorem@name\newtheorem언제 발행되는지는 아직 정의되지 않았습니다 . 해결책: \noexpand.

\documentclass[italian]{article}
\usepackage[T1]{fontenc}

\usepackage{amsthm}
\usepackage{thmtools} % Comment this line and it works
\usepackage[capitalise]{cleveref}
\usepackage{babel}

\makeatletter
\newtheorem{theorem}{\noexpand\cref@theorem@name}
\makeatother

\begin{document}

\begin{theorem}\label{test}
Let ABC be a triangle. If it hits your head it will hurt\ldots
\end{theorem}

\cref{test}

\end{document}

여기에 이미지 설명을 입력하세요

이것을 호환되게 만들려면 기호 이름 앞에 '를 \declaretheorem몇 개 추가해야 합니다 .\noexpand

덜 무거운 방법은 다음과 같습니다.

\documentclass[italian]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}

\usepackage{amsthm}
\usepackage{thmtools} % Comment this line and it works
\usepackage[capitalise]{cleveref}

\newcommand{\dtname}[1]{%
  \expandafter\noexpand
  \expandafter\noexpand
  \expandafter\noexpand
  \csname cref@#1@name\endcsname
}
\newcommand{\ntname}[1]{%
  \expandafter\noexpand
  \csname cref@#1@name\endcsname
}

\newtheorem{theorem}{\ntname{theorem}}

\declaretheorem[name=\dtname{lemma}]{lemma}

\begin{document}

\begin{lemma}\label{tl}
$0\ne 1$
\end{lemma}

\begin{theorem}\label{test}
Sia $ABC$ un triangolo. Se ti piglia in testa ti farà male.
\end{theorem}

Il \cref{test} e il \cref{tl} sono importanti.

\end{document}

여기에 이미지 설명을 입력하세요

관련 정보