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,但我学习了这篇文章,按我理解的「列表环境各条目呈现为段落」