Win11; TeXLive2024; VSCode.
想使用 enumitem 宏包下 \setlist 的设置来实现:列表环境各条目呈现为段落(各条目首行缩进,其余行顶格)。
目前可得如下方案能初步实现目标:
\setlist{
align=left, %标签在盒子内居左对齐
leftmargin=0pt, %条目左边距为0
itemindent=\dimexpr\parindent+\labelwidth+\labelsep\relax, %条目内缩进距离,除掉标签宽度、标签内容间距后刚好等于段落缩进距离
}但实践中发现,摘要环境以外区域的enumerate环境均能呈现上述效果,而以内区域则不行。由此内外效果不一致。
逐步剖析后基本确定根源为:值含\parindent的itemindent键在摘要环境内外的效果不一致。
引入 enumitem 宏包并设置如下:
\setlist{
itemindent=\parindent,
}编译后发现:摘要环境内的enumerate环境效果与摘要环境外的不一致。
在这里想寻求:
enumerate环境效果与摘要环境外的一致。做过的尝试:
\parindent改为固定值(以5em为例):摘要环境内外的enumerate环境效果均一致;\the\parindent来查看值是否一致:均为 15.0pt\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{abstract}
\setlength{\absleftindent}{0pt} %取消左边距
\setlength{\absrightindent}{0pt} %取消右边距
\renewcommand{\abstracttextfont}{\normalsize} %确保摘要环境内外字号一致
\usepackage{enumitem}
\setlist{
itemindent=\parindent,
}
\begin{document}
\begin{abstract}
\lipsum[2]
\begin{enumerate}
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\end{enumerate}
\end{abstract}
\lipsum[2]
\begin{enumerate}
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\end{enumerate}
\end{document}

