如何在列表环境中将文本/数学置于中心位置?

如何在列表环境中将文本/数学置于中心位置?

当将数学(显示)模式与列表环境结合使用时,显示的内容并非真正居中在页面上;它仅相对于项目的缩进居中。请考虑以下示例:

\begin{itemize}
\item The quadratic formula
\[
x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
\]
\item The freshman's dream
\[
(a+b)^n=a^n+b^n
\]
\end{itemize}

如何让显示的数学值相对于边缘水平居中??

\begin{center} text \end{center}当然,这个问题并不局限于显示方程式的中心化。在列表环境中使用时也存在同样的问题。

答案1

\documentclass{article}
\usepackage{amsmath,bm}
\def\MLine#1{\par\hspace*{-\leftmargin}\parbox{\textwidth}{\[#1\]}}
\begin{document}

\noindent\rule{\textwidth}{2pt}

\begin{itemize}
\item The quadratic formula 
      \MLine{x=\dfrac{-b\pm\sqrt{b^2-4ac}}{2a}}
\item The freshman's dream 
      \MLine{(a+b)^n=a^n+b^n}
\end{itemize}

\[(a+b)^n=a^n+b^n\]

\end{document}

在此处输入图片描述

答案2

一个粗暴的解决方案是

\makeatletter
\newcommand{\displaybump}{\hbox to \@totalleftmargin{\hfil}}
\makeatother

\displaybump放入你的序言中,然后在每个显示内容后面加上

\begin{itemize}
\item The quadratic formula
  \[
  x=\frac{-b\pm\sqrt{b^2-4ac}}{2a} \displaybump
  \]
\item The freshman's dream
  \[
  (a+b)^n=a^n+b^n \displaybump
  \]
\end{itemize}

这是一个完整的 LaTeX 文件,显示(至少对我而言)它可以正常工作:

\documentclass{article}


\makeatletter
  \newcommand{\displaybump}{\hbox to \@totalleftmargin{\hfil}}
\makeatother

\begin{document}

Just for reference: The following is not inside an \texttt{itemize}:
\[
  x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
\]

Just for reference: The following is not inside an \texttt{itemize}:
\[
  (a+b)^n=a^n+b^n
\]

\begin{itemize}
\item This item is so that the following \texttt{itemize} environment
  will have a larger total indentation.
  \begin{itemize}
  \item The quadratic formula:
    \[
    x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}
    \]
  \item The quadratic formula, using \verb"\displaybump":
    \[
    x=\frac{-b\pm\sqrt{b^2-4ac}}{2a} \displaybump
    \]
  \item The freshman's dream:
    \[
    (a+b)^n=a^n+b^n
    \]
  \item The freshman's dream, using \verb"\displaybump":
    \[
    (a+b)^n=a^n+b^n \displaybump
    \]
  \end{itemize}
\end{itemize}


\end{document}

相关内容