
\ref を使用してラベルを参照し、数字 (例: 1) ではなくアルファベットの文字 (例: 'A') を出力しようとしています。
どこかで\AAAlphanum{\ref{my_label}}を使うように読んだのですが、このコマンドは失敗します
欠落した数字はゼロとして扱われます。
どのような助けでも大歓迎です。
答え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}
)にデフォルト設定されます。2番目の参照では、\getrefnumber
によって提供される展開可能な が使用されます。refcount
最後の参照では、カスタムプロパティリスト(zref
\AlphAlph
) を使用して、カウンターの -バージョンのみを保存および/または取得しますsection
。
上記のすべてを拡張して、hyperref
、 もちろん。