![对文本中的句子进行编号](https://linux22.com/image/260111/%E5%AF%B9%E6%96%87%E6%9C%AC%E4%B8%AD%E7%9A%84%E5%8F%A5%E5%AD%90%E8%BF%9B%E8%A1%8C%E7%BC%96%E5%8F%B7.png)
我需要以一种明确的方式对文本中的句子进行编号,以表明数字不是文本的一部分。我能想到的最好的方法看起来很糟糕:
我会感激任何更有吸引力的东西!
值得一提的是,生成该代码的代码在这里:
\documentclass{article}
\usepackage{calc}
\usepackage[framemethod=tikz]{mdframed}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usepackage{environ,varwidth}
\mdfdefinestyle{tight}{roundcorner=1.5pt,innerleftmargin=0.7pt,innerrightmargin=0.7pt,innertopmargin=1pt,innerbottommargin=1pt,backgroundcolor=gray!20}
\newsavebox\MyTempBox
\NewEnviron{tight}{%
\savebox\MyTempBox{%
\begin{varwidth}{\linewidth}
\BODY
\end{varwidth}}%
\begin{minipage}{\dimexpr\wd\MyTempBox+2.5pt\relax}
\begin{mdframed}[style=tight,userdefinedwidth=\dimexpr\wd\MyTempBox+2.5pt\relax]
\BODY
\end{mdframed}%
\end{minipage}
}%
\newcommand\sno[1]{\begin{tight}\scriptsize\bf #1\end{tight}}
\begin{document}
\sno{21}Lorem Ipsum is simply dummy text of the printing and typesetting industry. \sno{22}Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \sno{23}It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. \sno{24}It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{document}
值得注意的一个小问题是,在数字后立即换行(如我上面例子中的 24)并不好。
答案1
简化,使用较小的数字并降低它们:
最小,
\documentclass{article}
\newcommand\sno[1]{$_{#1}$}
\begin{document}
\sno{21}Lorem Ipsum is simply dummy text of the printing and typesetting industry. \sno{22}Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \sno{23}It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. \sno{24}It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{document}
你也可以使用计数器自动计数,
\documentclass{article}
\newcounter{sno}
\setcounter{sno}{21}
\newcommand\sno{\stepcounter{sno}$_{\thesno}$}
\begin{document}
\sno Lorem Ipsum is simply dummy text of the printing and typesetting industry. \sno Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \sno It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. \sno It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{document}
答案2
甚至可以自动枚举句子。KOMAscript 包的作者和维护者 Markus Kohm 在名为 的包中实现了此功能scrjura
,但该手册从未被翻译成英文,因为它专注于德国律师的需求。
但也许你对这样的事情感兴趣:
\documentclass[pagesize, english]{scrartcl}
\usepackage{babel, scrjura, xcolor, etoolbox}
\useshorthands{/}
\defineshorthand{/S}{\Sentence\ignorespaces}
\defineshorthand{/.}{. \Sentence\ignorespaces}
\makeatletter
\preto\contract@paragraph@font{\color{white}}
\makeatother
\begin{document}
\begin{contract}
\Paragraph{}
/S Lorem Ipsum is simply dummy text of the printing and typesetting
industry/. Lorem Ipsum has been the industry's standard dummy text
ever since the 1500s, when an unknown printer took a galley of type
and scrambled it to make a type specimen book/. It has survived not
only five centuries, but also the leap into electronic typesetting,
remaining essentially unchanged/. It was popularised in the 1960s
with the release of Letraset sheets containing Lorem Ipsum passages,
and more recently with desktop publishing software like Aldus
PageMaker including versions of Lorem Ipsum.
\end{contract}
\end{document}
你看,列举的句子:
答案3
受到 Yiannis 的不太引人注目的解决方案的启发,我尝试使用行间注释。
由于缺乏行间空间,它不能很好地工作,但无论如何,这里是代码:
\documentclass{article}
\usepackage{fontspec}
\newcommand\sno[1]{\makebox[0pt]{{\setmainfont{LinotypeZapfino Two}\smash{\raisebox{-2.7pt}{\small #1}}}}}
\begin{document}
\sno{21}Lorem Ipsum is simply dummy text of the printing and typesetting industry. \sno{22}Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \sno{23}It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. \sno{24}It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
\end{document}