使用 enumitem 在内联列表中显示方程式

使用 enumitem 在内联列表中显示方程式

我正在尝试在 LaTeX 中创建内联列表,并且使用该enumitem包效果非常好。

但是如果我想放置一个显示方程式(这对于内联列表来说并不常见......但有时我需要)就会产生错误。

一位 MWE 表示:

\documentclass{article}


\usepackage[inline]{enumitem}                

\newlist{enumerateIL}{enumerate*}{1}%         
% Inline enumeration environment

\setlist[enumerateIL,1]{font=\itshape\bfseries,label={\arabic*.}} 
% Format itemize \item's  


\begin{document}

An in-line list:
\begin{enumerateIL}
   \item
   The first point:
   $a + b = c$.

   \item
   The second point
   \[a^2 + b^2 = c^2.\]

\end{enumerateIL}

\end{document}

我收到此编译错误

:
! Missing $ inserted.
<inserted text> 
                $
l.21    \[a^
            2 + b^2 = c^2.\]

根据错误消息所暗示的,在线方程式可以正常工作......但不能显示方程式。

有没有办法让它工作enumitem?如果没有,还有其他选择吗?

谢谢。

页。

答案1

根据@JavierBezos 的评论回答,将模式更改为unboxed

\documentclass{article}
\usepackage[inline]{enumitem}

\begin{document}
text before inline itemize environment
\begin{enumerate*}[mode=unboxed]
  \item this is an inline itemize environment with math environment
    \begin{equation}
      E= mc^2
   \end{equation}
\end{enumerate*}
\end{document}

答案2

在这里,我使用带有额外空格的手动换行符\\[5pt]来设置等式,并使用$\displaystyle...$在全宽文本框中设置等式。

\documentclass{article}


\usepackage[inline]{enumitem}                

\newlist{enumerateIL}{enumerate*}{1}%         
% Inline enumeration environment

\setlist[enumerateIL,1]{font=\itshape\bfseries,label={\arabic*.}} 
% Format itemize \item's  

\begin{document}

An in-line list:
\begin{enumerateIL}
   \item
   The first point:
   $a + b = c$.

   \item
   The second point\\[5pt]   
   \makebox[\linewidth]{$\displaystyle \frac{x}{a^2} + b^2 = c^2.$}\\[5pt]
   More stuff
   \item
   More stuff More stuff More stuff More stuff More stuff More stuff
   More stuff More stuff More stuff More stuff More stuff More stuff
   More stuff More stuff More stuff More stuff

\end{enumerateIL}

\end{document}

在此处输入图片描述

这可以通过添加以下前言来自动实现:

\usepackage{environ}
\NewEnviron{enumILeqn}{\\[5pt]\makebox[\linewidth]{$\displaystyle\BODY$}\\[5pt]}

和用法

The second point

\begin{enumILeqn}  
\frac{x}{a^2} + b^2 = c^2
\end{enumILeqn}

More stuff

答案3

我目前正在解决这个问题,$\displaystyle...$但当然,这会使数学保持内联,并且不会生成我希望的居中显示方程式。有时我希望使用相当复杂的方程式,但有时这还$\displaystyle...不够好。

相关内容