我正在使用带有 rmarkdown 包的 latex。以下是包所在的 YAML 标题和书面文本。
- \usepackage{amsmath}
- \usepackage{amsthm}
- \usepackage{bbm}
- \numberwithin{equation}{section}
- \usepackage{makecell}
- \usepackage{indentfirst}
- \usepackage{geometry}
- \usepackage{graphicx}
- \usepackage{tikz}
- \usepackage{verbatim}
- \usepackage{chronosys}
- \usepackage{stackengine}
- \usepackage{booktabs, colortbl, xcolor}
- \usepackage{babel}
- \usetikzlibrary{arrows.meta,calc}
- \usepackage[font=small]{caption}
- \usepackage{adjustbox}
- \usepackage{tabularx}
- \usepackage{pgfplots}
- \pgfplotsset{compat=1.7}
- \usepackage[makeroom]{cancel}
- \usetikzlibrary{arrows,decorations.markings}
- \usetikzlibrary{intersections}
- \usepackage[nottoc]{tocbibind}
- \newtheorem{prop}{Proposition}
- \theoremstyle{definition}
- \newtheorem{assumption}{Assumption}
- \newtheorem{definition}{Definition}
- \newtheorem{algorithm}{Algorithm}
- \usepackage[T1]{fontenc}
- \usepackage{tabularx,ragged2e,booktabs,caption}
- \newenvironment{rcases}
{\left.\begin{aligned}}
{\end{aligned}\right\rbrace}
- \renewcommand{\refname}{References}
- \UseRawInputEncoding
- \usepackage[utf8]{inputenc}
- \usepackage{hyperref}
- \hypersetup{
colorlinks=true,
linkcolor=black,
filecolor=blue,
citecolor = blue,
urlcolor=blue,
}
- \usepackage{subcaption}
- \usepackage[font=small,labelfont=bf]{caption}
- \usepackage{float}
- \usepackage{flafter}
- \floatstyle{plaintop}
- \restylefloat{table}
- \setlength{\parindent}{2.5em}
- \setlength{\parskip}{0em}
- \usepackage{adjustbox}
- \usepackage[style=english]{csquotes}
- \usepackage[colorlinks,allcolors=red]{hyperref}
- \usepackage[nameinlink,noabbrev]{cleveref}
- \creflabelformat{equation}{#2\textup{(\textcolor{red}{#1})}#3}
- \creflabelformat{assumption}{#2\textup{(\textcolor{red}{#1})}#3}
- \creflabelformat{proposition}{#2\textup{(\textcolor{red}{#1})}#3}
- \creflabelformat{figure}{#2\textcolor{red}{#1}#3}
- \creflabelformat{table}{#2\textcolor{red}{#1}#3}
- \creflabelformat{section}{#2\textcolor{red}{#1}#3}
...
\medskip
\makeatletter
\renewcommand\@makefnmark{\hbox{\@textsuperscript{\normalfont\color{red}\@thefnmark}}}
\newcommand{\lccref}[1]{\lcnamecref{#1}~\labelcref{#1}}
\makeatother
\pagebreak
\tableofcontents
\pagebreak
\section{Introduction}
\begin{assumption}\label{assump1}
\normalfont The production is assumed to adopt a single technology.
\end{assumption}
\cref{assump1} suggests something.
但它会打印?? suggests something.
。
答案1
如果你加载amsthm
前 hyperref
并且cleveref
,您不需要执行任何\creflabelformat
指令(因为它们本质上复制相应的默认值),并且您不需要运行\crefname{assumption}{assumption}{assumptions}
任何一个。
\documentclass{article} % or some other suitable document class
\usepackage{amsthm} % for \theoremstyle and \newtheoerem macros
\usepackage[colorlinks,allcolors=red]{hyperref}
\usepackage[nameinlink,capitalize,noabbrev]{cleveref}
\newtheorem{prop}{Proposition}
\newtheorem{algorithm}{Algorithm}
\theoremstyle{definition} % <-- new (to use upright font shape for theorem body)
\newtheorem{assumption}{Assumption}
\newtheorem{definition}{Definition}
\begin{document}
\begin{assumption}\label{assump1}
Production is assumed to adopt a single technology.
\end{assumption}
\noindent
According to \cref{assump1}, \dots
\end{document}