1

I have the following code:

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{eqnarray*}
\Rightarrow & x^2 > 4  \ \land & x\ge 0 
\end{eqnarray*}
\end{document}

What I want to do, is to set a column separator in the eqnarray above. But if I put one before \land or try to make an extra column in the middle, LaTeX gives me an error with a description like ! Missing $ inserted.

Hm, why? Thank you!

UPD. for Emma:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amsthm}
\begin{document}
\begin{proof}
$\subseteq$: Sei $x \in M $.
\begin{align*}
\Rightarrow & x^2 > 4 &\text{\ und\ }&x \ge 0 \\
\Rightarrow &\underbrace{x^2 - 4}_{(x-2)(x+2)} > 0 & \text{\ und\ } & x \ge 0 \\
\Rightarrow & x>2 & & \\
\Rightarrow & x \in N & &  
\end{align*}
\end{proof}
\end{document}

1 Answers1

4

General consensus says eqnarray is obsolete, and that you should use the amsmath environments align, gather, etc. instead.

The ! Missing $ inserted arises because eqnarray only expects three columns (LHS, operator, RHS) and so it tries to typeset the \ge in the nonexistent "fourth" column in text mode.

Since you're already using amsmath, you just need to replace eqnarray with align and your code will work.

If you want less space between the columns, maybe you really want to use the alignat environment instead, which puts no space except what you explicitly insert. For example,

\documentclass{article}
\usepackage{amsmath,mathtools}
\usepackage{amsthm}
\begin{document}
\begin{proof}
$\subseteq$: Sei $x \in M $.
\begin{alignat*}{3} % Argument is number of <r&l> columns
  \Rightarrow&\quad  &  &x^2 > 4     &      \text{und\ }&x \ge 0 \\
  \Rightarrow&       &  &\!\underbrace{x^2 - 4}_{\mathclap{(x-2)(x+2)}} > 0
                                     & \quad\text{und\ }&x \ge 0 \\
  \Rightarrow&       &  &x>2         &                  & \\
  \Rightarrow&       &  &x \in N     &                  &
\end{alignat*}
\end{proof}
\end{document}

Like align, the columns alternate between right and left aligned (which I've tried to help keep track of by adding spaces in the code). I've also included mathtools for the command \mathclap which makes the description under the brace not take up horizontal space so that the equation aligns better (the brace itself takes up some space too, which I've eaten with a \!).

Emma
  • 3,453
  • 12
  • 20
  • Yes, it works... But no, it does not look nice, because there is a "hole" in the middle. If you put \Rightarrow & x^2 > 4 \ & \land & x\ge 0 in the starred align environment, you will mention that there is no space between the arrow and the quad, than there comes a hole and the same with the logical and and the rest of the sentence. It could be great, if the thing looked like an obsolete Mr. eqnarray, but with 4 columns :) Thank you! – jupiter_jazz Oct 19 '16 at 02:39
  • It sounds to me like you are just using the &s here for the space they put in (which is generally considered a disadvantage of eqnarray), rather than to provide consistent horizontal alignment across multiple lines (which is the main intent of these environments). If you replace each & with \quad, does that give you what you want? – Emma Oct 19 '16 at 03:05
  • not really. This was a minimal exmaple only. I've updated the question for you, see below. I want every arrow, every expression before and after "und" as much as the "und" itself to be one under another. That is why tabular were ok, but than some \newcolumntype for math style are needed, as I use only math. there. tabularx is the same. eqnarray works only for 3 columns, as you said. align puts spaces spontaniously. \quads are not ok, because they do not give me control over the whole proof. Thank you. – jupiter_jazz Oct 19 '16 at 03:42
  • Okay, I've added a new solution using alignat instead of align. Does this help? – Emma Oct 19 '16 at 04:20
  • Surely that helps! We still have problems with the proof symbol, but that is not the matter of the question. Thank you for your examples! Least but not last, tell me please where the \!command refers to? Is this a LaTeX or LaTeX package command, what it does? – jupiter_jazz Oct 23 '16 at 06:31
  • The \! is just a small negative space to cancel out the extra width added by the brace. (The \mathclap makes the layout ignore the width of the text under the brace, but the brace itself seems to add a little width as well.) – Emma Oct 23 '16 at 16:58
  • Thank you, Emma! I've found these two in my new "LaTeX Companion", too. Thanks again! – jupiter_jazz Oct 24 '16 at 23:14