
\nameref
載入時star
版本的中斷section
。我有一個預設對段落進行編號的文檔,但我有一些不想編號但想參考的文檔。這些都標有,但是,如果同時載入套件,則會導致顯示空字串(hyperref 的連結框仍然可見)。paragraph
titlesec
\paragraph*
titlesec
nameref
微量元素:
\documentclass[12pt]{article}
\usepackage[sf]{titlesec} %comment this out and it works fine.
\usepackage{hyperref}
\begin{document}
\section{Sections}
\label{sec}
This is \nameref{sec}
\paragraph{A named Paragraph}
\label{par}
This is \nameref{par}
\paragraph*{A starred named Paragraph}
\label{par:star}
This is \nameref{par:star}
\end{document}
我懷疑 titlesec 會導致切片命令的所有星形變體出現此缺陷,但尚未對此進行測試。僅對我而言paragraph*
相關,但修復所有變體將是最好的。
我有預感,可能與此有關:https://tex.stackexchange.com/a/6658/19326然而,這恰好超出了我的乳膠知識,對我來說只是「魔法」。
答案1
將以下內容加入序言中:
\makeatletter
\def\ttl@useclass#1#2{%
\@ifstar
{\ttl@labeltrue\@dblarg{#1{#2}}}% {\ttl@labelfalse#1{#2}[]}%
{\ttl@labeltrue\@dblarg{#1{#2}}}}
\makeatother
這允許\<section>[<ToC>]{<regular>}
使用分段單元處理常規參數\<section>
。此外,設定\ttl@labeltrue
會插入適當的hyperref
錨。
\documentclass[12pt]{article}
\usepackage[sf]{titlesec} %comment this out and it works fine.
\usepackage{hyperref}
\makeatletter
\def\ttl@useclass#1#2{%
\@ifstar
{\ttl@labelfalse\@dblarg{#1{#2}}}% {\ttl@labelfalse#1{#2}[]}%
{\ttl@labeltrue\@dblarg{#1{#2}}}}
\makeatother
\begin{document}
\section{Sections}
\label{sec}
This is \nameref{sec}
\paragraph{A named Paragraph}
\label{par}
This is \nameref{par}
\paragraph*{A starred named Paragraph}
\label{par:star}
This is \nameref{par:star}
\end{document}
沒有經過廣泛測試。