참조에서만 카운터 인쇄 변경

참조에서만 카운터 인쇄 변경

enumi다음과 같은 문제가 있습니다. 처음 나타날 때와 다른 이름으로 참조하는 데 사용하고 싶은 카운터(내 경우에는)가 있습니다 . 이를 수행할 수 있는 Tex/Latex 도구가 있습니까?

좀 더 정확하게 말하자면, 문서 본문에 다음과 같이 쓰고 싶습니다.

\section{Lorem}
\subsection{Ipsum}

\begin{enumerate}
\item \label{my_item} dolor sit amet
\item consectetur
\end{enumerate}

목록이 다음과 같이 표시되도록 합니다.

i) dolor sit amet

ii) 연결

하지만 1.1.i를 가져오는 경우 \ref{my_item}("Ipsum"이 하위 섹션 1.1이라고 가정) 그래서 사용 :

\renewcommand{\theenumi} {\bf \arabic{section}.\arabic{subsection}.\roman{enumi}~}

내가 원하는 것은 아니다.

답변1

추가 LaTeX 패키지를 로드하지 않고도 형식 지정 목표를 달성할 수 있습니다(물론 적합한 패키지를 로드하는 데 아무런 문제가 없지만). 프리앰블에 다음 코드를 추가하면 됩니다.

\renewcommand\labelenumi{\roman{enumi})} % determine look of label
\renewcommand\theenumi\labelenumi
\makeatletter
\renewcommand\p@enumi{\thesubsection.} % "prefix" for cross-references
\makeatother

전체 MWE:

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

\documentclass{article} 
\renewcommand\labelenumi{\roman{enumi})}
\renewcommand\theenumi\labelenumi
\makeatletter
\renewcommand\p@enumi{\thesubsection.}
\makeatother
\begin{document} 

\section{Lorem}
\subsection{Ipsum}

\begin{enumerate}
\item \label{my_item} dolor sit amet
\item consectetur
\end{enumerate}

\section{Dolor}

A cross-reference to item \ref{my_item}.
\end{document}

부록enumitem: 다음과 같이 패키지를 로드하면 동일한 출력을 얻을 수 있습니다 .

\usepackage{enumitem}
\setlist[enumerate,1]{label*=\roman*),
                      ref=\thesubsection.\roman*)}

관련 정보