
\section{Proof of Theorem~\ref{thm:main}}
無法產生正確的 pdf 書籤(使用hyperref
包)。
\section{Proof of \texorpdfstring{Theorem~\ref{thm:main}}{Theorem 3.1.7}}
會給出想要的結果(\texorpdfstring 和標題設置),但由於「3.1.7
」是硬編碼的,每次重新排列文字時我都必須更改這行程式碼。
我知道許多數學論壇不能用作 pdf 字串(pdf 書籤),因為它們沒有 Unicode 表示(在章節標題中自動加入數學模式 \texorpdfstring)。
但「定理 3.1.7」僅包含純 ASCII 符號。因此,至少從理論上講,應該可以為此實施自動解決方案。
理想情況下,我希望有一個允許我編寫的程式碼:
\section{Proof of \Cref{thm:main}}
(透過使用該cleveref
包,但解決方案\ref
也已經非常有幫助)
例子:
\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}
\newtheorem{theorem}{Theorem}[section]
\begin{document}
\begin{theorem}\label{thm:main}
text
\end{theorem}
many pages
\section{Proof of \Cref{thm:main}}
\end{document}
(此程式碼沒有給出正確的pdf書籤)
hypperref
(PS:我認為在或 包中包含這樣的程式碼真是太棒了cleveref
)
答案1
您可以使用帶有星號的版本 \ref:
\documentclass{article}
\newtheorem{theorem}{theorem}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\section{Proof of Theorem~\texorpdfstring{\ref{thm:main}}{\ref*{thm:main}}}
\begin{theorem}
\label{thm:main} some theorem
\end{theorem}
\end{document}
答案2
@Phelype Oleinik 連結到一個非常好的解決方案https://tex.stackexchange.com/a/485979/128042
\documentclass{article}
\usepackage{hyperref}
\usepackage{cleveref}
\newtheorem{theorem}{Theorem}[section]
\usepackage{crossreftools}
\pdfstringdefDisableCommands{%
\let\Cref\crtCref
\let\cref\crtcref
}
\begin{document}
\begin{theorem}\label{thm:main}
text
\end{theorem}
many pages
\section{Proof of \Cref{thm:main}}
\end{document}
這個解決方案對不同的問題隱藏部分標題中的 smartef 鏈接也完美回答了這個問題。
烏爾麗克費雪溶液https://tex.stackexchange.com/a/504969/128042如果您無法使用該crossreftools
軟體包,這是一個很好的選擇。