
나는 \ref를 사용하여 레이블을 참조하고 숫자(예: 1) 대신 알파벳 문자(예: 'A')를 출력하려고 합니다.
\AAAlphanum{\ref{my_label}}을 사용하는 방법을 읽었지만 이 명령은 실패합니다.
숫자가 누락되어 0으로 처리됩니다.
어떤 도움이라도 대단히 감사하겠습니다.
답변1
이를 달성할 수 있는 방법에는 여러 가지가 있습니다.
\documentclass{article}
\usepackage{zref,refcount,alphalph,hyperref}
\makeatletter
\zref@newprop{AlphAlphcntr}[??]{\AlphAlph{\value{section}}}
\newcommand{\mylabel}[1]{\zref@labelbyprops{#1}{AlphAlphcntr}}
\newcommand{\myref}[1]{\zref@refused{#1}\zref@extract{#1}{AlphAlphcntr}}
\makeatother
\setlength{\parindent}{0pt}% Just for this example
\begin{document}
\section{A section}\label{sec:mysection}\mylabel{sec:mysection}
Section~\ref{sec:mysection}. \par
Section~\AlphAlph{\getrefnumber{sec:mysection}}. \par
Section~\myref{sec:mysection}.
\end{document}
첫 번째 참조에서는 를 사용합니다 \ref
. 기본값은 에 설정된 값입니다 \the<counter>
(이 경우 \arabic{section}
). 두 번째 참조는 \getrefnumber
에서 제공하는 확장형을 사용합니다.refcount
. 마지막 참조에서는 사용자 정의 속성 목록을 사용합니다(zref
\AlphAlph
) 카운터 버전 만 저장 및/또는 검색합니다 section
.
위의 모든 항목을 확장하여 사용할 수 있습니다.hyperref
, 물론.