有没有办法可以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}