2

I want to align equation label at the right-hand side of the equation. But On using the below code equation label is getting shifted into a new line as you can see from the picture.

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
\begin{aligned}
\[ u_i =
  \begin{cases}
    v_i,  & \quad r \leq CR\\
    x_i,  & \quad r > CR\\
  \end{cases}
\]
\end{aligned}
\end{equation}

\end{document}

enter image description here

How to align equation label at the right-hand side of the equation.

  • 1
    You get plenty of errors, which you should not ignore. Remove \[ and \]. Also, aligned is redundant, while harmless. – egreg Apr 9 '17 at 7:38
  • Your code is not compilable due to the use of \[ and \] inside of a math-environment. If you drop these I get the desired output using your MWE. – Skillmon Apr 9 '17 at 7:39
  • @egreg the usage of aligned does change the spacing here (minimal, but it does). But I agree it is redundant. – Skillmon Apr 9 '17 at 7:41
  • Thanks @egreg it worked, Can you please write an answer so that I can accept it. – Atinesh Apr 9 '17 at 7:53
7

When I run pdflatex on your example, I get

! LaTeX Error: Bad math environment delimiter.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...                                              

l.7 \[
       u_i =

followed by several other errors. This means something is wrong in \[ and that TeX tries its best to get out from the situation, but the final result will most probably be different from the expected.

Note that \[...\] is just a shorthand for

\begin{equation*}
...
\end{equation*}

(because you're using amsmath) and at that point you have already opened an equation environment, where equation* doesn't make sense, does it?

Also aligned does nothing at all: it's needed if you have a subordinate alignment to be typeset in equation or equation* (or other alignment environments).

\documentclass{article}
\usepackage{amsmath}
\begin{document}

\begin{equation}
u_i =
  \begin{cases}
    v_i,  & r \leq CR \\
    x_i,  & r > CR
  \end{cases}
\end{equation}

Don't add \quad.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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