更改参考样式以包含标题

更改参考样式以包含标题
\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}

在此处输入图片描述

相关内容