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

Strange quirk with Latex

  1. Jul 11, 2008 #1
    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?
  2. jcsd
  3. Jul 11, 2008 #2


    User Avatar
    Staff Emeritus
    Science Advisor

    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.
  4. Jul 11, 2008 #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?
  5. Jul 25, 2008 #4

    Ben Niehoff

    User Avatar
    Science Advisor
    Gold Member

    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 (Text):
    \[ \sin x \] \cos x \]
    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.
  6. Jul 26, 2008 #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?
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook