설명 환경 간 공유 카운터로 인해 "정의되지 않은 제어 순서"가 발생함

설명 환경 간 공유 카운터로 인해 "정의되지 않은 제어 순서"가 발생함

목표는 SharedCTR1설명 환경 전체에서 카운터를 공유하는 것입니다. 다음 코드는 하나의 설명 환경에서만 작동하지만 둘 다에서는 작동하지 않습니다.

\documentclass{report}

\begin{document}

{\newcounter{SharedCTR}
\def\SharedCTR1{\stepcounter{SharedCTR}\arabic{SharedCTR}}

\section{Section one}

\begin{description}
  \item[desc \SharedCTR1.] text text.
  \item[desc \SharedCTR1.] text text text.
  \item[desc \SharedCTR1.] text text text text.
\end{description}                                %% In original doc: extra curly bracket was here.


\section{Section two}

\begin{description}
  \item[desc \myUseCaseCTR1.] text text.          % Fails on this line.
  \item[desc \myUseCaseCTR1.] text text text.
  \item[desc \myUseCaseCTR1.] text text text text.
\end{description}

\end{document}

처음에는 이름에 있는 숫자가 문제인 줄 알았는데 1, 제거해도 여전히 작동하지 않습니다. 오류는 다음과 같습니다.

! Undefined control sequence.
<argument> desc \myUseCaseCTR 
                              1.
l.20   \item[desc \myUseCaseCTR1.]
                                   text text.          % Fails on this line.

[편집] 원본(긴) 문서에서는 어느 시점에 \end{description}}. }변수가 다른 설명 환경에서 다시 사용될 때 몇 줄 후에 오류를 일으키는 추가 중괄호가 있었습니다 . 문제를 발견하는 데 시간이 좀 걸렸습니다.

답변1

추가 항목을 삭제했지만 {큰 문제는 아니었습니다. 두 번째 정의( )를 정의하지 않으셨는데요, \myUseCaseCTR자세히 확인해보면 이름이 ( \SharedCTR)와 다릅니다. 나는 그것을 정의하기 위해 명령을 사용했습니다 \let. 행 번호 7을 참조하십시오.

실제 사례와 미리보기를 동봉합니다.

\documentclass{report}
\pagestyle{empty}
\begin{document}
%{ % Deleted
\newcounter{SharedCTR}
\def\SharedCTR1{\stepcounter{SharedCTR}\arabic{SharedCTR}}
\let\myUseCaseCTR=\SharedCTR
\section{Section one}
\begin{description}
  \item[desc \SharedCTR1.] text text.
  \item[desc \SharedCTR1.] text text text.
  \item[desc \SharedCTR1.] text text text text.
\end{description}
\section{Section two}
\begin{description}
  \item[desc \myUseCaseCTR1.] text text. % Failed on this line.
  \item[desc \myUseCaseCTR1.] text text text.
  \item[desc \myUseCaseCTR1.] text text text text.
\end{description}
\end{document}

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

관련 정보