Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Good day to all,

I have below equation, the first equation exceeds my margin if written in one line. So I want it appear in two lines which the first line is justified at the left side and the second line is justified at the right. Is this is a good practice or I have to put it in other way, which is accepted by mathematician especially.

This is the output of my latex command

\documentclass{report}
\usepackage{amssymb,amsmath}

\begin{document}

\begin{eqnarray}\nonumber
\mathbf{c}_m^t(b_0\mathbf{I}_m +b_{1}\mathbf{Q}_{m}+b_{2}\mathbf{Q}^2_{m}+\cdots +b_n \mathbf{Q}_m^n)\mathbf{H}_m=&\\ \label{panjang}
=\mathbf{eQ}_m^{\alpha}(a_0 \mathbf{I}_m^{}+a_1\mathbf{Q}_m+a_2\mathbf{Q}_m^{2}+\cdots+a_n\mathbf{Q}_m^{n})\mathbf{H}_m
\end{eqnarray}
where \(\mathbf{e}=\begin{bmatrix}\sqrt{m} & 0 & \cdots & 0\end{bmatrix}\). Rewrite Eqn. \ref{panjang} with
\begin{eqnarray}g_1(\mathbf{Q}_{m})=a_0 \mathbf{I}_m+a_1\mathbf{Q}_m^{}+a_2\mathbf{Q}_m^{2}+\cdots+a_n\mathbf{Q}_m^{ n}\end{eqnarray} 
and 
\begin{eqnarray}
g_2(\mathbf{Q}_{m})=b_0\mathbf{I}_m +b_{1}\mathbf{Q}_{m}+b_{2}\mathbf{Q}^2_{m}+\cdots +b_n \mathbf{Q}_m^n\end{eqnarray} it becomes
\begin{eqnarray}
\mathbf{c}_m^t g_{2}(\mathbf{Q}_{m})&=&
\mathbf{e}\mathbf{Q}_m^\alpha g_1(\mathbf{Q}_{m}).
\end{eqnarray}

\end{document}
share|improve this question
    
thank you. actually there are lines above the equation displayed. I just copied the equation. thank you for your advice. –  azlanaznam Jul 21 '12 at 9:55

2 Answers 2

As mentioned for example in the UK TeX FAQ the use of eqnarray is discouraged.

To achieve the layout you want, you can use for example the multline environment from amsmath. What else can be done is described for example in the Short Math Guide for LaTeX. I would not put a = on the end of the first line. But otherwise I think your approach is the best way to go in this case.

share|improve this answer
1  
It is the multline not multiline environment. Understandable, even so much that a specific error related to the accidental use of multiline instead of multline is mentioned in the troubleshooting of the amsmath manual :) –  J M Jul 21 '12 at 8:43
    
@J M: Oh. Strangely I read multiline in the Short Math Guide although it really does say multline. Guess that's how our mind plays tricks on us. Thanks a lot for the correction. –  canaaerus Jul 21 '12 at 8:49
    
great!it works. i couldn't think of looking at other options of equation environment. what i was thinking is how to have other command or renew command.. thanks a lot. –  azlanaznam Jul 21 '12 at 9:57
    
@azlanaznam: Glad to be of help. Please accept the answer if your problem is sufficiently solved. –  canaaerus Jul 21 '12 at 10:02
    
The align environment can also be quite helpful ins ome situations. –  Alfred M. Jul 21 '12 at 10:05

I would certainly replace the first eqnarray environment with a multline environment, as @canaaerus suggests in his answer.

Furthermore, I would also replace the second and third eqnarray environments with a single align environment (with the word and inserted with a \shortintertext macro), and I'd replace the final eqnarray environment with a simple equation environment. Basically, there's no good reason for using eqnarray, especially as the available alternatives are so much better.

In addition, I'd create a macro to abbreviate the very frequently occurring \mathbf{Q} with something shorter, say, \Q, i.e., I set up the macro \newcommand{\Q}{\mathbf{Q}}. Finally, if you want to have parentheses placed around cross-referenced equation numbers, you can get LaTeX to do this for you automatically if you use the \eqref (instead of \ref).

Taken together, the following modified MWE results:

\documentclass{report}
\usepackage{mathtools}
\numberwithin{equation}{chapter} % just for the MWE
\newcommand{\Q}{\mathbf{Q}}
\begin{document}
\setcounter{chapter}{5} % just for the MWE
\setcounter{equation}{19} % just for the MWE
\begin{multline}\label{panjang}
\mathbf{c}_m^t(b_0\mathbf{I}_m +b_{1}\Q_{m}+b_{2}\Q^2_{m}+\dots +b_n \Q_m^n)\mathbf{H}_m\\ 
=\mathbf{eQ}_m^{\alpha}(a_0 \mathbf{I}_m^{}+a_1\Q_m+a_2\Q_m^{2}+\dots+a_n\Q_m^{n})\mathbf{H}_m
\end{multline}
where \(\mathbf{e}=
\begin{bmatrix}\sqrt{m} & 0 & \dots & 0\end{bmatrix}\). Rewrite Eqn.~\eqref{panjang} with
\begin{align}g_1(\Q_{m})&=a_0 \mathbf{I}_m+a_1\Q_m^{}+a_2\Q_m^{2}+\dots+a_n\Q_m^{ n}
\shortintertext{and}
g_2(\Q_{m})&=b_0\mathbf{I}_m +b_{1}\Q_{m}+b_{2}\Q^2_{m}+\dots +b_n \Q_m^n
\end{align} 
so that it becomes
\begin{equation}
\mathbf{c}_m^t g_{2}(\Q_{m}) =
\mathbf{e}\Q_m^\alpha g_1(\Q_{m}).
\end{equation}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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