3

I have this code:

\begin{alignat*}
    && u=\tan^{-1}{x} &&v=x\\
    && du=\frac{1}{1+x^2} &&dv=1
\end{alignat*}

And I am trying to align the u with du and v with dv. I get errors and the overleaf produces this: What am I doing wrong?

Edit: I have the following errors: Line 21: missing number, treated as zero Line 23: amsmath error: extra & on this line Line 23: Misplaced \omit

yo'
  • 51,322
Kai ML
  • 33
  • 1
  • 7

2 Answers2

6

Welcome to TeX.SE!

  • please always provide MWE (Minimal Working Example), a small but complete document, which we can compile as it is and which reproduce your problem
  • environment alignat requires data on how many columns you like to have (since you did not define them, you receive errors)
\documentclass{article}
\usepackage{amsmath}

\begin{document} \begin{alignat}{3} u & = \tan^{-1}{x} &\qquad & v & = x\ du & = \frac{1}{1+x^2} & & dv & = 1 \end{alignat} \end{document}

enter image description here

If you like to have a bigger distance between columns with math expression, rather use align than alignat environment:

\documentclass{article}
\usepackage{amsmath}

\begin{document} \begin{align} u & = \tan^{-1}{x} & v & = x\ du & = \frac{1}{1+x^2} & dv & = 1 \end{align} \end{document}

enter image description here

CarLaTeX
  • 62,716
Zarko
  • 296,517
5

You must tell alignat how many “right-left” pairs of columns you want. And you have to provide the desired separation.

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat}{2} & u=\arctan{x} &\qquad& v=x\ & du=\frac{1}{1+x^2} && dv=1 \end{alignat}

\end{document}

enter image description here

I used “arctan” because I believe the symbol you use is mathematically wrong, so I cannot use it.

If you want to align at the = signs:

\documentclass{article}
\usepackage{amsmath}

\begin{document}

\begin{alignat}{2} u&=\arctan{x} &\qquad v&=x\ du&=\frac{1}{1+x^2} & dv&=1 \end{alignat}

\end{document}

enter image description here

egreg
  • 1,121,712