# How to split a long formula and make it beautiful?

My method:

\documentclass[UTF8]{ctexart}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{inputenc}

\begin{document}
$$\begin{split} \hat{c}_x(t,\gamma)=\int_0^t [K(\sigma,\gamma) K_L(e_\sigma)+e_f(\sigma)] d\sigma \\ & +K(t,\gamma) K_L e(t)-K(0,\gamma) K_L e(0) \\ & -\int_0^t [\frac{\partial{K(\sigma,\gamma)}}{\partial \sigma}K_L e(\sigma)d\sigma \end{split}$$

\end{document}


However, the formula becomes symmetrical. I want to know how to revise it.

-
I think you need to include a & on the first line. Try to add it between = and \int_0^t and see what happens. – Ignasi Jan 8 '14 at 15:20
Why did you ask the same question twice? – egreg Jan 8 '14 at 15:21
@egreg,Sorry, my network enviroment is bad ,so I gussess I submit twice when I think it is not be submitted. – mma Jan 8 '14 at 15:24
You should accept one of the answers. :) – Svend Tveskæg Jan 12 '14 at 17:04

You almost had it: you forgot to add & in the first row to mark the alignment point. A small refinement for not having the plus and minus below the equal sign by adding \quad. But I also present a slightly different approach, with the operation signs at the end of the lines.

Also, a \, before the differential is recommended

\documentclass[UTF8]{ctexart}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{epstopdf}
\usepackage{inputenc}

\begin{document}
$$\begin{split} \hat{c}_x(t,\gamma)&=\int_0^t [K(\sigma,\gamma) K_L(e_\sigma)+e_f(\sigma)] \,d\sigma \\ &\quad +K(t,\gamma) K_L e(t)-K(0,\gamma) K_L e(0) \\ &\quad -\int_0^t \frac{\partial{K(\sigma,\gamma)}}{\partial \sigma}K_L e(\sigma) \,d\sigma \end{split}$$

$$\begin{split} \hat{c}_x(t,\gamma)={} &\int_0^t [K(\sigma,\gamma) K_L(e_\sigma)+e_f(\sigma)] \,d\sigma + {} \\ &K(t,\gamma) K_L e(t)-K(0,\gamma) K_L e(0) - {}\\ &\int_0^t \frac{\partial{K(\sigma,\gamma)}}{\partial \sigma}K_L e(\sigma) \,d\sigma \end{split}$$

\end{document}


In order to have the small space automatically added, type

\newcommand{\diff}{\mathop{}\!d}


and use \diff\sigma or \diff x when needed.

What's the difference between using

$$\begin{split} ... \end{split}$$


\begin{aligned} ... \end{aligned}


or

\begin{align*}
...
\end{align*}


that have been proposed?

With split you can globally act so that the number is centered or placed at the bottom (with equation numbers on the right, it would be at the top with equation numbers on the left). By default the number is vertically centered, but with

\usepackage[tbtags]{amsmath}


it would be placed at top or bottom.

With aligned you'd get it vertically centered no matter what option you give. With align* you get no number at all. If instead align is used, you'd have to place manually \nonumber on the non numbered lines and it would be awkward to center it for an even number of lines.

-
@karlkoeller Yes, I meant that. – egreg Jan 8 '14 at 18:36
The main problem I see with the slightly different approach, with the operation signs at the end of the lines is that is a bit baffling. For example, the last line, your mind (at least mine) clearly “adds it to the sum” while you should subtract it (because of the minus). The benefit of the operation signs at the beginning is that it's a mix of unary and binary operators and clarifies the expression. – Manuel Jan 12 '14 at 16:28

I think you are after something like this?

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{aligned} \hat c_x(t,\gamma) &= \int_0^t \Bigl[ K(\sigma,\gamma) K_L(e_\sigma) + e_f(\sigma) \Bigr] d\sigma \\ & \qquad {}+ K(t,\gamma) K_L e(t) - K(0,\gamma) K_L e(0) \\ & \qquad {}- \int_0^t \Bigl[ \frac{\partial K(\sigma,\gamma)}{\partial\sigma} K_L e(\sigma) \Bigr] d\sigma \end{aligned}
\end{document}


-

