3

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

LaRiFaRi
  • 43,807
user26832
  • 497
  • What, precisely, are you trying to align? Which alignment point should be used? Please advise. – Mico Jul 02 '15 at 03: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 02 '15 at 03: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 02 '15 at 05:37

2 Answers2

2

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}
  • 1
    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 02 '15 at 03:35
  • I'm not so sure :( I always did this way – Charles Henrique Porto Ferreir Jul 02 '15 at 03: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 02 '15 at 03:39
  • 1
    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 02 '15 at 03: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}$
Zhang Ze
  • 347
  • 3
    I couldn't do it: "Package amsmath Error: \begin{split} won't work here \end{split}" – user26832 Jul 02 '15 at 04:14
  • 1
    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 02 '15 at 05:03