2

I'm writing a formula in mathmode but the line breaks don't wrap properly. I've tried \newline, \brea, \ and \hfill and none of them work. What can I do to make the line breaks wrap properly?

Thank you very much.

$<\hat{x}^2> = \frac{\int \tilde{\Psi}\hat{x}^2 \tilde{\Psi}d \tau}{\int\tilde{\Psi} *\tilde{Psi} d \tau} = N^4\int_{-a}^a \left(x^2-a^2\right)^2 \hat{x}^2\left(x^2-a^2\right)^2 dx = N^4\int_{-a}^a x^{10}-4a^2x^8+6a^4x^6-4a^6a^6x^4+a^8x^2dx = N^4\left.\left(\frac{x^{11}}{11}- \newline \frac{4a^2x^9}{9}+\frac{6a^4x^7}{7}-\frac{4a^6x^5}{5}+\frac{a^8x^3}{3}\right)\right]_{-a}^a = N^4\left[\left(\frac{a^{11}}{11}- \break \frac{4a^{11}}{9}+\frac{6a^{11}}{7}-\frac{4a^{11}}{5}+\frac{a^{11}}{3}\right)- \newline \left(-\frac{a^{11}}{11}+\frac{4a^{11}}{9}-\frac{6a^{11}}{7}+\frac{4a^{11}}{5}-\frac{a^{11}}{3}\right)\right] = \frac{315}{256a^9}\frac{256a^{11}}{3456}=\frac{35a^2}{384}$

enter image description here

3
  • Please provide complete small document with your equation. Your equation is very long, do you thing about to wrote it as displayed equation in one of amsmath environments?
    – Zarko
    Commented Dec 1 at 10:28
  • 1
    as you can see in your image <\hat{x}> does not produce angle brackets but less than and greater than, use \langle and \rangle Commented Dec 1 at 11:49
  • you need to remove the \left...\right as tex can not break a line within those commands, but you will not produce readable output from automatic linebreaking, here better to use an amsmath display such as \begin{align*} and align on the = with &= Commented Dec 1 at 11:51

1 Answer 1

8

I recommend you switch to using an align* environment (provided by the amsmath package). That way, display-style math mode instead of text-style math mode will be the default, the spacing between lines will be a bit more generous, and it'll be straightforward to select alignment points in each row.

Incidentally, I think you're missing a pair of parentheses in row 3.

enter image description here

\documentclass{article}
\usepackage{amsmath}  % for 'align*' environment

\begin{document}

\addtolength\jot{3pt}
\begin{align*}
\langle\hat{x}^2\rangle 
&= \frac{\int \tilde{\Psi}\hat{x}^2\tilde{\Psi} \, d\tau}%
        {\int\tilde{\Psi}*\tilde{\Psi} \, d\tau} \\
&= N^4\int_{-a}^a {(x^2-a^2)}^2 \hat{x}^2 {(x^2-a^2)}^2 \,dx \\
&= N^4\int_{-a}^a x^{10}-4a^2 x^8 +6a^4 x^6 -4a^6 a^6 x^4 +a^8 x^2 \,dx \\
&= N^4\biggl(\frac{x^{11}}{11} - \frac{4a^2x^9}{9}
   +\frac{6a^4x^7}{7}-\frac{4a^6x^5}{5}
   +\frac{a^8x^3}{3}\biggr)\bigg]_{-a}^a \\
&= N^4\biggl\{\biggl(\frac{a^{11}}{11}
   -\frac{4a^{11}}{9}+\frac{6a^{11}}{7}
   -\frac{4a^{11}}{5}+\frac{a^{11}}{3}\biggr)\\
&\qquad -\biggl(-\frac{a^{11}}{11}+\frac{4a^{11}}{9}
   -\frac{6a^{11}}{7}+\frac{4a^{11}}{5}
   -\frac{a^{11}}{3}\biggr)\biggr\} \\
&= \frac{315}{256a^9}\frac{256a^{11}}{3456}
   =\frac{35a^2}{384}
\end{align*}

\end{document}

Addendum: If for some reason you can't abide an align* environment, I suggest you place the entire equation in a \parbox.

enter image description here

Speaking for myself (who else?), I'd say that the align* solution is a lot easier to read.

\documentclass{article}
\usepackage{amsmath}  % for 'align*' environment
\usepackage{setspace} % for '\setstretch' macro
\begin{document}
\begin{center}

\setstretch{2.75} % need to increase the line spacing

\parbox{0.9\textwidth}{\raggedright%
\hangindent=15pt\hangafter=1 % automatic hanging indentation
$\displaystyle % use displaystyle rather than textstyle math
\langle\hat{x}^2\rangle 
= \frac{\int \tilde{\Psi}\hat{x}^2\tilde{\Psi} \, d\tau}
       {\int\tilde{\Psi}*\tilde{\Psi} \, d\tau} 
= N^4\int_{-a}^a {(x^2-a^2)}^2 \hat{x}^2 {(x^2-a^2)}^2 \,dx 
= N^4\int_{-a}^a x^{10}-4a^2 x^8 +6a^4 x^6 -4a^6 a^6 x^4 +a^8 x^2 \,dx 
= N^4\biggl(\frac{x^{11}}{11} - \frac{4a^2x^9}{9}
   +\frac{6a^4x^7}{7}-\frac{4a^6x^5}{5}
   +\frac{a^8x^3}{3}\biggr)\bigg]_{-a}^a 
= N^4\biggl\{\biggl(\frac{a^{11}}{11}
   -\frac{4a^{11}}{9}+\frac{6a^{11}}{7}
   -\frac{4a^{11}}{5}+\frac{a^{11}}{3}\biggr)\allowbreak
   -\biggl(-\frac{a^{11}}{11}+\frac{4a^{11}}{9}
   -\frac{6a^{11}}{7}+\frac{4a^{11}}{5}
   -\frac{a^{11}}{3}\biggr)\biggr\} 
= \frac{315}{256a^9}\frac{256a^{11}}{3456}
   =\frac{35a^2}{384}
$}

\end{center}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .