Equation too long -> label appears in next line

I have the following long equation and I want to label it but unfortunetly it appears to be too long so the label appears in next line. How can I fix this?

\documentclass{article}
\usepackage{amsmath}
\begin{document}

$$\label{my_eq} \min_{f,u} \frac{1}{2} \|A(Bu -f)\|^2_2 + \lambda_1\|Cf\|_{1,p} + \lambda_2\|Du\|_{1,p} + \frac{\kappa}{2}\|Ef - f_0\|^2_2 + \frac{1}{2}\|E(Pu) - f_0\|^2_2$$
\end{document}


1 Answer

There are more options: one it is to use multline or split or to use geometry package or of the other strategies.

\documentclass{article}
\usepackage{amsmath}
\usepackage{nccmath}

\begin{document}

\begin{multline}\label{my_eq}
\min_{f,u} \mfrac{1}{2} \|A(Bu -f)\|^2_2 + \lambda_1\|Cf\|_{1,p} + \lambda_2\|Du\|_{1,p}\\
+\mfrac{\kappa}{2}\|Ef - f_0\|^2_2 + \mfrac{1}{2}\|E(Pu) - f_0\|^2_2
\end{multline}

\end{document}


With the geometry package you can choose the margins of the paper.

\documentclass{article}
\usepackage[margin=2cm]{geometry}
\usepackage{amsmath}
\usepackage{nccmath}
\begin{document}

$$\label{my_eq} \min_{f,u} \mfrac{1}{2} \|A(Bu -f)\|^2_2 + \lambda_1\|Cf\|_{1,p} + \lambda_2\|Du\|_{1,p} + \mfrac{\kappa}{2}\|Ef - f_0\|^2_2 + \mfrac{1}{2}\|E(Pu) - f_0\|^2_2$$

\end{document}


• I 'd add a {} after the + at the end of the first line, for spacing reasons – Bernard Aug 7 '20 at 19:15
• @Bernard Done! Approved your comment. – Sebastiano Aug 7 '20 at 19:18
• Maybe, also, the fraction coefficients would look nicer with medium-sized factions (\mfrac from nccmath). LaTeX makes me a bit fussy at times :-) – Bernard Aug 7 '20 at 19:25
• @Bernard Don't worry. I provide now to edit. – Sebastiano Aug 7 '20 at 19:27
• The + sign should go to the next line. – egreg Aug 7 '20 at 21:52