为什么 \ref 只输入数字?

为什么 \ref 只输入数字?

有没有办法可以By Theorem \ref{theo1}By \ref{theo1}不改变以下文档中的输出的情况下进行替换:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{amsmath}


\newtheorem{theorem}{Theorem}

\begin{document}

\begin{theorem}\label{theo1}
I exist.
\end{theorem}


By Theorem \ref{theo1}, I exist.

\end{document}

答案1

聪明人包提供了宏\cref,它可以完成您要查找的操作。

在此处输入图片描述

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath,amsthm}
\usepackage[noabbrev,capitalize]{cleveref}
\newtheorem{theorem}{Theorem}

\begin{document}
\begin{theorem}\label{theo1}
I think.
\end{theorem}
\begin{theorem}\label{theo2}
I think some more.
\end{theorem}

By \cref{theo1}, I exist.

By \cref{theo1,theo2}, I exist some more.
\end{document}

相关内容