Cleverref 的问题

Cleverref 的问题

我对 有疑问cleveref。显然,它不适用于mdframed

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=2.50cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\usepackage{xcolor}
% Definition of colors
\definecolor{toc_heading}{RGB}{0 51 89}
\definecolor{toc}{RGB}{0 119 138}
\definecolor{section}{RGB}{0 113 187}
\definecolor{subsection}{RGB}{0 115 207}
\definecolor{headline}{RGB}{77 112 139}
\definecolor{citecolor}{RGB}{0 124 48}

\usepackage{amsthm}

\usepackage[framemethod=TikZ]{mdframed}
\mdfsetup{skipbelow=3ex}
\newtheorem{dummy}{dummy}[chapter]


\newmdtheoremenv [%
 hidealllines=true, leftline=true,
 linewidth = 2pt,  linecolor=section,
 leftmargin = 0,rightmargin = 0,%
 skipabove=\dimexpr\parskip+10pt\relax,
 innertopmargin = 0,splittopskip =3ex,
 innerrightmargin=2ex,splitbottomskip=3ex,innerbottommargin=2ex,
 ntheorem = false ,backgroundcolor=section!20%
]{theorem}[dummy]{Theorem}
\usepackage{hyperref}
\usepackage{cleveref}
\crefname{theorem}{theorem}{theorems}
\begin{document}
\chapter{Chapter 1}
\begin{theorem}\label{thm:1}    bla
\end{theorem}
 This is \cref{thm:1}.

\end{document}

此代码生成:这是?? 1.1。

有没有人遇到过类似的问题?

答案1

的使用\newmdtheoremenv为时过早,在cleveref可以应用其自己的版本\label等之前已经“修复”了交叉引用格式。

加载 之后,的定义theorem必须转移cleveref

\documentclass[12pt,a4paper]{book}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage[left=2.50cm, right=2.00cm, top=2.00cm, bottom=2.00cm]{geometry}
\usepackage{xcolor}
% Definition of colors
\definecolor{toc_heading}{RGB}{0 51 89}
\definecolor{toc}{RGB}{0 119 138}
\definecolor{section}{RGB}{0 113 187}
\definecolor{subsection}{RGB}{0 115 207}
\definecolor{headline}{RGB}{77 112 139}
\definecolor{citecolor}{RGB}{0 124 48}

\usepackage{amsthm}

\usepackage[framemethod=TikZ]{mdframed}
\mdfsetup{skipbelow=3ex}
\newtheorem{dummy}{dummy}[chapter]


\usepackage{hyperref}
\usepackage{cleveref}


\newmdtheoremenv [%
 hidealllines=true, leftline=true,
 linewidth = 2pt,  linecolor=section,
 leftmargin = 0,rightmargin = 0,%
 skipabove=\dimexpr\parskip+10pt\relax,
 innertopmargin = 0,splittopskip =3ex,
 innerrightmargin=2ex,splitbottomskip=3ex,innerbottommargin=2ex,
 ntheorem = false ,backgroundcolor=section!20%
]{theorem}[dummy]{Theorem}

\crefname{theorem}{theorem}{theorems}
\begin{document}
\chapter{Chapter 1}
\begin{theorem}\label{thm:1}    bla
\end{theorem}
 This is \cref{thm:1}.

\end{document}

在此处输入图片描述

相关内容