克莱弗雷夫包未找到浮动环境中的标签。相反,它显示???
我是否需要为浮动添加额外的属性?
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath,amssymb}
\usepackage{amsthm}
\usepackage{mathrsfs}
\usepackage{cleveref}
\usepackage{float}
\newfloat{Code}{htbp}{lop}
\pagenumbering{gobble}
\begin{document}
\Cref{some-reference}
\begin{Code}
\begin{algorithmic}
\Procedure{\texttt{AG\_EVAL}}{$\hat{r}, \mathit{Val}$}
\If{$\hat{r} \equiv v_0 \texttt{=} g( v_1, \dots, v_n)$}
\For{$\forall i \in [1, n]$}
\If{$v_i \not \in \mathit{Val}$}
\State Error: \emph{Cannot read attribute instance value before its ready.}
\EndIf
\EndFor
\State $\mathit{Val}(v_0) \gets g( \mathit{Val}(v_1), \dots, \mathit{Val}(v_n))$
\EndIf
\EndProcedure
\end{algorithmic}
\caption{This is an important code}
\label{some-reference}
\end{Code}
\end{document}
答案1
用 替换合适的标签字符串??
是因为 OP 定义并使用了一种新的浮点类型,称为Code
。虽然cleveref
非常聪明,但它还不够聪明,无法自己确定在新孵化的浮动环境中使用哪个标签字符串。幸运的是,该cleveref
包提供了宏\crefname
和\Crefname
,以便用户可以告知包应该将哪些文本标签与新设计的浮点类型一起使用。
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[a4paper, total={6in, 8in}]{geometry}
\usepackage{algorithm}
\usepackage{algpseudocode}
\usepackage{amsmath,amssymb,amsthm,mathrsfs}
\usepackage{tikz}
\usetikzlibrary{positioning,calc,arrows.meta}%arrows is deprecated
\usepackage{framed,blindtext}
\pagenumbering{gobble}
\usepackage{float}
\newfloat{Code}{htbp}{lop} % <-- run this *before* loading `cleveref`
\usepackage[colorlinks,allcolors=blue]{hyperref} % optional
\usepackage[nameinlink]{cleveref} % load this package *last*
\crefname{Code}{code}{codes} % <-- new
\Crefname{Code}{Code}{Codes} % <-- new
\begin{document}
\noindent
\Cref{some-reference}
\begin{Code}
\begin{algorithmic}
\Procedure{\texttt{AG\_EVAL}}{$\hat{r}, \mathit{Val}$}
\If{$\hat{r} \equiv v_0 \mathrel{\texttt{=}} g( v_1, \dots, v_n)$}
\For{$\forall i \in [1, n]$}
\If{$v_i \not \in \mathit{Val}$}
\State Error: \emph{Cannot read attribute instance value before its ready.}
\EndIf
\EndFor
\State $\mathit{Val}(v_0) \gets g( \mathit{Val}(v_1), \dots, \mathit{Val}(v_n))$
\EndIf
\EndProcedure
\end{algorithmic}
\caption{This is an important code}
\label{some-reference} % <-- always place \label after \caption
\end{Code}
\end{document}