I amm having issues with \nameref
and \ref
not returning the desired output. I would like to have definitions referred to by Definition 0.0.1 (see below). I do not want the result of \nameref{defn1} to be bold and I would like the "Definition" to appear. More precisely, here is the output (via overleaf):
Here is the relevant TeX code:
\documentclass[11pt, reqno,openany]{amsbook}
\setlength{\parindent}{0pt}
\usepackage[colorlinks, linkcolor=black, citecolor=magenta, linktocpage]{hyperref}
\usepackage{amsmath}
\numberwithin{equation}{section}
\usepackage{scrextend}
\makeatletter
\numberwithin{section}{chapter}
\def\@secnumfont{\mdseries}
\def\section{\@startsection{section}{1}%
\z@{.7\linespacing\@plus\linespacing}{.5\linespacing}%
{\normalfont\scshape\centering}}
\def\subsection{\@startsection{subsection}{2}%\
\z@{.5\linespacing\@plus.7\linespacing}{-.5em}%
{\normalfont\bfseries}}
\patchcmd{\@thm}{\let\thm@indent\indent}{\let\thm@indent\noindent}{}{}
\patchcmd{\@thm}{\thm@headfont{\scshape}}{\thm@headfont{\bfseries}}{}{}
\usepackage{lipsum}
\makeatletter
\theoremstyle{plain}
\theoremstyle{definition}
\newtheorem{thm}{\textbf{Theorem}}[section]
\newtheorem{defn}[thm]{\textbf{Definition}}
\newtheorem{conv}[thm]{\textbf{Convention}}
\newtheorem{rmk}[thm]{\textbf{Remark}}
\newtheorem{crmk}[thm]{\textbf{Cautionary Remark}}
\newtheorem{notn}[thm]{\textbf{Notation}}
\newtheorem{ex}[thm]{\text{Example}}
\newtheorem{cor}[thm]{\textbf{Corollary}}
\newtheorem{prop}[thm]{\textbf{Proposition}}
\newtheorem{lem}[thm]{\textbf{Lemma}}
\newtheorem{q}[thm]{\textbf{Question}}
\renewcommand\thesubsection{\Alph{subsection}}
\renewcommand{\thedefn}{\textbf{\thesection.\thesubsection \arabic{defn}}}
\renewcommand{\thethm}{\textbf{\thesection.\thesubsection \arabic{thm}}}
\renewcommand{\theconv}{\textbf{\thesection.\thesubsection \arabic{conv}}}
\renewcommand{\thermk}{\textbf{\thesection.\thesubsection \arabic{rmk}}}
\renewcommand{\thecrmk}{\textbf{\thesection.\thesubsection \arabic{crmk}}}
\renewcommand{\thenotn}{\textbf{\thesection.\thesubsection \arabic{notn}}}
\renewcommand{\theex}{\thesection.\thesubsection \arabic{ex}}
\renewcommand{\theprop}{\textbf{\thesection.\thesubsection \arabic{prop}}}
\renewcommand{\thecor}{\textbf{\thesection.\thesubsection \arabic{cor}}}
\renewcommand{\thelem}{\textbf{\thesection.\thesubsection \arabic{lem}}}
\renewcommand{\theq}{\textbf{\thesection.\thesubsection \arabic{q}}}
\begin{document}
Consider the following:
\begin{ex}\label{example1}
Here is an example.
\end{ex}
Hence, define:
\begin{defn}\label{defn1}
We make the following definition.
\end{defn}
If I want to refer back to these, nameref does not yield anything: \nameref{example1} (Package hyperref warning: suppressing empty link). On the other hand, ref simply returns the number, e.g., \ref{defn1}. \\
I would like the reference to the example (respectively, definition) to appear as Example 0.0.1 (respectively, Definition 0.0.2).
\end{document}
\documentclass
).\nameref
returns the title, not the number. So with\begin{defn}[Famous definition]
you get Famous definition from it.