![在段落第一个单词之前立即打印,而不改变其首行缩进?](https://linux22.com/image/299898/%E5%9C%A8%E6%AE%B5%E8%90%BD%E7%AC%AC%E4%B8%80%E4%B8%AA%E5%8D%95%E8%AF%8D%E4%B9%8B%E5%89%8D%E7%AB%8B%E5%8D%B3%E6%89%93%E5%8D%B0%EF%BC%8C%E8%80%8C%E4%B8%8D%E6%94%B9%E5%8F%98%E5%85%B6%E9%A6%96%E8%A1%8C%E7%BC%A9%E8%BF%9B%EF%BC%9F.png)
虽然我的情况可以概括,但如果我描述一个具体的例子也许会更清楚。
我需要将数字作为下标打印在每个段落第一行的左边,但不影响其第一行缩进。
数字与首字母之间的间距必须与脚注数字的默认间距相同。
我一直在尝试定义一个新命令,但无法保持以下文本不变。
以下 MWE 说明了我的意思:
\documentclass[12pt]{book}
\usepackage{fixltx2e}
\newcommand\parnumber[1]{\hspace{-5pt}{\footnotesize}\textsubscript{#1}\kern -2pt\normalsize}
\begin{document}
I should like, before proceeding further, to tell you how I feel...
\parnumber{1} I should like, before proceeding further, to tell you how I feel about the State which we have described. I might compare myself to a person who, on beholding beautiful animals either created by the painter's art, or, better still, alive but at rest, is seized with a desire of seeing them in motion or engaged in some struggle or conflict to which their forms appear suited; this is my feeling about the State which we have been describing.
\parnumber{2} And we too, Socrates, as Timaeus says, will not be wanting in enthusiasm; and there is no excuse for not complying with your request.
\end{document}
第一行显示了段落应如何缩进。第二行显示了\parnumber
命令如何影响其缩进。
我知道命令定义充其量只是原始的。
如何才能将其改进为在段落第一个单词之前立即打印数字,而不改变其首行缩进?
我想过使用浮动框,但我无法让它精确地工作。
答案1
在这里,在我的 MWE 中,我使用了\llap
,但另一种形式将\makebox[0pt][r]{...}
包括\leavevmode\llap{...}
这是经过编辑的 MWE,以将这些更改合并到\parnumber
宏本身中。这\ignorespaces
允许您在调用后放置空格或不放置空格\parnumber{1}
,而不会产生任何不良影响。
\documentclass[12pt]{book}
\usepackage{fixltx2e}
\newcommand\parnumber[1]{\leavevmode\llap{%
\footnotesize\textsubscript{#1}\,}\ignorespaces}
\begin{document}
I should like, before proceeding further, to tell you how I feel...
\parnumber{1}I should like, before proceeding further, to tell you how I feel about the State which we have described. I might compare myself to a person who, on beholding beautiful animals either created by the painter's art, or, better still, alive but at rest, is seized with a desire of seeing them in motion or engaged in some struggle or conflict to which their forms appear suited; this is my feeling about the State which we have been describing.
\parnumber{2} And we too, Socrates, as Timaeus says, will not be wanting in enthusiasm; and there is no excuse for not complying with your request.
\end{document}