我不断在文本的不同区域添加一类句子:
\section{...}
...
sentence1
...
\subsection{...}
...
sentence2
...
\section{...}
...
sentence3
...
我想制作一个add
机制,标记所有句子,然后通过以下方式将它们总结在一个地方listallthesentences
:
\section{...}
...
\add{sentence1}
...
\subsection{...}
...
\add{sentence2}
...
\section{...}
...
\add{sentence3}
...
\section{summary}
\listallthesentences
在摘要中,如果所有句子都重复并且指向其初始位置,效果会更好。
有人知道如何实现这一点吗?
答案1
您可以使用\@starttoc
它来生成类似于 ToC、Lof 或 LoT 的列表(但是,从描述中不清楚“标记句子”的含义):
\documentclass{article}
\usepackage{hyperref}
\makeatletter
\newcommand\listofsentences{\@starttoc{los}}
\newcommand\addsentence[1]{%
\par\csname phantomsection\endcsname\addcontentsline{los}{section}{#1}#1\par}
\makeatother
\begin{document}
\section{Test Section One}
\addsentence{This is a test sentence.}
\section{Test Section Two}
\addsentence{This is another test sentence.}
\section{Summary}
\listofsentences
\end{document}
新列表中的条目没有页码且具有正常字体的变体(在评论中请求):
\documentclass{article}
\usepackage{hyperref}
\makeatletter
\newcounter{sentence}
\newcommand\listofsentences{\@starttoc{los}}
\newcommand\addsentence[1]{%
\stepcounter{sentence}%
\par\csname phantomsection\endcsname\addcontentsline{los}{sentence}{#1}#1\par}
\newcommand\l@sentence[2]{\par\noindent#1}
\makeatother
\begin{document}
\section{Test Section One}
\addsentence{This is a test sentence.}
\section{Test Section Two}
\addsentence{This is another test sentence.}
\section{Summary}
\listofsentences
\end{document}