I got some issues while writing a formula in LaTeX. I have to print this in my document:

\textit{P3ACM}: $ \left \langle \left \langle ( 09.00, 18.00 ) , \{ Monday, Tuesday, Wednesday, Thursady, Friday \} \right \rangle , \left \langle NOW,  24/12/11:23.59 \right \rangle \right \rangle $

but once I compile it, the formula gets off the margins used in the whole document. I just started using LaTeX so I'm not so good, would you please suggest me how to get over this problem?

migrated from stackoverflow.com Aug 31 '11 at 14:55

This question came from our site for professional and enthusiast programmers.


As @carlpett mentioned, LaTeX does not break lines in mathmode automatically. You have to tell it where to perform the breaking. And yes, extensible delimiters specified by \left and \right pairs need to be paired on the same line. A consolation is the use of \left. and \right. to be the "missing" pair on the left/right of another delimiter. However, this does not bode well if the contents between \left and \right are of different sizes between line breaks. For this, \vphantom{<stuff>} prints a zero-width rectangle with height exactly that of <stuff>. This way you can break equations the way you want to, and stretch the height of the extensible delimiters to match each other, even across lines.

A good example mixing all these ideas is contained in section 8.1.1 Braces over several lines (page 25) in Herbert Voß' mathmode document.

Alternatively, foregoing the use of extensible delimiters, you could resize delimiters using any of the following: \big, \bigg, \Big, \Bigg, or \bigl, \bigr, \Bigl, \Bigr, \biggl, \biggr, \Biggl and \Biggr from the amsmath package. Here is an example from the package documentation that highlights this:

\usepackage{amsmath}% http://ctan.org/pkg/amsmath
  \left[\sum_i a_i\left|\sum_j x_{ij}\right|^p\right]^{1/p}
  \quad \text{versus} \quad
  \biggl[\sum_i a_i\Bigl\lvert\sum_j x_{ij}\Bigr\rvert^p\biggr]^{1/p}

Different extensible delimiters

  • IIRC, the @ user notification works in comments, but not in answers. – lockstep Aug 31 '11 at 16:23
  • @lockstep: I know, but I wanted to credit some of the discussion given by @ carlpett (who won't be notified by this comment, by the way). :-| – Werner Aug 31 '11 at 16:29
  • 1
    \[bB]ig(g)?[lr]? doesn't come from the amsmath! – morbusg Jan 29 '12 at 11:32
  • @Werner: At the risk of being pedatic, the question is about inline math which TeX does break across lines automatically. There the only problem is that \left...\right constructs can't be broken. – Hendrik Vogt Jun 20 '12 at 15:03

LaTeX does not insert line breaks in mathmode, you'll have to do it manually. I'd suggest using the align environment, in which you can easily align your lines so they look nice. For instance:

    math &math math \\
    &more math

The \\ breaks the line, and LaTeX will then line up the &s.

  • so it should be something like this? \begin{align} \textit{P3ACM}: & \left \langle \left \langle ( 09.00, 18.00 ) , \{ Monday, Tuesday, Wednesday, Thursady, Friday \} \right \rangle , \& \left \langle NOW, 24/12/11:23.59 \right \rangle \right \rangle \end{align} cause it didn't work – breathe0 Aug 31 '11 at 8:16
  • What is the error? I think \textit doesn't like being in a math environment, so that might be it. Also, this will not be inline, as your original code was. If you need that, I think you'll have to manually break your code by exiting and entering math mode where you want the line break – carlpett Aug 31 '11 at 8:28
  • i took out \textit and left only \\ (no &, just to try) and the error is: "Extra }, or forgotten \right." this is the code changed: \begin{align} P3ACM: \left \langle \left \langle ( 09.00, 18.00 ) , \{ Monday, Tuesday, Wednesday, Thursady, Friday \} \right \rangle , \\ \left \langle NOW, 24/12/11:23.59 \right \rangle \right \rangle \end{align} – breathe0 Aug 31 '11 at 8:36
  • @breathe0: Ok, turns out \left and \right need to be matched per line. So add a \right. at the end of the first line, and a \left. at the beginning of the first. – carlpett Aug 31 '11 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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