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}
























问 enumitem 宏包 itemindent=\parindent 的设置在abstract环境内、外的效果不同?