# How change the horizontal space while the align environment

This is my code, if one tests it the last term is all the way to the right, how can I change the horizontal spacing so that everything is to the left?

\documentclass[a4paper]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{mathrsfs}
\usepackage{amsfonts}
\usepackage{tabstackengine}
\stackMath
\makeatletter
\renewcommand\TAB@delim[1]{\scriptstyle#1}
\makeatother
\setstackgap{S}{2pt}
\begin{document}
\begin{align*}
&\int _0^1\arctan ^3\left(x\right)\:dx=\frac{1}{2}\beta \left(3\right)-2\int _0^1\frac{x\arctan ^2\left(x\right)}{1+x^2}\:dx\\[5mm]
&=\frac{1}{2}\beta \left(3\right)-\frac{3}{8}\ln \left(2\right)\zeta \left(2\right)+2\underbrace{\int _0^1\frac{\arctan \left(x\right)\ln \left(1+x^2\right)}{1+x^2}\:dx}_{x=\tan \left(t\right)}\\
&=\frac{1}{2}\beta \left(3\right)-\frac{3}{8}\ln \left(2\right)\zeta \left(2\right)-4\int _0^{\frac{\pi }{4}}t\ln \left(\cos \left(t\right)\right)\:dt \\[2mm]
&=\frac{1}{2}\beta \left(3\right)-\frac{3}{8}\ln \left(2\right)\zeta \left(2\right)+4\ln \left(2\right)\int _0^{\frac{\pi }{4}}t-4\sum _{k=1}^{\infty }\frac{\left(-1\right)^{k+1}}{k}\int _0^{\frac{\pi \:}{4}}t\cos \left(2kx\right)\:dt
\end{align*}
%\end{Large}
\end{document}

• Welcome to TeX.SX! Please make your code compilable (if possible), or at least complete it with \documentclass{...}, the required \usepackage's, \begin{document}, and \end{document}. That may seem tedious to you, but think of the extra work it represents for TeX.SX users willing to give you a hand. Help them help you: remove that one hurdle between you and a solution to your problem. – TobiBS Aug 15 at 8:43
• ok i think its more complete now – user222501 Aug 15 at 9:03
• I completed your snippet and tested it. If you mean the last line ends far to the right, this is due to the length of the formula in this last line. If you don't like it, you can split it after the = sign. If 've misunderstood the problem, pleave explain with more details – Bernard Aug 15 at 9:09
• @Bernard: A switch with an extra "s". Sorry for the typo. – leandriis Aug 15 at 9:34
• Don't be sorry – I found that rather funny. Remembered me some Lubitsch movie (not sure which one). – Bernard Aug 15 at 9:37

If you provide an additional line break in what's currently the final row (and omit the stray \end{Large} directive), your equation looks fine in my opinion.

Incidentally, none of the manifold \left and \right sizing statements actually do anything -- except mess up the horizontal spacing and create an awful lot of code clutter. Do omit them.

\documentclass[a4paper]{article}
\usepackage{amsmath}
\begin{document}

\begin{align*}
\int_0^1 \!\arctan^3(x)\,dx
&=\frac{1}{2}\beta(3)
-2\int_0^1 \frac{x\arctan^2(x)}{1+x^2}\,dx\\[3mm]
&=\frac{1}{2}\beta(3)-\frac{3}{8}\ln(2)\zeta(2)
+2\underbrace{\int_0^1 \frac{\arctan(x)\ln(1+x^2)}{%
1+x^2}\,dx}_{x=\tan(t)}\\
&=\frac{1}{2}\beta(3)-\frac{3}{8}\ln(2)\zeta(2)
-4\int_0^{\frac{\pi}{4}} t\ln(\cos(t))\,dt\\[2mm]
&=\frac{1}{2}\beta(3)-\frac{3}{8}\ln(2)\zeta(2)
+4\ln(2)\int_0^{\frac{\pi}{4}} t \\ % <-- new linebreak
\int_0^{\frac{\pi}{4}} t\cos(2kx)\,dt
\end{align*}
\end{document}


With use of the multlined environment defined in the mathtools package:

\documentclass[a4paper]{article}
\usepackage{mathtools}

\begin{document}
\begin{align*}
\int_0^1 \arctan^3(x)\,dx
&=\frac{1}{2}\beta(3)
-2\int_0^1 \frac{x\arctan^2(x)}{1+x^2}\,dx\\[3mm]
&=\frac{1}{2}\beta(3)-\frac{3}{8}\ln(2)\zeta(2)
+2\underbrace{\int_0^1 \frac{\arctan(x)\ln(1+x^2)}{%
1+x^2}\,dx}_{x=\tan(t)}\\
&=\frac{1}{2}\beta(3)-\frac{3}{8}\ln(2)\zeta(2)
-4\int_0^{\frac{\pi}{4}} t\ln(\cos(t))\,dt\\[2mm]
& = \begin{multlined}[t]
\frac{1}{2}\beta(3)-\frac{3}{8}\ln(2)\zeta(2) +4\ln(2)\int_0^{\frac{\pi}{4}} t \\ % <-- new linebreak
-4\sum_{k=1}^{\infty} \frac{(-1)^{k+1}}{k} \int_0^{\frac{\pi}{4}} t\cos(2kx)\,dt
\end{multlined}
\end{align*}
\end{document}


Still another variant, with some improvements: I've removed the plethora of useless \left ... \right, using a single \bigl(...\bigr) for reaons of legibility. Other than that, I systematically used the medium-sized fractions from nccmath for fractionary coefficients, which should not have, in my opinion, the same visual importance as fractionary expressions.

\documentclass{article}%
\usepackage{nccmath, mathtools}

\begin{document}

\begin{align*}
\int _0^1\arctan ^3(x)\:dx&=\mfrac{1}{2}\beta (3)-2\int _0^1\frac{x\arctan ^2(x)}{1+x^2}\:dx\\[5mm]
&=\mfrac{1}{2}\beta (3)-\mfrac{3}{8}\ln (2)\zeta (2)+2\underbrace{\int _0^1\frac{\arctan (x)\ln (1+x^2)}{1+x^2}\:dx}_{x=\tan (t)}\\
&=\mfrac{1}{2}\beta (3)-\mfrac{3}{8}\ln (2)\zeta (2)-4\int _0^{\frac{\pi }{4}}t\ln\bigl(\cos(t)\bigr)\:dt \\[2mm]
&=\mfrac{1}{2}\beta (3)\begin{aligned}[t] & -\mfrac{3}{8}\ln (2)\zeta (2)+4\ln (2)\int _0^{\frac{\pi }{4}}t {}\\[-1ex] & -4\sum _{k=1}^{\infty }\frac{(-1)^{k+1}}{k}\int _0^{\frac{\pi \:}{4}}t\cos (2kx)\:dt
\end{aligned}
\end{align*}

\end{document}