6

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

3

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

| improve this answer | |
4

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

| improve this answer | |
  • 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
  • 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 '14 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 '14 at 3:36
4

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

| improve this answer | |

Your Answer

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