I am attempting to write a simple equation inside a document that uses Latex, and I have attempting this line of code so far:

$\mathcal{L}= -\frac{1}{4}  \mathcal{F}_{\mu \nu} \mathcal{F}^{\mu \nu} \\
+ \mathcal{i} \overline{\psi} \cancel{D}\psi + h.c. \\
+ \overline{\psi}_i y_{ij} \psi_j \phi + h.c. 
+|D_\mu \phi|^2 - V(\phi)$

This gives me:

enter image description here

where the label is immediate to the equation.

I have attempted \setcounter \label \usepackage{amsmath} \begin{align*}, but to no avail. The equation number continues to be at the very end of this equation, where I would like it to be right aligned (at the right edge of the page). Any advice would be greatly appreciated.

2 Answers 2


You have errors in your code:

  • $...$ and \[...\] opens/closes math environments
    • It is the error to use them inside an already created math environments
    • $...$ is for inline equations (equivalent but preferable form in LaTeX is \(...\))
    • \[...\] is a shot form for \begin{equation*}...\end{equation*} and is used for quick single-lined equations in display mode without eq. number
  • Don't use any form of centring inside math anvironments
  • More complex formatting requires other environments e.g. gather, align, alignat
    • Each such environment has an equivalent inner form: aligned, alignedat, and gathered
    • Inner forms can only be used inside already created math environment
    • Each of the inner form produces a single equation number, regardless of a number of lines it contains.

Also, a preferable way to make a section or a chapter number a part of the equation number is to use the following macro defined in amsmath:


It will reset the equation part every time you start a new section. Change section to chapter and you will get the same effect with chapters.

Here is one way to format your equation with a single equation number. The [b] is an optional argument of aligned environment to place eq. number at the bottom of the inner block.

More can be found in the documentation of amsmath package.

enter image description here



\section{The first section}

  \begin{aligned}[b]  % change to [t], [c] if top- or middle-aligned, respectively
    \mathcal{L} &= -\frac{1}{4}  \mathcal{F}_{\mu \nu} \mathcal{F}^{\mu \nu} \\
    &\qquad + \mathcal{i} \overline{\psi} \cancel{D}\psi + h.c. \\
    &\qquad + \overline{\psi}?_i y_{ij} \psi_j \phi + h.c.\\
    &\qquad + |D_\mu \phi|^2 - V(\phi)

Reference to the Equation~\ref{eq:example}.

Do not ignore LaTeX errors. They are there for a reason

In your case, I notice that you have


(I added indentation to make it clear what’s happening). You have \begin{center} ended with \end{equation} and \begin{equation} ended with \end{center}.

You need to properly nest things.


you don’t want to use a center environment in the first place. And the $$ shouldn’t be there.

When you have a multiline equation, you should use split from the amsmath package,¹ so your equation would look like

    \mathcal{L} = … \\
       … \\
       … \\

  1. If you’re unfamiliar with packages, this means that you will want to add to your document’s preamble (the stuff between \documentclass{…} and \begin{document}), the command:


    You can find out more about the capabilities of the amsmath package by typing texdoc amsmath at a command line if you're running LaTeX on your computer or going to https://texdoc.org and typing amsmath into the search box there.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .