3

What is wrong with this column of two equations?

\begin{equation}
    \begin{align}
        u(x,t) &= \frac{\partial\phi}{\partial x}\\
        \mathbf{u}(\mathbf{r}, t) &= \left(\begin{array}
            \partial_y\phi(\mathbf{r},t)\\
            -\partial_x\phi(\mathbf{r},t)
        \end{array}\right).
    \end{align}
\end{equation}

Output

It drops \partial and output the error message "Package amsmath Error: Erroneous nesting of equation structures; LaTeX error: Illegal character in array arg."

Other ways to get the right output would also be welcome.

3
  • 1
    You're missing the required argument of the array environment. You should write \begin{array}{c}, not just \begin{array}. LaTeX is looking for the argument; the first thing it encounters is \partial, which gets gobbled, i.e., is not going to be typeset. And, because \partial is (unsurprisingly) not a valid column type for array, you get an error message about an illegal character...
    – Mico
    Dec 6, 2016 at 11:08
  • 1
    A separate issue is that you mustn't encase an align enviroment inside an equation environment. You should either remove \begin{equation} and \end{equation} or replace align with split.
    – Mico
    Dec 6, 2016 at 11:12
  • 3
    I'm voting to close this question as off-topic because is was answered in the comments Dec 6, 2016 at 11:17

2 Answers 2

4

Some suggestions and observations:

  • The array environment takes a mandatory argument -- the column type(s) to be used. You haven't provided this argument, and LaTeX is therefore forced to (mis)interpret the next character it can find -- the \partial symbol -- as the argument of array, with disastrous consequences,

    I would actually like to suggest that you use a pmatrix environment instead of an array environment. That way, you can leave off the \left( and \right) directives, and the material is better, i.e., more tightly spaced too.

  • You mustn't encase an align environment inside an equation environment. I suggest you replace align with split.

  • Use a \phantom{-} directive in the first row of the column vector to get the correct (vertical) alignment.

enter image description here

\documentclass{article}
\usepackage{amsmath} % for "split" and "pmatrix" environments
\begin{document}
\begin{equation}
    \begin{split}
        u(x,t) &= \frac{\partial\phi}{\partial x}\\
        \mathbf{u}(\mathbf{r}, t) &= 
        \begin{pmatrix}
            \phantom{-}\partial_y\phi(\mathbf{r},t)\\
                      -\partial_x\phi(\mathbf{r},t)
        \end{pmatrix}
    \end{split}
\end{equation}
\end{document}
3
  • 1
    with pmatrix*[r], you don't need \phantom-}.
    – Bernard
    Dec 6, 2016 at 11:41
  • @Bernard -- I guess you'd save 11 keystrokes ("\phantom{-}" but add 8 more (two times "*[r]"), for a net saving of 3 keystrokes. I suppose one would begin to save more keystrokes if there were more \phantom` statements... :-)
    – Mico
    Dec 6, 2016 at 12:27
  • I don't mean quibbling, but it would be only 5 keystrokes :o)
    – Bernard
    Dec 6, 2016 at 12:40
3

The array environment expects a column-specifier (i.e. l,c,r) which gives the alignment of the columns. That is the second error LaTeX error: Illegal character in array arg. The first comes from the align environment being inside the equation environment, these both start display math and are incompatible, you can use either a single align environment or the aligned environment inside the equation environment.

\documentclass{article}
\usepackage{amsmath}

\begin{document}
    \begin{align}
        u(x,t) &= \frac{\partial\phi}{\partial x}\\
        \mathbf{u}(\mathbf{r}, t) &= \left(\begin{array}{r}
            \partial_y\phi(\mathbf{r},t)\\
            -\partial_x\phi(\mathbf{r},t)
        \end{array}\right).
    \end{align}
\hrule
\begin{equation}
    \begin{aligned}
        u(x,t) &= \frac{\partial\phi}{\partial x}\\
        \mathbf{u}(\mathbf{r}, t) &= \left(\begin{array}{r}
            \partial_y\phi(\mathbf{r},t)\\
            -\partial_x\phi(\mathbf{r},t)
        \end{array}\right).
    \end{aligned}
\end{equation}
\end{document}

enter image description here

3
  • 3
    Using the pmatrix*[r] environment would avoid having to set the \left( … \right) pair.
    – Bernard
    Dec 6, 2016 at 11:18
  • 1
    @Bernard using pmatrix does indeed make more sense, I probably should have paid more attention to what the OP actually wanted to be typeset! Mico's answer covers use of the pmatrix environment so I think I'll leave my answer as is.
    – Dai Bowen
    Dec 6, 2016 at 11:37
  • 1
    array is good, but it should be \begin{array}{@{} r @{}} in order to suppress the padding. Actually, I'd simply use \begin{pmatrix} without forcing right alignment.
    – egreg
    Dec 6, 2016 at 11:45

You must log in to answer this question.

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