Latex Bug: Indentation with \sin(x) \] \cos(x)

  • Context: LaTeX 
  • Thread starter Thread starter kazimir82
  • Start date Start date
  • Tags Tags
    Latex Strange
Click For Summary

Discussion Overview

The discussion revolves around an issue with LaTeX formatting, specifically regarding the use of the \] command in the expression \sin(x) \] \cos(x). Participants explore whether this behavior is a bug in the LaTeX formula generator used by the forum.

Discussion Character

  • Technical explanation, Debate/contested

Main Points Raised

  • One participant notes that the \] command appears to cause strange indenting for \sin(x) and questions if this is a bug in the LaTeX generator.
  • Another participant expresses uncertainty about the purpose of the \] command, stating that it typically ends the equation environment in standard LaTeX, but may not be applicable in the forum's LaTeX implementation.
  • A different participant shares that they discovered the issue accidentally and suggests that LaTeX should either display the \] or ignore it, questioning if it has an undocumented function.
  • One participant describes their own LaTeX solution for a website, hypothesizing that the forum's LaTeX engine processes formulas similarly, which could lead to the \] ending the displaymath environment and causing the indentation issue.
  • Another participant challenges the previous explanation, noting that \cos(x) is displayed in a different font, suggesting that the LaTeX engine might be interpreting the input differently than expected.

Areas of Agreement / Disagreement

Participants express differing views on the cause of the issue, with no consensus reached regarding whether it is a bug or a result of the LaTeX engine's behavior.

Contextual Notes

There is uncertainty regarding the specific behavior of the LaTeX engine in the forum, particularly how it handles the \] command and its impact on formatting.

kazimir82
Messages
4
Reaction score
0
Check this formula:

\sin(x) \] \cos(x)

The \] there (click formula for source) seems to cause some strange indenting for sin(x). Is this a bug in the Latex formula generator?
 
Physics news on Phys.org
I have no idea. What are you trying to use the \] for? In normal latex this ends the equation environment, but I don't think it is enabled in our forum latex.
 
Not using the \] for any particular reason here, I discovered this by accident. Just wondering how this can happen. I'd say Latex should either display the bracket (just like \} displays a curly bracket) or display nothing at all (like anything unknown with a backslash in front of it).

Or does the \] have some undocumented function?
 
I'm writing a Latex solution for my own website, and the way mine works is that it takes the user's formula, sticks it in a skeleton .tex document inside \[ and \] tags, and then processes that file to produce the image.

My guess is that Physics Forums' Latex engine works in a similar fashion. In that case, typing a '\]' in your formula will cause the skeleton .tex file to look like this:

Code:
\preamble
\[ \sin x \] \cos x \]
\postamble

So, as you see, the '\]' you typed ended the displaymath environment, causing the '\cos x' to be evaluated in a text environment. Ordinarily, displaymath is indented relative to the surrounding text. This is what happened; your 'sin x' is indented, and 'cos x' begins a new paragraph in the text environment.
 
That isn't quite what is happening (though I don't know what is) since the cos is displayed in mathrm font and the x is in the math font. Perhaps the engine is guessing that this ought to be in a math environment?
 

Similar threads

  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 11 ·
Replies
11
Views
9K
  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 9 ·
Replies
9
Views
3K
  • · Replies 45 ·
2
Replies
45
Views
11K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 7 ·
Replies
7
Views
3K