2

I am trying to align some inequalities, but for some reason they are shifted to the right of the page. Here is what I have:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\begin{equation*}
\begin{align*}
    \vert x-a \vert &< \varepsilon = \delta \\
    \frac{\vert (1+x)-(1+a)\vert}{1} &< \varepsilon \\
    \frac{\vert (1+x)-(1+a)\vert}{\sqrt{1+x} + \sqrt{1+a}} &< \varepsilon \\
    \frac{\vert (\sqrt{1+x}+\sqrt{1+a})(\sqrt{1+x}-\sqrt{1+a})\vert}{\sqrt{1+x} + \sqrt{1+a}} &< \varepsilon \\
    \vert \sqrt{1+x} - \sqrt{1+a} &< \varepsilon
\end{align*}
\end{equation*}

I am pretty new to Latex, so any help would be much appreciated.

Here is a screenshot of the output: enter image description here

P.s. How can I get the "output" of the code to display on this post? I feel like it would make the issue a lot more clear.

Thanks!

NNN
  • 230
  • Why not use the align*environment? You cannot nest align in equation. For that, use aligned or split. You can post a screenshot of the result with an icon in the tool bar at the top of the edit window. – Bernard Nov 02 '16 at 01:50
  • @Bernard Would using the 'align' environment mean simply removing the '\begin{equation}' and '\end{equation*} lines? If so that does not change anything. – NNN Nov 02 '16 at 01:56
  • regarding your question of how to get your output to display here, this question has some good advice: Compile a LaTeX document into a PNG image that's as short as possible. after you've done that, click on the icon to the right of the {}, above the question box; this brings up a window that allows you to post a .png file. – barbara beeton Nov 02 '16 at 12:09

3 Answers3

3

There's an error message when nested. Your shifted environment is only a visual effect due to the dissymmetry between the l.h.s. and the r.h.s. Look at the result with the showframe option of geometry, to visualise the margins. B.t.w. I replaced the pairs \vert … \vert with pairs \lvert … \rvert, which will have a better horizontal spacing:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage[showframe]{geometry}

\begin{document}

\begin{align*}
    \vert x-a \vert &< \varepsilon = \delta \\
    \frac{\lvert (1+x)-(1+a)\rvert}{1} &< \varepsilon \\
    \frac{\lvert (1+x)-(1+a)\rvert}{\sqrt{1+x} + \sqrt{1+a}} &< \varepsilon \\
    \frac{\lvert (\sqrt{1+x}+\sqrt{1+a})(\sqrt{1+x}-\sqrt{1+a})\rvert}{\sqrt{1+x} + \sqrt{1+a}} &< \varepsilon \\
    \lvert \sqrt{1+x} - \sqrt{1+a} \rvert&< \varepsilon
\end{align*}

\end{document} 

enter image description here

Bernard
  • 271,350
1

You cannot nest align* into equation*: it doesn't make sense, because align is by itself a display making environment. If you think to it, the unstarred variant align numbers each line; so it should be

\begin{align*}
A &< B \\
...
\end{align*}

without any equation* around it.

You might do

\begin{equation*}
\begin{aligned}
A &< B \\
...
\end{aligned}
\end{equation*}

and the result would be the same except perhaps for the spacing around the display and for the fact that the former can be split across pages (with \displaybreak before the relevant \\ command) and the latter can't.

However, such a display will look awful anyway, because the centering will be with respect to the width of the longest left-hand side plus the longest right-hand side, so the alignment point will appear too much on the right.

Such unbalanced lines should be treated, in my opinion, with gather and some more generous interline space.

\documentclass{article}
\usepackage{amsmath}

\usepackage{showframe} % just for the example

\begin{document}

\begin{gather*}
\lvert x-a \rvert < \delta = \varepsilon \\[1ex]
\frac{\lvert (1+x)-(1+a)\rvert}{1} < \varepsilon \\[1ex]
\frac{\lvert (1+x)-(1+a)\rvert}{\sqrt{1+x} + \sqrt{1+a}} < \varepsilon \\[1ex]
\frac{\lvert (\sqrt{1+x}+\sqrt{1+a})(\sqrt{1+x}-\sqrt{1+a})\rvert}
     {\sqrt{1+x} + \sqrt{1+a}} < \varepsilon \\[1ex]
    \lvert \sqrt{1+x} - \sqrt{1+a}\rvert < \varepsilon
\end{gather*}

\end{document}

enter image description here

A possible improvement is remembering that when a square root vinculum happens to fall near a closing parenthesis, a thin space is needed; so the fourth display line should be

\frac{\lvert (\sqrt{1+x}+\sqrt{1+a}\,)(\sqrt{1+x}-\sqrt{1+a}\,)\rvert}
     {\sqrt{1+x} + \sqrt{1+a}} < \varepsilon \\[1ex]

The difference is small, but noticeable by absence.

enter image description here

egreg
  • 1,121,712
-1
    \begin{document}

  \begin{align*}
   \vert x-a \vert &< \varepsilon = \delta \\
    \frac{\lvert (1+x)-(1+a)\rvert}{1} &< \varepsilon \\
   \frac{\lvert (1+x)-(1+a)\rvert}{\sqrt{1+x} + \sqrt{1+a}} &<       
    \varepsilon \\
    \frac{\lvert (\sqrt{1+x}+\sqrt{1+a})(\sqrt{1+x}-\sqrt{1+a})\rvert}    
    {\sqrt{1+x} + \sqrt{1+a}} &< \varepsilon \\
    \lvert \sqrt{1+x} - \sqrt{1+a} \rvert&< \varepsilon
   \end{align*}


      \huge
     \begin{tabular}{rl}
     $ x-a$  &$< \varepsilon = \delta$ \\
     &\\
    $\frac{| (1+x)-(1+a)|}{1}$ &$< \varepsilon$ \\
    &\\
   $\frac{| (1+x)-(1+a)|}{\sqrt{1+x} + \sqrt{1+a}}$ &$< \varepsilon $\\
  &\\
   $\frac{| (\sqrt{1+x}+\sqrt{1+a})(\sqrt{1+x}-\sqrt{1+a})|}   
   {\sqrt{1+x}     +     \sqrt{1+a}}$ &$< \varepsilon $\\
   &\\
    $ \sqrt{1+x} - \sqrt{1+a} $& $< \varepsilon$\\
  \end{tabular}

% second uses normal latex commands. I am unable to paste the out put but you can check it yourself.

vaman
  • 81