# Why is the equation not centered?

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:

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

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{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{document}


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}


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


• How can I make it look proper and "nice"? I tried reducing the fontsize to 4pt but it made no difference. – user54515 Jul 17 '14 at 3:22
• @Anonymous What about spliting on tle last - sign? – Przemysław Scherwentke Jul 17 '14 at 3:24
• That's ok, but can I make the equations themselves smaller font? – user54515 Jul 17 '14 at 3:25
• @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 '14 at 3:29
• @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 '14 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}