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

In summary, the conversation discusses the function of the "\]" in a Latex formula and how it affects the formatting of the equation. It is speculated that Physics Forums' Latex engine works by inserting the user's formula into a skeleton .tex document and that typing "\]" in the formula ends the displaymath environment, causing the equation to be evaluated in a text environment. However, there is confusion as to why the font for the "\cos" is displayed differently than the "x".
  • #1
kazimir82
4
0
Check this formula:

[tex]\sin(x) \] \cos(x)[/tex]

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
  • #2
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.
 
  • #3
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?
 
  • #4
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.
 
  • #5
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?
 

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

What is a Latex Bug?

A Latex Bug refers to a coding error or glitch in the Latex language, specifically in the formatting of mathematical equations. These bugs can cause unexpected or incorrect results when typesetting equations.

How does the Latex Bug affect indentation with \sin(x) \] \cos(x)?

The Latex Bug with indentation occurs when using the \sin(x) and \cos(x) functions within a set of brackets (\[ \]). The bug causes the indentation of the equation to be incorrect, leading to an uneven or misaligned display of the equation.

Is there a workaround for the Latex Bug with \sin(x) \] \cos(x)?

Yes, there is a workaround for this bug. Instead of using \sin(x) and \cos(x) within the brackets, you can use their equivalent commands \sin{ x } and \cos{ x } outside of the brackets. This will result in the correct indentation of the equation.

Are there any other known Latex Bugs related to equation formatting?

Yes, there are several known Latex Bugs related to equation formatting. These include issues with spacing, alignment, and incorrect display of symbols. It is always recommended to check for any known bugs before typesetting equations in Latex.

How can I report a Latex Bug?

If you encounter a Latex Bug, you can report it to the Latex community by posting on their official forum or submitting a bug report on their GitHub page. Make sure to include a detailed description of the bug and any relevant code or examples for the developers to troubleshoot.

Similar threads

Replies
8
Views
2K
Replies
11
Views
6K
Replies
4
Views
2K
Replies
12
Views
2K
Replies
9
Views
2K
Replies
45
Views
10K
Replies
2
Views
2K
Replies
1
Views
4K
Replies
7
Views
3K
Back
Top