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.

I have tried for over one hour now, in vain, on centering one equation. Why in the world is the equation not centered - i.e., so much margin on the left??

Here is my code:

\documentclass[10pt]{article}
\begin{document}
$$\frac{dX_{SS}}{dt}=\Lambda-\mu X_{SS}-\frac{\beta\bigg(X_{HS}+X_{HT}+X_{H+{T_T^{(1)}}}+X_{H+T_T^{(2)}}
+X_{H+T_T^{(3)}}\bigg)}{N}-\frac{\tau(X_{ST}+X_{HT})X_{SS}}{N}$$
\end{document}

And the output:

enter image description here

I have tried flalign, raggedleft, raggedright, with amsmath package, etc...

share|improve this question
    
Please, don't use $$...$$ for one-line displayed maths in LaTeX documents; use \[...\] instead (See tex.stackexchange.com/questions/503/why-is-preferable-to). –  Gonzalo Medina Jul 17 at 3:30

3 Answers 3

up vote 4 down vote accepted

How about this solution that uses alignedat? There is only one number naturally:

    \documentclass[10pt]{article}
    \usepackage[utf8]{inputenc}
    \usepackage{lmodern}

    \usepackage{mathtools}

    \begin{document}

    I have tried for over one hour now, in vain, on centering one equation. Why in the world is the equation not centered - i.e., so much margin on the left??

    \begin{equation}
    \begin{alignedat}{2}
    \frac{dX_{SS}}{dt} &= \Lambda - \mu X_{SS} &  & -\frac{β \big(X_{HS}+X_{HT}+X_{H+{T_T^{(1)}}}+X_{H+T_T^{(2)}}+X_{H+T_T^{(3)}}\big)}{N} \\
     &  &  &  -\frac{τ(X_{ST}+X_{HT})X_{SS}}{N}
    \end{alignedat}
    \end{equation}

    \end{document} 

enter image description here

share|improve this answer

As you can see from the enlarged version, the equation is longer then \textwidth, hence cannot be centered. But, in general instead of TeX $$...$$, a LaTeX \[...\] (or other structure) should be used. See Why is \[ ... \] preferable to $$ ... $$?

\documentclass[10pt]{article}
\begin{document}


I have tried for over one hour now, in vain, on centering one equation. Why in the world is the equation not centered - i.e., so much margin on the left??

$$\frac{dX_{SS}}{dt}=\Lambda-\mu X_{SS}-\frac{\beta\bigg(X_{HS}+X_{HT}+X_{H+{T_T^{(1)}}}+X_{H+T_T^{(2)}}
+X_{H+T_T^{(3)}}\bigg)}{N}-\frac{\tau(X_{ST}+X_{HT})X_{SS}}{N}$$




I have tried for over one hour now, in vain, on centering one equation. Why in the world is the equation not centered - i.e., so much margin on the left??
\end{document}

enter image description here

But it is better to split too long equation:

\documentclass[10pt]{article}
\usepackage{amsmath}
\begin{document}


I have tried for over one hour now, in vain, on centering one equation. Why in the world is the equation not centered - i.e., so much margin on the left??

\begin{align*}
\frac{dX_{SS}}{dt}&=\Lambda-\mu X_{SS}-\frac{\beta\bigg(X_{HS}+X_{HT}+X_{H+{T_T^{(1)}}}+X_{H+T_T^{(2)}}
+X_{H+T_T^{(3)}}\bigg)}{N}\\
&\quad{}-\frac{\tau(X_{ST}+X_{HT})X_{SS}}{N}
\end{align*}




I have tried for over one hour now, in vain, on centering one equation. Why in the world is the equation not centered - i.e., so much margin on the left??


\end{document}

enter image description here

share|improve this answer
    
How can I make it look proper and "nice"? I tried reducing the fontsize to 4pt but it made no difference. –  Anonymous Jul 17 at 3:22
    
@Anonymous What about spliting on tle last - sign? –  Przemysław Scherwentke Jul 17 at 3:24
    
That's ok, but can I make the equations themselves smaller font? –  Anonymous Jul 17 at 3:25
2  
@Anonymous You can say, e.g., {\footnotesize (your equation)}, but it is a last resort. Splitting into lines is a normal practice. –  Przemysław Scherwentke Jul 17 at 3:29
1  
@PrzemysławScherwentke Could you please suggest in you answer not to use $$...$$ for one-line displayed maths in LaTeX documents, but to use \[...\] instead? (Even though I know the real problem here is not that, but in any case it's a useful advise, in my opinion). –  Gonzalo Medina Jul 17 at 3:36

You have several ways: I'll present four. In all, the long fraction line has been replaced by \frac{1}{N} in front of the numerator, which is probably less heavy to read. The examplese after the first actually have \tfrac{1}{N} which is possibly even better. Exercise your taste.

\documentclass[10pt]{article}
\usepackage{amsmath}
\begin{document}

I have tried for over one hour now, in vain, on centering one equation. Why in the world is 
the equation not centered---i.e., so much margin on the left?
\begin{equation*}
\begin{split}
\frac{dX_{SS}}{dt}=\Lambda-\mu X_{SS}
  &-\frac{1}{N}
      \beta\bigl(X_{HS}+X_{HT}+X_{H+T_T^{(1)}}+X_{H+T_T^{(2)}}+X_{H+T_T^{(3)}}\bigr)\\
  &-\frac{1}{N}\tau(X_{ST}+X_{HT})X_{SS}
\end{split}
\end{equation*}
I have tried for over one hour now, in vain, on centering one equation. Why in the world is 
the equation not centered---i.e., so much margin on the left?
\begin{equation*}
\begin{split}
\frac{dX_{SS}}{dt}=\Lambda-\mu X_{SS}
  &-\tfrac{1}{N}
      \beta\bigl(X_{HS}+X_{HT}+X_{H+T_T^{(1)}}+X_{H+T_T^{(2)}}+X_{H+T_T^{(3)}}\bigr)\\
  &-\tfrac{1}{N}\tau(X_{ST}+X_{HT})X_{SS}
\end{split}
\end{equation*}
I have tried for over one hour now, in vain, on centering one equation. Why in the world is 
the equation not centered---i.e., so much margin on the left?
\begin{multline*}
\frac{dX_{SS}}{dt}=\Lambda-\mu X_{SS}
  -\tfrac{1}{N}
      \beta\bigl(X_{HS}+X_{HT}+X_{H+T_T^{(1)}}+X_{H+T_T^{(2)}}+X_{H+T_T^{(3)}}\bigr)\\
  -\tfrac{1}{N}\tau(X_{ST}+X_{HT})X_{SS}
\end{multline*}
I have tried for over one hour now, in vain, on centering one equation. Why in the world is 
the equation not centered---i.e., so much margin on the left?
\begin{multline*}
\frac{dX_{SS}}{dt}=\Lambda-\mu X_{SS}\\
  -\tfrac{1}{N}
      \beta\bigl(X_{HS}+X_{HT}+X_{H+T_T^{(1)}}+X_{H+T_T^{(2)}}+X_{H+T_T^{(3)}}\bigr)\\
  -\tfrac{1}{N}\tau(X_{ST}+X_{HT})X_{SS}
\end{multline*}
I have tried for over one hour now, in vain, on centering one equation. Why in the world is 
the equation not centered---i.e., so much margin on the left?

\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.