枚举中第一个项之前的令人讨厌的空格会启动类似定理的环境

枚举中第一个项之前的令人讨厌的空格会启动类似定理的环境

在以(括号内的)枚举开头的定理类环境中,水平的项目前的额外空间被消除,但:

  • 没有破坏项目主体的正确缩进,包括项目中第一行之后的行;

  • 没有要求第一项正文之前有一个空行;

  • 没有过度缩小第一个项目的标签与其正文之间的空间?

在以下源的输出中,第一个红色箭头标记了多余的不需要的水平空间出现的位置。

正如我们在“1.3 示例”中看到的,试图消除第一个项目的额外水平空间会破坏第一个项目的统一水平缩进。在“1.4 示例”中,第一个项目的正文在其标签后开始一个单独的段落。在“1.5 示例”中,通过消除源代码中的空白行可以避免后一个问题,但第一个项目的标签和正文之间的空间太小。

\documentclass{article}
\usepackage[left=1.2in,right=1.2in,top=1in,bottom=1in]{geometry}

\newcommand{\sometxt}{%
Some text begins this. The identity is $\sin^2(\theta) + \cos^2(\theta) = 1$ %
and in very simple terms $(a + b)^2 \neq a^2 + b^2$.%
On the other hand, we do have the basic law of powers that $(a b)^2 = a^2 b^{2}$.
}

\usepackage{enumitem}
\usepackage{mathtools,amsthm,thmtools}

\newlist{pexenum}{enumerate}{1}
\setlist[pexenum,1]{label= \upshape(\arabic*)}

\swapnumbers

\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\declaretheoremstyle[
  headfont= \bfseries, headpunct={\bfseries.},
  postheadspace=0.5em,
  spaceabove=12pt,spacebelow=12pt
]{exstyle}

\declaretheorem[
  style=exstyle, numberlike=theorem,
  ]
{examples}

\begin{document}

\section{The  section}

\noindent This is OK with text within the environment precedes the enumeration:

\begin{examples}
  Text before the enumeration.
    \begin{pexenum}
      \item 
      
      \sometxt      
      \setcounter{pexenumi}{9}
      \item \sometxt
   \end{pexenum}
\end{examples}

\noindent \textbf{The problem}, when \emph{no} text precedes enumeration---too much horizontal space before 1st label:
\begin{examples}
    \begin{pexenum}
      \item 
      
      \sometxt
      \setcounter{pexenumi}{9}
      \item \sometxt
   \end{pexenum}
\end{examples}

\noindent  Attempted fix---\verb!leftmargin=*! etc.. \emph{Wrong}---entire 1st item exdented:

% From https://tex.stackexchange.com/a/17487/13492:
\begin{examples}
    \begin{pexenum}[leftmargin=*]
      \item 
      
      \sometxt
    \end{pexenum}\vspace*{-2\partopsep}
    \begin{pexenum}[resume]
    \setcounter{pexenumi}{9}
      \item \sometxt
   \end{pexenum}
\end{examples}

\noindent  Attempted fix---use \verb!\fixitem!.. \emph{Wrong}---1st item body begins new paragraph after item label:

% From https://tex.stackexchange.com/a/17500/13492:
\newcommand*\fixitem{\item[]%
  \refstepcounter{pexenumi}\hskip-\leftmargin\labelpexenumi\hskip0.5\labelsep}
  
\begin{examples}
    \begin{pexenum}
      \fixitem % The blank line before the item's text is deliberate!
      
      \sometxt
      \item \sometxt
    \setcounter{pexenumi}{9}
      \item \sometxt
   \end{pexenum}
\end{examples}

\noindent  Attempted fix---use \verb!\fixitem!.---no blank line. This works, but \emph{awkward} having to avoid the blank line:
  
\begin{examples}
    \begin{pexenum}
      \fixitem 
%      
      \sometxt
      \item \sometxt
    \setcounter{pexenumi}{9}
      \item \sometxt
   \end{pexenum}
\end{examples}

\end{document}

类定理环境中枚举中第一项标签后的间距

编辑:@label所示方法https://tex.stackexchange.com/a/17465/13492似乎有效!

有关的:

这个问题类似于枚举中第一个项之前的令人讨厌的空格,它启动了一个定理,但现在:

  • 枚举是用括号中的数字完成的(这可能会影响间距);并且
  • 每个项目都有多行,而在原始问题中,每个项目只有一行,这掩盖了所提供的答案中的缺陷。

源代码只显示了一种方法,试图删除第一个项目之前不需要的水平空间,但在以下问题的答案中给出了其他方法枚举中第一个项之前的令人讨厌的空格,它启动了一个定理遭受同样的缺点。

另请参阅我的“非答案”https://tex.stackexchange.com/a/586852/13492

答案1

这是你想要的吗?

\documentclass{article}

\newcommand{\sometxt}{%
Some text begins this. The identity is $\sin^2(\theta) + \cos^2(\theta) = 1$ %
and in very simple terms $(a + b)^2 \neq a^2 + b^2$.%
On the other hand, we do have the basic law of powers that $(a b)^2 = a^2 b^{2}$.
}

