18

When using math (display) mode in conjunction with a list environment, the displayed material is not truly centered on the page; it is only centered with respect to the indentation of the item. Consider the following example:

\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}

How can I get the displayed math to be centered horizontally with respect to the margins of the page??

Of course, this question is not specific to centering a displayed equation. The same question is valid for the use of \begin{center} text \end{center} inside a list environment.

Caramdir
  • 89,023
  • 26
  • 255
  • 291
Kristen
  • 5,003

2 Answers2

8
\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}

enter image description here

2

A crude solution is to put

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

into your preamble and then follow the content of each display with \displaybump, as in

\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}

Here's a complete LaTeX file showing (at least for me) that it works:

\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}
  • For some reason, this does nothing on my end. – Kristen Feb 21 '11 at 13:14
  • @Kristen Weird; I just tested it again, using copy and paste, and it works for me. I added only \documentclass{article}. \begin{document}, and \end{document}. Are you sure it's not working? The difference in centering is very small; if you put your itemize inside of another itemize the difference is larger and slightly more visible. – Phil Hirschhorn Feb 21 '11 at 18:02
  • @Kristen I edited my answer (above) to include a complete LaTeX file, which shows (at least to me) that it works. (It's still a crude solution, though.) – Phil Hirschhorn Feb 21 '11 at 20:27
  • @Kristen Oops; I'd left an extra \displaybump in there; I just corrected the LaTeX file. – Phil Hirschhorn Feb 21 '11 at 21:39
  • Yeah, I'm sure it doesn't work. I know the difference is very small, but the width of the object I want to display is so large that I can see a significant difference in white space on the left and right sides. – Kristen Feb 22 '11 at 03:28