我正在尝试制作一个带有附加信息的章节标题。目前我只是更改样式并将文本直接添加到章节标题中,但它会产生意想不到的副作用,即当我 \nameref 它时会被包含在内。
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\begin{document}
\section*{Section One {\footnotesize \textnormal A section of important stuff}\label{sec1}}
Stuff for the section goes here.
\section*{Another Section}
I try to reference \nameref{sec1} and I get the complete title, while I only want to see "Section Title"
\end{document}
答案1
这里我定义了两个新命令,\runinsec
和\aftersec
,前者用于section
在需要这样的部分时代替,后者用于在部分标题的同一行中插入信息。
梅威瑟:
\documentclass{article}
\usepackage[hidelinks]{hyperref}
\makeatletter
\newcommand\runinsec{\@startsection {section}{1}{\z@}%
{3.5ex \@plus 1ex \@minus .2ex}%
{-1em}%
{\normalfont\Large\bfseries}}
\newcommand\aftersec[1]{\begingroup\normalfont\footnotesize\bfseries #1\endgroup%
\par\nobreak\vspace*{2.3ex}\noindent\ignorespaces}
\makeatother
\begin{document}
\runinsec*{Section One}\label{sec1}\aftersec{A section of important stuff}
Stuff for the section goes here.
\section*{Another Section}
I try to reference \nameref{sec1} and I get the complete title, while I only want to see "Section Title"
\end{document}
输出