1

This question already has an answer here:

How to solve this alignment?

I wrote \[a^2+...\] but I couldn't align it in my document. What's the best way to center a long equation like this one?

I use LaTeX

marked as duplicate by Werner, Maarten Dhondt, Svend Tveskæg, user13907, LaRiFaRi Jul 2 '15 at 7:28

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What, precisely, are you trying to align? Which alignment point should be used? Please advise. – Mico Jul 2 '15 at 3:18
  • @Mico I would like to center this equation, but it's so long. What's the best way to solve this problem? write two times this symbol \[]\ and divide the equation in two? – user26832 Jul 2 '15 at 3:25
  • Are you really trying to typeset a^2+b^2+...? If not, please provide a more realistic example, i.e., the actual equation you're looking to typeset. – Mico Jul 2 '15 at 5:37
1

You should try something like this:

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage[left=3cm,right=2cm,top=3cm,bottom=2cm]{geometry}
\begin{document}
\begin{equation}
\begin{split}
a^2 + b^2 + c^2 +d^2\\ 
e ^2 + f^2 + g^2
\end{split}
\end{equation}
\end{document}
  • Is there any way to split it automatically? I mean If the equation is so long I don't know if I split in two , three or four parts. – user26832 Jul 2 '15 at 3:35
  • I'm not so sure :( I always did this way – Charles Henrique Porto Ferreir Jul 2 '15 at 3:37
  • @user26832 I think the idea is that something like a displayed equation should not be split automatically because it needs to be split where it 'makes sense' i.e. according to the meaning. And TeX can't do that because all it knows about is boxes. – cfr Jul 2 '15 at 3:39
  • Could you complete the code? split is not a standard LaTeX environment, after all. Your answer could be improved if it provided a compilable example. – cfr Jul 2 '15 at 3:41
0

There are a few options that you can choose from. You can either use \multiline or \split depending on how you would like to align. I would suggest to use \split in your case. And it will be like the following with the alignment point at $+$.

$\begin{split}
a^2 & +b^2 + \ldots \\
    & +l^2 + \ldots 
\end{split}$
  • 1
    I couldn't do it: "Package amsmath Error: \begin{split} won't work here \end{split}" – user26832 Jul 2 '15 at 4:14
  • You need to put \split in another math environment like \equation or \align because it is a subsidiary math environment which can not exist independently. – Zhang Ze Jul 2 '15 at 5:03

Not the answer you're looking for? Browse other questions tagged or ask your own question.