2

I want my equation and align environments to center with respect to nested indents, but they only seem to center with respect to the full page width. Here is some example code:

\documentclass[12pt]{amsart}
\usepackage{geometry, amsthm}
\geometry{letterpaper, margin=1in}

\begin{document}

\begin{enumerate}
    \item First level
    \begin{enumerate}
        \item Second Level
        \begin{enumerate}
            \item Third level\\
            \begin{center}
                $x<y$ % Centered inside nested items
            \end{center}
            \begin{equation*}
                x < y % Centered in whole page
            \end{equation*}
        \end{enumerate}
    \end{enumerate}
\end{enumerate}


\end{document}

This is the resulting document:

Document

Placing the equation/align inside a center doesn't work. How do I get the align and equation environments to center with respect to nested indents?

4
  • 2
    Welcome to TeX.SE! one way is to enclosed equation into minipage: \begin{minipage}{\linewidth} \begin{equation*} x < y \end{equation}\end{minipage}
    – Zarko
    Sep 2 '19 at 17:30
  • The centering of display equations on the full text width is a design decision applicable to all AMS document classes. If you are submitting a paper for publication by the AMS, you can expect a change to your requested style to be overruled. This is not to say that your preference is "bad", only that publishers do have a traditional style that they adhere to, and the document classes they provide support that style. Sep 2 '19 at 18:59
  • Thank you for the comments. I was looking for a way to make parts of an assignment look more elegant, and will take caution when not adhering to AMS standards regarding submitted papers.
    – Oreomair
    Sep 2 '19 at 20:09
  • Just add \renewcommand{\fullwidthdisplay}{} to your document preamble, see the answer to the question marked as duplicate. You should not use the proposed answers here, that have side effects.
    – egreg
    Sep 2 '19 at 22:05
1

You can redefine the equation environment so that it would automatically adjust to the current \linewidth (thanks to @Zarko's comment) using the etoolbox package.

Output

\documentclass[12pt]{amsart}
\usepackage{geometry, amsthm}
\geometry{letterpaper, margin=1in}
\usepackage{etoolbox}
\BeforeBeginEnvironment{equation*}{\begin{minipage}{\linewidth}}
\AfterEndEnvironment{equation*}{\end{minipage}}

\begin{document}
Not in an environment:
\begin{center}
  $x<y$
\end{center}
\begin{equation*}
  x < y
\end{equation*}

\begin{enumerate}
  \item First level
    \begin{center}
      $x<y$
    \end{center}
    \begin{equation*}
      x < y
    \end{equation*}
    \begin{enumerate}
    \item Second Level
      \begin{center}
        $x<y$
      \end{center}
      \begin{equation*}
        x < y
      \end{equation*}
      \begin{enumerate}
        \item Third level
        \begin{center}
          $x<y$
        \end{center}
        \begin{equation*}
            x < y
        \end{equation*}
      \end{enumerate}
    \end{enumerate}
  \end{enumerate}
\end{document}
1
  • 1
    Very nice. I need to study environments but this solution is elegant in that you only need to make one change.
    – Oreomair
    Sep 2 '19 at 18:53
1

Displayed equation(s) always consider text width, meanwhile \begin{center} ... \end{center} width of environment, where it is. Similar feature for displayed equation you can obtain with enclosing it in minipage with width of environment, where it is. This is done with using \linewidth for width of minipage.

Edit: Use of minipage for equation may lead to some unexpected problems. See edited code:

\documentclass[12pt]{amsart}
\usepackage{geometry}
\usepackage{amsmath}
\usepackage{xcolor}

\begin{document}

\begin{enumerate}
    \item First level
    \begin{enumerate}
        \item Second Level
        \begin{enumerate}
            \item Third level
            \begin{center}
                $x<y$ % Centered inside nested items
            \end{center}
            \begin{minipage}{\linewidth}\color{red}
            \begin{equation*}
                x < y % Centered in whole page
            \end{equation*}
            \end{minipage}

However, writing text immediately after equation in `minipage` and reducing width of the equation can lead to some unexpected problems, specially when equations are longer and numbered. For example:

            \begin{minipage}{\linewidth}\color{red}
            \begin{align}
    \sin(x_{\mathrm{deg}})
        & = \sin(y_{\mathrm{rad}})      \\
        & = \frac{\pi}{180} x - \Bigl(\frac{\pi}{180}\Bigr)^{3}
            \frac{x^{3}}{3!}  + \Bigl(\frac{\pi}{180}\Bigr)^{5}
            \frac{x^{5}}{5!}  - \Bigl(\frac{\pi}{180}\Bigr)^{7}
            \frac{x^{7}}{7!} + \cdots .
            \end{align}
            \end{minipage}
        \end{enumerate}
    \end{enumerate}
\end{enumerate}
\end{document}

enter image description here

(red lines indicate text area margins)

Note:

  • this solution works only, if the whole equation(s) (in any math environments provided by amsmath or similar packages) has enough space on page. This is important since minipage cannot be breaking between pages and consequently it can introduce unwanted white space in your list.
  • from image of edited example is clearly seen problems with vertical spaces around equation
  • you also need to car, that minipage always start in new line of text (as it is done im edited MWE).
2
  • Thank you, this is perfect. The context on minipage is also appreciated.
    – Oreomair
    Sep 2 '19 at 18:25
  • @AdamMair, see edited answer. This solution has some serious limitations. I would rather stick with standard way of writing of equations.
    – Zarko
    Sep 2 '19 at 18:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.