# How can I center equations?

My code is:

onde
$$\pi(\textbf{x})=\frac{1}{1+e^{-(\beta_0+\sum_{i=1}^{p}\beta_ix_i)}}$$


How can I put the equation in the middle?

• it would be centred by default, you presumably have fleqn option or a non standard class in use. – David Carlisle Jul 2 '16 at 13:31
• You should post a fully compilable code that produces this result (document class, packages and options thereof). – Bernard Jul 2 '16 at 13:32

I can more or less reproduce your screenshot with the following code (observe that the amsmath package is loaded with the option fleqn):

\documentclass{book}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage[fleqn]{amsmath}
\begin{document}
\setcounter{chapter}{2}
\setcounter{equation}{1}

\noindent
onde,
$$\pi(\textbf{x})=\frac{1}{1+e^{-(\beta_0+\sum_{i=1}^{p}\beta_ix_i)}}$$
\end{document}


If you want to have the displayed equations centered rather than left-justified, don't specify the fleqn option while loading amsmath.

Separately, you should use \mathbf rather than \textbf in math mode. Also, do consider using \exp[...] notation instead of e^{...}; your readers will thank you.

\documentclass{book}
\usepackage[a4paper,margin=2.5cm]{geometry}
\usepackage{amsmath}
\begin{document}
\setcounter{chapter}{2}
\setcounter{equation}{1}

\noindent
onde,
$$\pi(\mathbf{x})=\frac{1}{1+\exp[-(\beta_0+\sum_{i=1}^p \beta_ix_i)]}$$
\end{document}

• isn't e very different from exp? e is the number 2,718…, while exp would be an general exponent, albeit a rather unusual way of writing it. I am, however, not a mathematician, so I could very well be wrong here. – Runar Jul 2 '16 at 14:07
• @RunarTrollet - I'm not a mathematician either, but I've taken a fair number of math courses over the years. The only sensible base for the \exp expression is, you guessed it, e\approx 2.718. The reason I recommend \exp is typographic: the elements \beta, x, \sum, - and + will by typeset in scriptstyle rather than scriptscriptstyle -- much appreciated by anyone over 45 (or otherwise not blessed with keen eyesight of youth). – Mico Jul 2 '16 at 14:13
• You are perfectly correct, I have just never seen it written in that way, but you do make a very good case. I also found an interesting post on Math.SE, about this very topic. math.stackexchange.com/questions/1226089/is-expx-the-same-as-ex – Runar Jul 2 '16 at 14:26
• @RunarTrollet - Correction to what I wrote earlier: Most of the material in the denominator of the second equation is rendered in textstyle, not scriptstyle. (The subscript and superscript terms in the second version of the equation are in scriptstyle, whereas they are in scriptscriptstyle in the first version.) Either way, the size difference is rather significant. – Mico Jul 2 '16 at 14:43
• @Ana - Please confirm or disconfirm my conjecture that you were specifying the option fleqn in your document. – Mico Jul 2 '16 at 18:43