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.

2 Answers 2

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
  • This works as long as the itemize invironment isn't inside an itemize or enumerate or etc. If you change \leftmargin to \@totalleftmargin, it will work more generally. Commented Feb 21, 2011 at 21:27
  • How can you use the MLine command with a gather environment? Commented Jun 11, 2014 at 0:42
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}
5
  • For some reason, this does nothing on my end.
    – Kristen
    Commented Feb 21, 2011 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. Commented Feb 21, 2011 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.) Commented Feb 21, 2011 at 20:27
  • @Kristen Oops; I'd left an extra \displaybump in there; I just corrected the LaTeX file. Commented Feb 21, 2011 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
    Commented Feb 22, 2011 at 3:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .