How to split a very large latex line in Texmaker?

In summary: Is it a poem? In summary, the conversation revolves around the difficulty in splitting a mathematical line in LaTeX due to the presence of \left [ and \right ] parts. The suggested solution is to use the align environment from the AMS LaTeX package. However, there are errors occurring when attempting to use this solution.
  • #1
fluidistic
Gold Member
3,924
261
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 can't 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.
 
Physics news on Phys.org
  • #3
chiro said:
Hey fluidistic.

Is something like this up your alley?

http://people.oregonstate.edu/~peterseb/tex/samples/verbatim-environment.html

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.
 
  • #4
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]
 
  • #5
Yes micromass, exactly.
However it returns 4 errors:
Code:
! LaTeX Error: Environment align undefined.
Code:
! Misplaced alignment tab character &.
Code:
! Misplaced alignment tab character &.
Code:
! LaTeX Error: \begin{document} ended by \end{align}.
Thanks guys for the help so far.
 
  • #6
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]
 
  • #7
This returns:
Code:
! 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:
  • #8
fluidistic said:
Code:
! LaTeX Error: Environment align undefined.
In other words, you aren't using the AMS LaTeX package.

Use it.
 
  • #9
D H said:
In other words, you aren't using the AMS LaTeX package.

Use it.

I see. I added \usepackage{amsmath} just before the \begin{document} line.
By trying micromass's first suggestion I get the error message:
Code:
! Package amsmath Error: Erroneous nesting of equation structures;
And by trying his second suggestion I get more errors:
Code:
! 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 $$.
 
  • #10
Your error appears to result from doing something like this:
Code:
$$
\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:
\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
 
  • #11
D H said:
Your error appears to result from doing something like this:
Code:
$$
\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:
\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
Hmm what am I supposed to do with this strange-difficult looking code?
 
  • #12
Use my code, but don't put any $ in front of it and in the end.
 
  • Like
Likes 1 person
  • #13
micromass said:
Use my code, but don't put any $ in front of it and in the end.

That worked like a charm. Thanks a lot! Damn I feel stupid. XD
 
  • #14
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:
  • #16
You can choose a single line to show the equation number by putting /nonumber somewhere inside the other line.

This is archaic, and doesn't center the number, but I can't remember quickly the other way to do it I think it had to do with align.
 

Related to How to split a very large latex line in Texmaker?

1. How do I split a large latex line in Texmaker?

To split a large latex line in Texmaker, you can use the "Split Line" feature by pressing Ctrl+Enter on your keyboard. This will automatically split the line at the current cursor position and create a new line below it.

2. Can I split a large latex line into multiple lines in Texmaker?

Yes, you can split a large latex line into multiple lines in Texmaker by selecting the portion of the line that you want to split and then using the "Split Line" feature. This will create a new line with the selected portion of the line, and the remaining portion will stay on the original line.

3. Is there a limit to the length of a line in Texmaker?

Texmaker does not have a specific limit for the length of a line. However, it is recommended to keep the line length within a reasonable range to ensure readability and avoid any formatting issues.

4. Can I split a large latex line without using the "Split Line" feature?

Yes, you can manually split a large latex line in Texmaker by using the "Enter" key on your keyboard. This will create a new line and move the remaining portion of the line to the next line. However, using the "Split Line" feature is more efficient and precise.

5. How can I undo a line split in Texmaker?

To undo a line split in Texmaker, you can use the "Undo" feature by pressing Ctrl+Z on your keyboard. This will revert the line split and merge the lines back into one. You can also use the "Undo" feature multiple times to undo multiple line splits.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
526
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
979
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
11
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
Back
Top