Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to split a very large latex line in Texmaker?

Tags:
  1. Aug 3, 2013 #1

    fluidistic

    User Avatar
    Gold Member

    Hi guys, so I have a very large line of latex in texmaker. When i compile it icant read the right part of it. The latex code contains \left [ and \right ] part so i cant split it with $$ $$ signs. Any idea? I also noticed that i have a huge unused left margin/edge in my whole document, despite having chosen article and a4paper as document type. So fixing this problem might fix the need to split the latex line. Thank you.
     
  2. jcsd
  3. Aug 3, 2013 #2

    chiro

    User Avatar
    Science Advisor

  4. Aug 3, 2013 #3

    fluidistic

    User Avatar
    Gold Member

    Hmm I'm not really sure. Actually I realize I haven't been specific enough: I'm dealing with a mathematical line. This one:
    $$\frac{\partial ^2 P}{\partial x^2}=\frac{1}{\sqrt{2\pi t} \sigma} \left [ \frac{1}{\sigma ^2 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t} \} + \frac{(x-y)^2}{\sigma ^4 t^2} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t} \} -\frac{1}{\sigma ^2 t} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t} \} -\frac{(x+y-2B)^2}{\sigma ^4 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t} \} \right ]$$ and it gets cut in the 3rd exponential term.
    I tried to reduce the margin but the result is disastrous (it works for 0 cm margin but I can't use such a small margin!). So I really would like to split that line into 2.
     
  5. Aug 3, 2013 #4

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    Like this?

    [tex]\begin{align}
    & \frac{\partial ^2 P}{\partial x^2}=\frac{1}{\sqrt{2\pi t} \sigma} \left [ \frac{1}{\sigma ^2 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t} \} + \frac{(x-y)^2}{\sigma ^4 t^2} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t} \}\right. \\
    & \qquad \qquad \qquad \qquad \left. -\frac{1}{\sigma ^2 t} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t} \} -\frac{(x+y-2B)^2}{\sigma ^4 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t} \} \right ]
    \end{align}[/tex]
     
  6. Aug 3, 2013 #5

    fluidistic

    User Avatar
    Gold Member

    Yes micromass, exactly.
    However it returns 4 errors:
    Code (Text):
    ! LaTeX Error: Environment align undefined.
    Code (Text):
    ! Misplaced alignment tab character &.
    Code (Text):
    ! Misplaced alignment tab character &.
    Code (Text):
    ! LaTeX Error: \begin{document} ended by \end{align}.
    Thanks guys for the help so far.
     
  7. Aug 4, 2013 #6

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    What about this:

    [tex]\begin{eqnarray*}
    & & \frac{\partial ^2 P}{\partial x^2}=\frac{1}{\sqrt{2\pi t} \sigma} \left [ \frac{1}{\sigma ^2 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t} \} + \frac{(x-y)^2}{\sigma ^4 t^2} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t} \}\right. \\
    & &\qquad \qquad \qquad \qquad \left. -\frac{1}{\sigma ^2 t} \exp \{ - \frac{(x-y)^2}{2\sigma ^2 t} \} -\frac{(x+y-2B)^2}{\sigma ^4 t} \exp \{ -\frac{(x+y-2B)^2}{2\sigma ^2 t} \} \right ]
    \end{eqnarray*}[/tex]
     
  8. Aug 4, 2013 #7

    fluidistic

    User Avatar
    Gold Member

    This returns:
    Code (Text):
    ! Display math should end with 2 dollar signs.
    ! Missing $ inserted.
    ! Extra \endgroup.
    ! Display math should end with 2 dollar signs.
    ! Missing $ inserted.
    ! LaTeX Error: \begin{document} ended by \end{eqnarray*}.
    ! LaTeX Error: Too many columns in eqnarray environment.
    ! Extra alignment tab has been changed to \cr.
    ! Missing \endgroup inserted.
    And what I did was writting 2 dollar signs, then your text (copied and pasted) and then 2 dollar signs. I tried with 1 dollar sign too, but I get errors too.

    Edit: I also tried the example given in a paper about latex ($$\begin{eqnarray}\nonumber
    I_{00}&=& \frac{(2\pi)^3}{\alpha^{\prime 2}}
    \int d^6x \sqrt{-G}e^{-\Phi} \left[R_G+G^{MN}
    \partial_M\Phi\partial_N\Phi\right.\\
    && \left.-\frac{1}{12}G^{MQ}G^{NR}G^{PS}H_{MNP}H_{QRS}\right]
    \end{eqnarray}
    $$) but I get the same errors.
     
    Last edited: Aug 4, 2013
  9. Aug 4, 2013 #8

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    In other words, you aren't using the AMS LaTeX package.

    Use it.
     
  10. Aug 4, 2013 #9

    fluidistic

    User Avatar
    Gold Member

    I see. I added \usepackage{amsmath} just before the \begin{document} line.
    By trying micromass's first suggestion I get the error message:
    Code (Text):
    ! Package amsmath Error: Erroneous nesting of equation structures;
    And by trying his second suggestion I get more errors:
    Code (Text):
    ! Missing \endgroup inserted.
    ! Extra alignment tab has been changed to \cr.
    ! LaTeX Error: Too many columns in eqnarray environment.
    ! LaTeX Error: \begin{document} ended by \end{eqnarray*}.
    ! Missing $ inserted.
    ! Display math should end with $$.
    ! Extra \endgroup.
    ! Missing $ inserted.
    ! Display math should end with $$.
     
  11. Aug 4, 2013 #10

    D H

    User Avatar
    Staff Emeritus
    Science Advisor

    Your error appears to result from doing something like this:
    Code (Text):
    $$
    \begin{align}<code omitted>\end{align}
    $$
    Don't do that. The align environment is a top-level command. You can't use it in math mode.

    Don't use $$, period. That's a plain TeX rather than LaTeX command. Until you can understand why this plain TeX code yields the Twelve Days of Christmas, it's best to steer clear of plain TeX:
    Code (Text):
    \let~\catcode~`76~`A13~`F1~`j00~`P2jdefA71F~`7113jdefPALLF
    PA''FwPA;;FPAZZFLaLPA//71F71iPAHHFLPAzzFenPASSFthP;A$$FevP
    A@@FfPARR717273F737271P;ADDFRgniPAWW71FPATTFvePA**FstRsamP
    AGGFRruoPAqq71.72.F717271PAYY7172F727171PA??Fi*LmPA&&71jfi
    Fjfi71PAVVFjbigskipRPWGAUU71727374 75,76Fjpar71727375Djifx
    :76jelse&U76jfiPLAKK7172F71l7271PAXX71FVLnOSeL71SLRyadR@oL
    RrhC?yLRurtKFeLPFovPgaTLtReRomL;PABB71 72,73:Fjif.73.jelse
    B73:jfiXF71PU71 72,73:PWs;AMM71F71diPAJJFRdriPAQQFRsreLPAI
    I71Fo71dPA!!FRgiePBt'el@ lTLqdrYmu.Q.,Ke;vz vzLqpip.Q.,tz;
    ;Lql.IrsZ.eap,qn.i. i.eLlMaesLdRcna,;!;h htLqm.MRasZ.ilk,%
    s$;z zLqs'.ansZ.Ymi,/sx ;LYegseZRyal,@i;@ TLRlogdLrDsW,@;G
    LcYlaDLbJsW,SWXJW ree @rzchLhzsW,;WERcesInW qt.'oL.Rtrul;e
    doTsW,Wk;Rri@stW aHAHHFndZPpqar.tridgeLinZpe.LtYer.W,:jbye
     
  12. Aug 4, 2013 #11

    fluidistic

    User Avatar
    Gold Member

    Hmm what am I supposed to do with this strange-difficult looking code?
     
  13. Aug 4, 2013 #12

    micromass

    User Avatar
    Staff Emeritus
    Science Advisor
    Education Advisor
    2016 Award

    Use my code, but don't put any $ in front of it and in the end.
     
  14. Aug 4, 2013 #13

    fluidistic

    User Avatar
    Gold Member

    That worked like a charm. Thanks a lot! Damn I feel stupid. XD
     
  15. Aug 4, 2013 #14

    fluidistic

    User Avatar
    Gold Member

    By the way is there a way I can number such an equation? Apparently if I had used .\begin{equation} .\end{equation} the numbering would have been automatic.
    However there's no numbering when I use .\begin{eqnarray*} .\end{eqnarray*}. (without the dots of course)
    Edit: Removing the * signs in {eqnarray*} produces 2 numbering for each line of the single equation and the numbers are not placed enough on the right side (the (1) and (2) are basically placed inside the equation)
     
    Last edited: Aug 4, 2013
  16. Aug 5, 2013 #15

    Pythagorean

    User Avatar
    Gold Member

  17. Aug 20, 2013 #16

    Hepth

    User Avatar
    Gold Member

    You can choose a single line to show the equation number by putting /nonumber somewhere inside the other line.

    This is archaic, and doesnt center the number, but I can't remember quickly the other way to do it I think it had to do with align.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to split a very large latex line in Texmaker?
  1. Line breaks in Latex (Replies: 1)

  2. Line Spacing in Latex (Replies: 4)

  3. Double Line in LaTeX (Replies: 7)

Loading...