Cleveref 找不到标签

Cleveref 找不到标签

以下代码给出了节而不是路标作为参考。这可能是初学者的错误。

\documentclass{article}

\usepackage{tikz}
\usepackage{mdframed}


\newcounter{signpost}%
\newenvironment{signpost}[1][]{%
    \stepcounter{signpost}%
        \ifstrempty{#1}%
        {\mdfsetup{%
            frametitle={%
                \tikz[baseline=(current bounding box.east),outer sep=0pt]
                \node[anchor=east,rectangle,fill=blue!20]
                {\strut Summary~\thesignpost};}}
        }%
        {\mdfsetup{%
            frametitle={%
                \tikz[baseline=(current bounding box.east),outer sep=0pt]
                \node[anchor=east,rectangle,fill=blue!20]
                {\strut Summary~\thesignpost:~#1};}}%
        }%
        \mdfsetup{innertopmargin=10pt,linecolor=blue!20,%
            linewidth=2pt,topline=true,
            skipabove=6pt, skipbelow=6pt, nobreak=true,
            frametitleaboveskip=\dimexpr-\ht\strutbox\relax,}
        \begin{mdframed}[]\relax%
        }{\end{mdframed}}

\usepackage[noabbrev]{cleveref}
\crefname{signpost}{summary}{summaries} 



\begin{document}

\section{Hello Stackexchange}

This is some text.

\begin{signpost}[This is a summary]
This is a summary of the above text.
\label{signpost:MWE}
\end{signpost}

In \cref{signpost:MWE} you see \ldots

\end{document}

我需要做什么改变才能得到“在路标 1 中你看到……”

答案1

你只需要改为\stepcounter{signpost}\refstepcounter{signpost}后者使你的signpost计数器成为引用机制使用的计数器。

相关内容