
\usepackage{algorithm,algpseudocode}
\usepackage{hyperref}
그래서 내가 언제
\begin{algorithm}
\caption{Baseline}\label{ALG_baseline}
\begin{algorithmic}[1]
...
\end{algorithmic}
\end{algorithm}
출력은 다음과 같습니다.
--------------------------------------
Algorithm 1: Baseline
--------------------------------------
...
--------------------------------------
분명히 카운터가 이미 있습니다.
하지만
\autoref{ALG_baseline} is simply linked to with a number.
결과는 int입니다.
[1] is simply linked to with a number.
자동 참조 출력을 어떻게 만들 수 있나요?
[Algorithm 1] is ...
대신에?
답변1
\autoref
\....autorefname
해당 매크로 에서만 완전히 작동합니다 \sectionautorefname
.
hyperref
관련 카운터 이름도 저장되어 있는 특정 라벨 정보에서 참조 정보를 추출합니다.
즉, 카운터 이름이 이면 foo
존재 \fooautorefname
해야 합니다. 그렇지 않으면 무시됩니다(그리고 콘솔에 경고가 표시됩니다).
환경 algorithm
에 동일한 이름의 카운터가 있으므로
\newcommand{\algorithmautorefname}{Algorithm}
hyperref
올바른 정보를 제공하겠습니다 .
\documentclass{article}
\usepackage{algorithm,algpseudocode}
\usepackage{hyperref}
\newcommand{\algorithmautorefname}{Algorithm}
\begin{document}
\begin{algorithm}
\caption{Baseline}\label{ALG_baseline}
%\begin{algorithmic}[1]
%
%\end{algorithmic}
\end{algorithm}
\autoref{ALG_baseline} is simply linked to with a number.
\end{document}
해당 cleveref
패키지는 유사한 기능을 제공하지만 이름도 설정해야 합니다 \crefname{algorithm}{algorithm}{algorithms}
.
업데이트
이는 카운터 이름 감지에 대한 OP의 의견을 해결합니다.
파일 발췌 .log
:
카운터 정의는 파일에 다음 .log
과 같이 기록됩니다 c@foo=\countY
. 여기서 는 Y
사용 가능한 카운터 레지스터의 수이며 실제로는 중요하지 않습니다(몇 가지 예외를 제외하고).
\@float@every@algorithm=\toks16
\c@algorithm=\count88
나중에 우리는 발견합니다.
\c@ALG@line=\count89
\c@ALG@rem=\count90
\c@ALG@nested=\count91
\ALG@tlm=\skip43
\ALG@thistlm=\skip44
\c@ALG@Lnr=\count92
\c@ALG@blocknr=\count93
\c@ALG@storecount=\count94
\c@ALG@tmpcounter=\count95
\ALG@tmplength=\skip45
이는 ALG@line
라인 번호 카운터일 가능성이 매우 높다는 것을 의미합니다.
@
그러나 이름의 사용 으로 인해 '숨겨진' 카운터입니다 !
답변2
하이퍼참조 기본 알고리즘 이름을 덮어쓰려면 \newcommand 대신 \renewcommand{}를 사용해야 한다는 사실을 알아내기 위해 절반의 시간이 걸렸습니다.