4
\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 ...

As the image shows, the output of \ref is "1.0.1". Is there a substitute of \ref whose output is "Theorem 1.0.1" instead of only the number "1.0.1"?

enter image description here

cgnieder
  • 66,645
  • 1
    Welcome to the TeX.SE. Off-topic. Excuse me if I give you this suggestion: why do not use amsthm package? – Sebastiano Jul 11 '20 at 22:27
  • Peraphs your question is a duplicate of this question: https://tex.stackexchange.com/questions/109843/cleveref-and-named-theorems or this https://tex.stackexchange.com/questions/2450/a-better-way-to-reference-theorem-like-environments – Sebastiano Jul 11 '20 at 22:33
  • 2
    There are several packages that place both the "ambient", as you put it, and the associated number in the cross-referencing call-out. Among them are prettyref, smartref, fancyref, and theoremref. (The latter works for theorem-like environments ontly.) There's also \autoref of the hyperref package. That said, the undisputed current king of cross-referencing packages is cleveref and its user macros \cref and \crefrange. See Cross-reference packages: which to use, which conflict? for more information on these packages. – Mico Jul 12 '20 at 06:17
  • Incidentally, your code doesn't compile; it makes use an undefined environment named theorem. It also lacks \begin{document} and \end{document} directives. – Mico Jul 12 '20 at 06:21

1 Answers1

3
\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}

enter image description here

user187802
  • 16,850