I would do as follows:

\documentclass{article}

\usepackage{amsmath}
\newcommand*\dif{\mathop{}\!d}

\begin{document}

\begin{align*}
\hat c_x(t,\gamma)
&= \int_0^t [K(\sigma,\gamma) K_L(e_\sigma) + e_f(\sigma)] \dif\sigma \\
&\hphantom{{}=} + K(t,\gamma) K_L e(t) - K(0,\gamma) K_L e(0) \\
&\hphantom{{}=} - \int_0^t \left[ \frac{\partial K(\sigma,\gamma)}{\partial\sigma} K_L e(\sigma)\right] \dif\sigma
\end{align*}

\end{document}


-

# Remarks

I'm amazed, that no one suggested multline.

I prepared an example using three different approaches:

• multine: Left align the first line, mid aligns the lines in between and right aligns the last line.
• multlined (requires the mathtools package): Similar to multine, but to be used inside of e.g. equation, just like aligned. It aligns the last line a little behind the end of the first line, the lines in between will be aligned to the center.
• dmath from the breqn package: The breqn package features automatic linebreaking of equation, but has many downsides!

# Example

\documentclass[12pt]{article}
\pagestyle{empty}% for cropping
\usepackage{breqn}
\begin{document}
\begin{multline*}
\hat c_x(t,\gamma)
= \int_0^t \Bigl[ K(\sigma,\gamma) K_L(e_\sigma) + e_f(\sigma) \Bigr] d\sigma \\
+ K(t,\gamma) K_L e(t) - K(0,\gamma) K_L e(0)\\
- \int_0^t \Bigl[ \frac{\partial K(\sigma,\gamma)}{\partial\sigma} K_L e(\sigma) \Bigr] d\sigma
\end{multline*}
\clearpage
\begin{equation*}
\begin{multlined}
\hat c_x(t,\gamma)
= \int_0^t \Bigl[ K(\sigma,\gamma) K_L(e_\sigma) + e_f(\sigma) \Bigr] d\sigma \\
+ K(t,\gamma) K_L e(t) - K(0,\gamma) K_L e(0)\\
- \int_0^t \Bigl[ \frac{\partial K(\sigma,\gamma)}{\partial\sigma} K_L e(\sigma) \Bigr] d\sigma
\end{multlined}
\end{equation*}
\clearpage
\begin{dmath*}% no line breaks with \\ needed.
\hat c_x(t,\gamma)
= \int_0^t \Bigl[ K(\sigma,\gamma) K_L(e_\sigma) + e_f(\sigma) \Bigr] d\sigma
+ K(t,\gamma) K_L e(t) - K(0,\gamma) K_L e(0)
- \int_0^t \Bigl[ \frac{\partial K(\sigma,\gamma)}{\partial\sigma} K_L e(\sigma) \Bigr] d\sigma
\end{dmath*}
\end{document}


# breqn

-
A nice juxtaposition of various possible solutions. I think it might be even more useful if three solutions were rendered with the same magnification. (Right now, the effective font sizes are rather different.) – Mico Jan 12 '14 at 16:09
@Mico I will try to correct it, but this is due to the upload, where the StackExchange-software scales the picture to fit the column width. – Henri Menke Jan 12 '14 at 16:13

Since you did not only ask for line-breaking but also about beautification, I would like to add the following suggestions extending another answer:

1. In case "L" is not a variable, it should not be written italic.
2. I saw an upright "d" in many publications. You could consider to set it upright as well. Many people also prefer a half space in front of it.

Pick or ignore this suggestions depending on your focused audience.

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{aligned} \hat c_x(t,\gamma) &= \int\limits_0^t \Bigl[ K(\sigma,\gamma) K_{\mathrm L}(e_\sigma) + e_f(\sigma) \Bigr] \mathrm d\sigma \\ & \qquad {}+ K(t,\gamma) K_{\mathrm L} e(t) - K(0,\gamma) K_L e(0) \\ & \qquad {}- \int\limits_0^t \Bigl[ \frac{\partial K(\sigma,\gamma)}{\partial\sigma} K_{\mathrm L} e(\sigma) \Bigr] \mathrm d\sigma \end{aligned}
\end{document}


-