有没有 \ref 的替代品,可以同时写出环境的名称和编号?

有没有 \ref 的替代品,可以同时写出环境的名称和编号?
\documentclass[12pt, a4paper,openright,oneside]{book}

\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{amssymb, amsmath}
\usepackage{tikz-cd}

\newenvironment{definition}[1][Definition]{\begin{trivlist}
        \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{remark}[1][Remark]{\begin{trivlist}
        \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}
\newenvironment{proof}[1][Proof]{\begin{trivlist}
        \item[\hskip \labelsep {\bfseries #1}]}{\end{trivlist}}

\begin{theorem} \label{thm}
4 is a multiple of 2.
\end{theorem}

A consequence of \ref{thm} is that ...

如图所示, 的输出\ref为“1.0.1”。 是否有一个 的替代品,\ref其输出是“定理 1.0.1”,而不仅仅是数字“1.0.1”?

在此处输入图片描述

答案1

\documentclass[12pt, a4paper,openright,oneside]{book}

\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage{amssymb, amsthm, amsmath}
\usepackage{cleveref}

\newtheorem{theorem}{Theorem}
\newtheorem{remark}{Remark}

\begin{document}
 
\begin{theorem} \label{thm}
4 is a multiple of 2.
\end{theorem}

A consequence of \cref{thm} or \Cref{thm} is that ...

\begin{remark} \label{rmk}
4 is a multiple of 2.
\end{remark}

A consequence of \Cref{rmk} is that ...

\begin{proof} 
$2*2=4$ 
\end{proof}

\end{document}

在此处输入图片描述

相关内容