6

I have try some code like this:

\begin{align*}
Q(R)&=\bi(R,R)\\
    &=\bi(R_I+R_{\Rico}+R_W,R_I+R_{\Rico}+R_W)\\
    &=\bi(R_I,R_I)+2\bi(R_I,R_{\Rico})+2\bi(R_I,R_W)\\
    &+\bi(R_{\Rico},R_{\Rico})+2\bi(R_{\Rico},R_w)\\
    &+\bi(R_W,R_W).
\end{align*}

where

\newcommand{\Rico}{\Ric_o}
\newcommand{\bi}{\mathrm{bi}\,}

The problem is I would like to set the last three lines aligned right, did there has any solutions instead to type several \quad or \qquad?

1
  • maybe \hspace will be a solution.
    – user19832
    Dec 3, 2012 at 14:34

2 Answers 2

3

I would place the last three equations in an extra aligned environment as follows:

\documentclass{article}

\usepackage{mathtools}

\DeclareMathOperator{\Ric}{Ric}
\newcommand{\Rico}{\Ric_o}
\DeclareMathOperator{\bi}{bi}

\begin{document}
\begin{align*}
  Q(R) ={}&\bi(R,R)\\
  ={}&\bi(R_I+R_{\Rico}+R_W,R_I+R_{\Rico}+R_W)\\
  ={}&\begin{aligned}[t]
    \bi(R_I,R_I)+2\bi(R_I,R_{\Rico})+2\bi(R_I,R_W)&\\
    +\bi(R_{\Rico},R_{\Rico})+2\bi(R_{\Rico},R_w)&\\
    +\bi(R_W,R_W)&.
  \end{aligned}
\end{align*}
\end{document}

Sample output

Noticed the changed placement of the alignment charecter in relation to the equals signs and the consequent use of extra braces as ={}& to ensure correct spacing. I have also defined your missing commands with \DeclareMathOperator. I chose to load mathtools instead of amsmath, but that is just personal preference; it loads amsmath anyway.

4
  • Personally, I would write &= as I write always. And then use \! before the \begin{aligned}.... Shorter in my opinion (may be not truly aligned, but it looks well).
    – Manuel
    Dec 3, 2012 at 18:20
  • @Manuel That is what I usually do too, but in this case the misalignment seemed too much. I'll really have to understand one day what is going there. Dec 3, 2012 at 18:40
  • I have just ignored the usage of [t] in my trying. By the way, I think {}& just give the right (balance) spacing of =, is it right?
    – user19832
    Dec 17, 2012 at 8:06
  • @user19832 The [t] or [b] option is very useful for fixing the vertical alignment. The documentation for the mathtools package uses ={}& almost everywhere in alignments. To my eyes (which often deceive me) it gives very tiny extra space in comparison with &=, but I haven't made any concrete measurements. Dec 17, 2012 at 9:48
2

Here's a couple of options- you didn't tell us what the \Ric command is- please always post a complete MWE :)

screenshot

I would also use

\newcommand{\bi}{\operatorname{bi}}

for your \bi command, assuming I have interpreted it correctly.

\documentclass{article}
\usepackage{amsmath}
\newcommand{\Rico}{Ric_o}
%\newcommand{\bi}{\mathrm{bi}\,}
\newcommand{\bi}{\operatorname{bi}}

\begin{document}

\begin{align*}
Q(R)&=\bi(R,R)\\
    &=\bi(R_I+R_{\Rico}+R_W,R_I+R_{\Rico}+R_W)\\
    &=\bi(R_I,R_I)+2\bi(R_I,R_{\Rico})+2\bi(R_I,R_W)\\
    &\phantom{{}=}+\bi(R_{\Rico},R_{\Rico})+2\bi(R_{\Rico},R_w)\\
    &\phantom{{}=}+\bi(R_W,R_W).
\end{align*}

\begin{align*}
Q(R)&=\bi(R,R)\\
    &=\bi(R_I+R_{\Rico}+R_W,R_I+R_{\Rico}+R_W)\\
    &=\bi(R_I,R_I)+2\bi(R_I,R_{\Rico})+2\bi(R_I,R_W)\\
    &&&+\bi(R_{\Rico},R_{\Rico})+2\bi(R_{\Rico},R_w)\\
    &&&+\bi(R_W,R_W).
\end{align*}

\end{document}
0

You must log in to answer this question.

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