![更改参考样式以包含标题](https://linux22.com/image/480736/%E6%9B%B4%E6%94%B9%E5%8F%82%E8%80%83%E6%A0%B7%E5%BC%8F%E4%BB%A5%E5%8C%85%E5%90%AB%E6%A0%87%E9%A2%98.png)
\documentclass[a4paper]{scrartcl}
\usepackage{amsthm}
\usepackage[pdftex,svgnames,hyperref]{xcolor}
\usepackage{thmtools}
\usepackage{hyperref}
\newtheorem{defi}{Definition}[subsection]
\newtheorem{lemma}[defi]{Lemma}
\newtheorem{cor}[defi]{Corollary}
\newtheorem{theorem}[defi]{Theorem}
\newtheorem*{theorem*}{Theorem}
\declaretheorem[style=remark, name=Remark, sibling=defi]{rem}
\declaretheorem[style=remark, name=Remark, sibling=defi, numbered=no]{rem*}
\declaretheorem[style=remark, name=Example, sibling=defi]{bsp}
\newcommand{\defword}[1]{\textbf{#1}}
\begin{document}
\begin{theorem}\label{spectraltheorem}
\defword{Spectral Theorem for compact and self-adjoint operators}\\
\end{theorem}
\begin{proof}
Blablabla.
\end{proof}
Want to reference \ref{spectraltheorem} but should look like \textbf{Theorem 0.0.1} with red box around it.
\end{document}
答案1
您可以使用该cleveref-usedon
包:
\documentclass[a4paper]{scrartcl}
\usepackage{amsthm}
\usepackage[svgnames]{xcolor}
\usepackage{thmtools}
\usepackage{hyperref}
\newtheorem{defi}{Definition}[subsection]
\newtheorem{lemma}[defi]{Lemma}
\newtheorem{cor}[defi]{Corollary}
\newtheorem{theorem}[defi]{Theorem}
\newtheorem*{theorem*}{Theorem}
\declaretheorem[style=remark, name=Remark, sibling=defi]{rem}
\declaretheorem[style=remark, name=Remark, sibling=defi, numbered=no]{rem*}
\declaretheorem[style=remark, name=Example, sibling=defi]{bsp}
\newcommand{\defword}[1]{\textbf{#1}}
\usepackage[capitalise,nameinlink]{cleveref-usedon}
\makeatletter
\patchcmd{\@cref}{\begingroup}{\begingroup\bfseries}{}{}
\makeatother
\begin{document}
\begin{theorem}\label{spectraltheorem}
\defword{Spectral Theorem for compact and self-adjoint operators}\\
\end{theorem}
\begin{proof}
Blablabla.
\end{proof}
Want to reference \cref{spectraltheorem} but should look like \textbf{Theorem 0.0.1} with red box around it.
\end{document}