\usepackage{enumitem}
\usepackage{mathtools,amsthm,thmtools}

\newlist{pexenum}{enumerate}{1}
\setlist[pexenum,1]{label= \upshape(\arabic*), wide=0pt, leftmargin=*}

\swapnumbers

\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\declaretheoremstyle[
  headfont= \bfseries, headpunct={\bfseries.},
  postheadspace=0.5em,
  spaceabove=12pt,spacebelow=12pt
]{exstyle}

\declaretheorem[
  style=exstyle, numberlike=theorem,
  ]
{examples}

\begin{document}

\section{The section}

\begin{examples}
  Text before the enumeration.
    \begin{pexenum}
      \item \sometxt
      \item \sometxt
   \end{pexenum}
\end{examples}

\begin{examples}
    \begin{pexenum}
      \item \sometxt
      \item \sometxt
   \end{pexenum}
\end{examples}

\begin{examples}
    \begin{pexenum}[leftmargin=*]
      \item \sometxt
    \end{pexenum}\vspace*{-2\partopsep}
    \begin{pexenum}[resume]
      \item \sometxt
   \end{pexenum}
\end{examples}

\end{document} 

在此处输入图片描述

编辑:如果您更喜欢列表中的右对齐标签,则可以使用以下widest命令:

\documentclass{article}
\newcommand{\sometxt}{%
Some text begins this. The identity is $\sin²(θ) + \cos²(θ) = 1$ %
and in very simple terms $(a + b)² ≠ a² + b²$.%
On the other hand, we do have the basic law of powers that $(a b)² = a² b^{2}$.
}

\usepackage{enumitem}
\usepackage{mathtools,amsthm,thmtools}

\newlist{pexenum}{enumerate}{1}
\setlist[pexenum,1]{label= \upshape(\arabic*), widest=99, leftmargin=*}

\swapnumbers

\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\declaretheoremstyle[
  headfont= \bfseries, headpunct={\bfseries.},
  postheadspace=0.5em,
  spaceabove=12pt,spacebelow=12pt
]{exstyle}

\declaretheorem[
  style=exstyle, numberlike=theorem,
  ]
{examples}

\begin{document}

\section{The section}

\begin{examples}
  Text before the enumeration.
    \begin{pexenum}[start=9]
      \item \sometxt
      \item \sometxt
   \end{pexenum}
\end{examples}

\begin{examples}
    \begin{pexenum}
      \item \sometxt
      \item \sometxt
   \end{pexenum}
\end{examples}

\begin{examples}
    \begin{pexenum}[leftmargin=*]
      \item \sometxt
    \end{pexenum}\vspace*{-2\partopsep}
    \begin{pexenum}[resume]
      \item \sometxt
   \end{pexenum}
\end{examples}

\end{document} 

在此处输入图片描述

编辑:我稍微修改了一下代码:

   \begin{examples}
        \begin{pexenum}
          \item[(1)\phantom{0}\kern0.05em\stepcounter{pexenumi}]\hskip-0.55em\sometxt
          \item \sometxt
       \end{pexenum}
    \end{example}

输入图片

答案2

你可以将first钥匙与以下技巧一起使用这个帖子

\documentclass{article}

\newcommand{\sometxt}{%
Some text begins this. The identity is $\sin^2(\theta) + \cos^2(\theta) = 1$ %
and in very simple terms $(a + b)^2 \neq a^2 + b^2$.%
On the other hand, we do have the basic law of powers that $(a b)^2 = a^2 b^{2}$.
}

\usepackage{enumitem}
\usepackage{mathtools,amsthm,thmtools}

\newlist{pexenum}{enumerate}{1}
\setlist[pexenum,1]{label= \upshape(\arabic*)}

\swapnumbers

\declaretheorem[name=Theorem,numberwithin=section]{theorem}

\declaretheoremstyle[
  headfont= \bfseries, headpunct={\bfseries.},
  postheadspace=0.5em,
  spaceabove=12pt,spacebelow=12pt
]{exstyle}

\declaretheorem[
  style=exstyle, numberlike=theorem,
  ]
{examples}

\newcommand*\myfirstitem{\item[]% based on https://tex.stackexchange.com/a/17500
  \refstepcounter{pexenumi}\hskip-\leftmargin\labelpexenumi\hskip0.5\labelsep
  \let\olditem\item
  \def\item{\let\item\olditem}%
  }


\begin{document}

\section{The  section}

\begin{examples}
  Text before the enumeration.
    \begin{pexenum}
      \item \sometxt
      \item \sometxt
   \end{pexenum}
\end{examples}

\begin{examples}
    \begin{pexenum}[first=\myfirstitem]
      \item \sometxt
      \item \sometxt
   \end{pexenum}
\end{examples}

\begin{examples}
    \begin{pexenum}[leftmargin=*]
      \item \sometxt
    \end{pexenum}\vspace*{-2\partopsep}
    \begin{pexenum}[resume]
      \item \sometxt
   \end{pexenum}
\end{examples}

\end{document}

在此处输入图片描述

相关内容