4

Is there way so that one can replace By Theorem \ref{theo1} by By \ref{theo1} without changing output in the following document:

\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}
Minimus Heximus
  • 715
  • 6
  • 19

1 Answers1

4

The cleveref package provides the macro \cref, which does what you're looking for.

enter image description here

\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}
Mico
  • 506,678