Troubleshooting Latex: Can't Generate Multiple Lines in a Single [tex] Block?

  • Context: LaTeX 
  • Thread starter Thread starter Redbelly98
  • Start date Start date
  • Tags Tags
    Latex Line
Click For Summary

Discussion Overview

The discussion revolves around the challenges participants face when trying to generate multiple lines within a single [tex] block in LaTeX on the Physics Forums. Participants explore various methods and environments to achieve this, including the use of specific LaTeX commands and environments.

Discussion Character

  • Technical explanation, Debate/contested, Exploratory

Main Points Raised

  • Some participants express frustration that the double backslash (\\) does not work for creating new lines in [tex] blocks, suggesting it may be a bug in the forum software.
  • One participant proposes using the flalign environment as an alternative to achieve multi-line formatting, detailing how to structure the code for alignment.
  • Another participant notes that the eqnarray environment also does not display correctly on the forums.
  • Some participants mention that the [tex] tag acts like \[ in LaTeX, and using \] may break the LaTeX environment, complicating the use of new lines.
  • A participant shares a testing experience showing that removing the double backslash allows the code to display correctly, raising questions about the current functionality of LaTeX on the forum.
  • There are mentions of revisiting methods now that MathJax is being used, with some participants indicating they have found solutions or workarounds.
  • One participant shares a code snippet using the align environment, which raises questions about its output.

Areas of Agreement / Disagreement

Participants generally agree that the double backslash does not function as expected in the forum's LaTeX implementation, but there is no consensus on a definitive solution. Multiple competing views and methods are presented without resolution.

Contextual Notes

Some participants note that the behavior of LaTeX commands may depend on the specific environment provided by the forum software, and there are unresolved issues regarding the proper use of certain LaTeX environments.

Who May Find This Useful

Users interested in formatting LaTeX code on forums, particularly those seeking to create multi-line equations or expressions.

Redbelly98
Staff Emeritus
Science Advisor
Homework Helper
Insights Author
Messages
12,179
Reaction score
186
I can't seem to generate multiple lines within a single [ tex ][ /tex ] block. It's supposed to happen if I type \\ but it just never works for me.

Example:

<br /> f_1(x) = x \\ <br /> f_2(x) = 1-x^2<br />

The "f2(x)" is supposed to start on a new line.

What am I doing wrong?
 
Last edited:
Physics news on Phys.org
Redbelly98 said:
I can't seem to generate multiple lines within a single [ tex ][ /tex ] block. It's supposed to happen if I type \\ but it just never works for me.

Example:

<br /> f_1(x) = x \\ <br /> f_2(x) = 1-x^2<br />

The "f2(x)" is supposed to start on a new line.

What am I doing wrong?

Unfortunately I'm not going to be of any help to you. I've also tried this numerous times, but to the same effect.
 
I don't think that the \\ has ever worked on the forums, it must be some kind of bug in the software. However, one can start new lines using the flalign environment.

<br /> \begin{flalign*}<br /> f_1\left(x\right) &amp; = &amp; &amp; x\\<br /> f_2\left(x\right) &amp; = &amp; &amp; 1-x^2\\<br /> f_3\left(x\right) &amp; = &amp; &amp; \frac{f_1}{f_2} \\<br /> &amp; = &amp; &amp; \frac{x}{1-x^2}<br /> \end{flalign*}<br />

And the code:
Code:
\begin{flalign*}
f_1\left(x\right) & = & & x\\
f_2\left(x\right) & = & & 1-x^2\\
f_3\left(x\right) & = & & \frac{f_1}{f_2} \\
& = & & \frac{x}{1-x^2}
\end{flalign*}

The * is used to suppress line enumeration. The alignment of each element is fixed to alternate between left and right as shown below

Code:
\begin{flalign*}
right & left & right & ... \\
right & left & right & ... \\
right & left & right & ... \\
\end{flalign*}

But you can add additional & separators to obtain the desired layout, as I have done above:

Code:
\begin{flalign*}
right & left &  & left \\
right & left &  & left \\
right & left &  & left \\
\end{flalign*}

I agree that this method is far more verbose than simply using \\ is mathmode, but it is the only work-a-round that i know of for PF. Note that the eqnarray environment does not display correctly either at PF.
 
Thanks Hoot. So the &'s help line up the equal signs. And if I just wanted to left-justify each line, each line would start with a &.

Code:
      \begin{flalign*}
      & f_1(x) = x \\ 
      & f_2(x) = 1-x^2
      \end{flalign*}

I also found this previous discussion in a locked thread:
https://www.physicsforums.com/showthread.php?t=8997&highlight=latex+line&page=19

However, in chroot's examples the code uses TWO begin and TWO end statements, eg.
\begin{equation*}
\begin{split}

So the single begin statement
\begin{flalign*}
is an improvement over that.

Thanks again!

RB
 
Hootenanny said:
II don't think that the \\ has ever worked on the forums
I've never known it to work in LaTeX either. (Remember that [ itex ] ... [/itex] is analogous to $ ... $, and [ tex ] ... [/tex] is analogous to \[ ... \])
 
Hurkyl said:
I've never known it to work in LaTeX either. (Remember that [ itex ] ... [/itex] is analogous to $ ... $, and [ tex ] ... [/tex] is analogous to \[ ... \])
Hmm, you're quite right: \\ only works in array enviroments in LaTeX :redface:
 
<br /> \]<br /> This is the first line.\\<br /> This is the second line.\\<br /> This is the third line.<br /> \[<br /> E=mc^2<br /> \]<br /> This is another line.<br /> \[<br />

Click on the rendered image to see what I did.
Maybe some \LaTeX expert can explain what is going on.
I suspect that the forum software already places us in a \LaTeX environment... and these \[ \] break us out of it somehow.
 
Last edited:
robphy said:
I suspect that the forum software already places us in a \LaTeX environment... and these \[ \] break us out of it somehow.

Sounds precisely right to me: the tag acts like \[ and by typing \], you close the latex environment.
 
Now that we are using MathJax, I am revisiting how to generate multiple lines within a single LaTeX code block.

EDIT: Nevermind, I found out how to do this: https://www.physicsforums.com/showthread.php?p=261329

Also, scroll down post #1 here for multi-line examples: https://www.physicsforums.com/showthread.php?t=8997

Please disregard the following...[/color]

I just now noticed a problem with these old posts (for example Post #'s 1 and 3 above). Right now I see the LaTeX code, without the [_tex_] tags, enclosed in a box and left-right centered in the page. I have FireFox 4 and Windows 7.

Apparently MathJax doesn't like the double-backslash newline indicator, and that is preventing the code from being processed properly.

Testing:

Using same code from Post #1 again:
<br /> f_1(x) = x \\ <br /> f_2(x) = 1-x^2<br />

Same code, with double-backslash removed:
<br /> f_1(x) = x <br /> f_2(x) = 1-x^2<br />

So the question is, is it possible anymore to generate a new line within the same [_tex_] code block? Hootenanny's trick in Post #3 used to work -- not that I am advocating going back to the old LaTeX system.
 
Last edited:
  • #10
Here:
<br /> \begin{align}<br /> a &amp; b \\<br /> c &amp; d<br /> \end{align}<br />

This one gives weird results:
<br /> \begin{multline}<br /> a b \\<br /> c d<br /> \end{multline}<br />
 

Similar threads

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 12 ·
Replies
12
Views
4K
  • · Replies 16 ·
Replies
16
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 2 ·
Replies
2
Views
6K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
5
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K