maybe related to \quotation:
如果先暂时不看abstract宏包和
\setlength{\absleftindent}{0pt} %取消左边距
\setlength{\absrightindent}{0pt} %取消右边距
\renewcommand{\abstracttextfont}{\normalsize} %确保摘要环境内外字号一致的设置...
% line 366~408 article.cls
\if@titlepage
....
\else
\newenvironment{abstract}{%
\if@twocolumn
\section*{\abstractname}%
\else
\small
\begin{center}%
{\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
\end{center}%
\quotation
\fi}
{\if@twocolumn\else\endquotation\fi}
\fi
...
\newenvironment{quotation}
{\list{}{\listparindent 1.5em%
\itemindent \listparindent
\rightmargin \leftmargin
\parsep \z@ \@plus\p@}%
\item\relax}
{\endlist}其中在abstarct中的首行缩进名为\listparindent 1.5em.可见下例。
\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\parindent=0em
\makeatletter
\renewenvironment{abstract}{%
\if@twocolumn
\section*{\abstractname}%
\else
\small
\begin{center}%
{\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
\end{center}%
\quotation
\fi}
{\if@twocolumn\else\endquotation\fi}
\renewenvironment{quotation}
{\list{}{%
\listparindent 1.5em% %<-important here
\itemindent \listparindent
\rightmargin \leftmargin
\parsep \z@ \@plus\p@}%
\item\relax}
{\endlist}
\makeatother
\begin{document}
\lipsum[2]
\begin{abstract}
\lipsum[2]
\end{abstract}
\lipsum[2]
\end{document}
哇...根源貌似找到了:abstract环境内又嵌套了quotation环境,而quotation环境内主动将itemindent的值设为了\listparindent。
对的。
那请问怎么少改动的“使内的与外的一致”呢,从局部优先的特征来看只能重定义整个quotation环境了吗...我感觉重定义quotation也并不太好,这可能影响正文中正常使用quotation环境。
「怎么少改动的“使内的与外的一致”呢?」按我理解的需求是:
abstract内的首行间距与\parindent一致quotation环境的正常使用我感觉把\quotation复制一份使用\parindent的版本\myquotation专门用于abstarct也许会更好(?)例如这样:
\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{etoolbox}
\makeatletter
\NewCommandCopy{\myquotation}{\quotation}
\renewcommand\myquotation{%
\list{}{%\listparindent 1.5em%
\itemindent \parindent %\listparindent
\rightmargin \leftmargin
\parsep \z@ \@plus\p@}%
\item\relax
}
\patchcmd{\abstract}{\quotation}{\myquotation}{}{}
\makeatother
\parindent=0em
\begin{document}
\begin{quotation}
\lipsum[2][1-5]
\end{quotation}
\lipsum[2][1-5]
\begin{abstract}
\lipsum[2][1-5]
\begin{quotation}
\lipsum[2][1-5]
\end{quotation}
\end{abstract}
\lipsum[2]
\begin{quotation}
\lipsum[2][1-5]
\end{quotation}
\end{document}
此时对于正文段落的间距\parindent似乎是一致了,但对于enumerate似乎仍有问题...
\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{abstract}
\setlength{\absleftindent}{0pt}
\setlength{\absrightindent}{0pt}
\renewcommand{\abstracttextfont}{\normalsize}
\usepackage{etoolbox}
\makeatletter
\NewCommandCopy{\myquotation}{\quotation}
\renewcommand\myquotation{%
\list{}{%\listparindent 1.5em%
\itemindent \parindent%\listparindent
\rightmargin \leftmargin
\parsep \z@ \@plus\p@}%
\item\relax
}
\patchcmd{\abstract}{\quotation}{\myquotation}{}{}
\makeatother
\parindent=4em
\begin{document}
\lipsum[2][1-5]
\begin{abstract}
\lipsum[2][1-5]
\begin{enumerate}
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\end{enumerate}
\end{abstract}
\lipsum[2]
\begin{enumerate}
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\end{enumerate}
\end{document}
沉默...
把评论区中的测试代码搬到我们的目标「希望abstract环境」和「正文环境」保持一致,注意quotation环境中实际上就是一个\list,既然我们想要和正文一致,不妨直接(非常暴力地)把\myquotation置为空,这样似乎就不会受到:
\listparindent 1.5em%
\itemindent \listparindent
\rightmargin \leftmargin
\parsep \z@ \@plus\p@的影响了...(因为原先abstract内部就借用了quotation内部也借用了\list,所以在abstract内部用enumerate实际上是"list in list"...)
这样的话,也不需要abstract宏包调整字号了,直接从底层自定义想要的abstract环境...(嗯我也不知道好不好...)
\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
%% 不用 abstract 宏包,自力更生吧...
\usepackage{etoolbox}
\patchcmd{\abstract}{\small}{}{}{}
\patchcmd{\abstract}{\quotation}{}{}{}
\patchcmd{\endabstract}{\endquotation}{}{}{}
\newcommand\txt{This is some txt txt txt txt txt txt. }
\newcommand\mytxt{\txt\txt\txt\txt\txt\txt}
\newcommand*\printvalue[1]{\texttt{\string #1} : \the #1}
\parindent=2em % 为了适应「10.」的两位数缩进稍微调大了...
\usepackage{enumitem}
\setlist{
align=left,
leftmargin=0pt,
itemindent=\parindent,
labelindent=0pt,
labelwidth=!,
}
\begin{document}
\makeatletter
\texttt{\meaning\abstract}
\texttt{\meaning\endabstract}
\makeatother
\lipsum[2][1-5]
\begin{abstract}
\lipsum[2][1-5]
\begin{enumerate}[start=8]
\item \printvalue\leftmargin
\item \printvalue\itemindent
\item \printvalue\labelsep
\item \printvalue\labelwidth
\item \printvalue\labelindent
\item \mytxt
\end{enumerate}
\end{abstract}
\lipsum[2]
\begin{enumerate}[start=8]
\item \printvalue\leftmargin
\item \printvalue\itemindent
\item \printvalue\labelsep
\item \printvalue\labelwidth
\item \printvalue\labelindent
\item \mytxt
\end{enumerate}
\end{document}
查看 abstract 宏包的环境定义,可能和内部调用 center 环境有关
\if@titlepage \renewenvironment{abstract}{%
\titlepage \null\vfil \@beginparpenalty\@lowpenalty
\begin{center}%
\bfseries \abstractname \@endparpenalty\@M
\end{center}}%
{\par\vfil\null\endtitlepage}
\else \renewenvironment{abstract}{%
\if@twocolumn
\section*{\abstractname}%
\else \small
\begin{center}%
{\bfseries \abstractname\vspace{-.5em}\vspace{\z@}}%
\end{center}%
\quotation \fi} {\if@twocolumn\else\endquotation\fi}
\fi将 MWE 中的 abstract 环境改为 center 环境
\documentclass{article}
\usepackage{showframe}
\usepackage{lipsum}
\usepackage{abstract}
\setlength{\absleftindent}{0pt} %取消左边距
\setlength{\absrightindent}{0pt} %取消右边距
\renewcommand{\abstracttextfont}{\normalsize} %确保摘要环境内外字号一致
\usepackage{enumitem}
\setlist{
itemindent=\parindent,
}
\begin{document}
\begin{center}
\lipsum[2]
\begin{enumerate}
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\end{enumerate}
\end{center}
\lipsum[2]
\begin{enumerate}
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\item this is text. this is text. this is text. this is text. this is text. this is text. this is text. this is text.
\end{enumerate}
\end{document}

效果和以上展示的一致,初步判断就是 center 所致。
哇...根源貌似找到了:
abstract环境内又嵌套了quotation环境,而quotation环境内主动将itemindent的值设为了\listparindent。把外部设置改为:
摘要环境外的列表效果就与摘要环境内的一致了。
那请问怎么少改动的“使内的与外的一致”呢,从局部优先的特征来看只能重定义整个
quotation环境了吗...以及
我不是很看得明白hhhh,但我学习了这篇文章,按我理解的「列表环境各条目呈现为段落」
@u70550 谢谢E老师的分析~这两天有事一直没跟进这问题。
首先敲定两个结论,在标准文档类中:
abstract环境的额外缩进、列表额外首行缩进,都是由quotation环境引起;abstract环境内的字号由\small命令引起。而因为

abstract宏包会对abstract环境重定义:于是在导入
abstract包的情况下对\small,\quotation进行patch会失败(\small改由\abstractnamefont控制、quotation环境替换成了@bstr@ctlist)。因此可以在不用
abstract包的情况下patch:意思是列表环境的各个条目(包括标签在内)保持与正文段落一致的缩进设置。我也是看了
enumitem包的手册尝试出来的,具体啥原理不太记得了...anyway,abstract环境内缩进距离的问题捣弄出来了就好 ^_^@u64726 哈哈😄不知为何,我没看到那个at的消息...
在LaTeX宏包开发入门.pdf的1.2节提到:
理论上是的。我看的官方英文资料比较少,按道理「LaTeX Companion」肯定有...
这些
\expandafter就不耗费脑细胞分析了...但都定义了\csname #1\endcsname和\csname end#1\endcsname.@u70550 感谢E老师的解惑(抱拳)