其实这是一位群友的问题,按照惯例来自答一下...
一个可能的答案来自 link 。
进行如下设置即可:
\makeatletter
\def\ttl@useclass#1#2{%
\@ifstar
{\ttl@labelfalse\@dblarg{#1{#2}}}% {\ttl@labelfalse#1{#2}[]}%
{\ttl@labeltrue\@dblarg{#1{#2}}}}
\makeatother
下面是实现的效果:
\documentclass{ctexart}
\usepackage{nameref}
\usepackage{xcolor}
\usepackage{titlesec}
\titleformat{\section}[frame]
{\normalfont\color{magenta}}
{\footnotesize \enspace \Large \textcolor{magenta}{\S \,\thesection}\enspace}{6pt}
{\Large\filcenter \bf \songti }
\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{第一章AAA}\label{sec:A}
我要引用section C: \nameref{sec:C}
\section*{第二章BBB}\label{sec:B}
我要引用section A: \nameref{sec:A}
\section{第三章CCC}\label{sec:C}
我要引用section B: \nameref{sec:B}
\end{document}
这个titleformat
感觉有点子眼熟,fncychap
宏包提供了类似的样式..如下
问 titlesec宏包与nameref宏包的冲突问题