perf~\ref{soft_reset_perf}
\phantomsection
\item[perf]:~\label{soft_reset_perf} Indicates that a soft reset has been performed.
它在“perf”旁边显示部分编号。我怎样才能获得没有部分编号的链接?
我~\nameref{soft_reset_perf}
得到了定义标签的部分的名称。我希望显示项目名称(本例中为“perf”)而不是部分名称。
答案1
这是实现输出的另一种方法。由于您要引用标签的名称,因此使用分段单元是理想的选择。
在下面的例子中,我已将其定义\Item
为类似于\paragraph
(它被设置为“段落级别”,并进行了一些间距调整),因为它现在是一个分段单元。因此,使用\label{<lab>}
和\nameref{<lab>}
可以按预期工作:
\documentclass{article}
\usepackage{nameref}% http://ctan.org/pkg/nameref
\makeatletter
\newcommand\Item{\@startsection{paragraph}{4}{-2em}%
{0pt}%
{0pt}%
{\normalfont\normalsize\bfseries}}
\makeatother
\begin{document}
For more information, see~\nameref{soft_reset_perf} or~\nameref{something}.
\begingroup
\setlength{\leftskip}{2em}% Correct for \Item adjustment
\Item{perf}:~\label{soft_reset_perf} Indicates that a soft
reset has been performed. Here is some more text. Here is some
more text. Here is some more text. Here is some more text.
\Item{something}:~\label{something} This is just an interesting
item that will be referenced by name at a different location in
the document.\par
\endgroup
\end{document}
为了模拟itemize
环境,我使用负缩进(无缩进?)排版了\Item
。2em
因此,为了纠正水平偏移,左边距被向右推了2em
(通过设置\leftskip
)。有关 定义中特定组件的帮助\Item
,请考虑阅读在哪里可以找到类似 LaTeX 的 \@startsection 命令的帮助文件或文档?
答案2
\documentclass{article}
\usepackage{nameref}
\begin{document}
For more information, see~\nameref{soft_reset_perf} or~\nameref{something}.
\paragraph{perf}:~\label{soft_reset_perf} Indicates that a soft
reset has been performed. Here is some more text. Here is some
more text. Here is some more text. Here is some more text.
\paragraph{something}:~\label{something} This is just an interesting
item that will be referenced by name at a different location in
the document.
\end{document}