Not signed in (Sign In)

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

  1.  

    Please use this thread to discuss LaTeX hacks used on MO 1.0 that may break upon transition to MO 2.0.

    • You can use the sandbox to test things out on MO 2.0.

    • You can also use our fakesite to test things out on MO 1.0 without disrupting the main site.

    In another thread, Emil J pointed out that the "backticks hack" that is frequently used on MO 1.0 will not work on MO 2.0. This problem has already been corrected in the sandbox.

  2.  

    It's common to use \\{...\\} for sets on MO. This will not work on MO 2.0 where \{...\} can be used instead. (Of course, \lbrace...\rbrace works fine on both MO1.0 and MO2.0.)

    • CommentAuthorHarry Gindi
    • CommentTimeAug 17th 2012 edited
     

    Here are some good hacks for comments that still work:

    To get a newline, add the TeX $$ $$
    To get around the character minimum, add the TeX $ \hskip 0 em $ (verbatim). This is exactly 15 characters and allows the posting of empty comments.

  3.  

    Another hack around the minimal number of characters is ${}{}{}{}{}{}{}{}{}$ (or so), or $\phantom{things that will not be rendered}$.

  4.  

    There's simpler ways of doing that! We don't have MathJaX on TeX-SX and yet I managed this answer.

    • CommentAuthorHarry Gindi
    • CommentTimeAug 17th 2012 edited
     

    @Andrew: The stuff you can do in comments is quite a bit more limited, as far as I can remember. For instance, you can't include any kind of nontrivial markdown or html junk. Also, linebreaks in comments have to use LaTeX, I believe.

  5.  
    The length checks we have in place are nothing more than a toddler barrier to try and promote the proper behavior of posting something of value - we are aware there are infinite ways of bypassing these checks.

    As far as the \\{ sets example - could you post links to actual posts in the sandbox where rendering has failed?
  6.  

    Geoff, I think we need Davide's word on this.

    I believe that for $ environment \\{ might work, but in $$ the double \\ is translated to a new line, and then the { breaks off completely.

    • CommentAuthorHarry Gindi
    • CommentTimeAug 17th 2012 edited
     

    @Andrew, I can't figure out for the life of me how you got that through. I was able to get something like "Yes ." to post, but I couldn't get it without a space.

    Edit: Ah, tricky. Using an invisible unicode character with 0 width. I got it to work with U+FEFF, but my hex editor says that you did it with U+200B

  7.  

    As long as we're talking about MO LaTeX oddities, it would be great if we could use \[ ... \] for displayed math, as an alternative to $$ ... $$.

    I've never used $$ for displays except on MO and the n-Category Café: all the actual LaTeX I write uses \[ ... \]. Indeed, I thought that was the approved LaTeX way of doing things: I don't think Lamport's book even mentions the possibility of using $$. (Is it some leftover from plain TeX?) I'd been using LaTeX for about ten years before I ever heard of the double dollar.

    Although I'm now used to having to do this differently for MO, and rarely forget, it tripped me up at first, and I imagine it will continue to trip up newcomers until it's fixed.

    • CommentAuthorHarry Gindi
    • CommentTimeAug 17th 2012 edited
     

    @Tom: I think that collides with markdown's syntax. It seems unlikely that SE will break markdown in order to implement that. I mean, we'd probably end up with something very nasty like $\[........ \]$

  8.  

    Geoff, there is an example here.

    In case that wasn't clear, the way that the sandbox interprets \\{ is the correct one. The way this works on MO now is that markdown interprets \\ and feeds \{ to mathjax. (In particular, \{ does work when backticks are used.)

  9.  

    I'd been using LaTeX for about ten years before I ever heard of the double dollar.

    If you learned LaTeX the way I think most of us did (reverse-engineering other people's .tex files), then you must have had better examples than I did. I'd been using LaTeX for about ten years before I ever heard of \[...\].

  10.  

    Ah, no, I learned Latex by reading Lamport's book. Deviant, I know. Anyway, (1) there are clearly people (e.g. me) for whom $$ is an oddity, and (2) Harry's explanation suggests there's little we can do about it.

  11.  
    >Is it some leftover from plain TeX?

    No, $$ is not a leftover from Plain TeX, it's a basic feature of TeX (hence Plain TeX and LaTeX).
    The precise relationship between \[ and $$ can be easily understood from the definition of \[ and \] in the file ltmath.dtx:

    (Sorry, due to a bug in meta.MO engine the initial spaces are suppressed, making the text less readable.)

    \def\[{%
    \relax\ifmmode
    \@badmath
    \else
    \ifvmode
    \nointerlineskip
    \makebox[.6\linewidth]{}%
    \fi
    $$%%$$ BRACE MATCH HACK
    \fi
    }

    \def\]{%
    \relax\ifmmode
    \ifinner
    \@badmath
    \else
    $$%%$$ BRACE MATCH HACK
    \fi
    \else
    \@badmath
    \fi
    \ignorespaces
    }

    Thus we immediately see the nonsyntactic difference between \[ and $$:

    \nointerlineskip
    \makebox[.6\linewidth]{}

    This results in a slightly bigger space before \[ if it occurs in vertical mode, e.g., starts a new paragraph
    and the formula itself is short enough to trigger the standard \aboveshortdisplayskip mechanism,
    which makes the vertical spacing shorter if a displayed formula does not overlap with the above text.

    Given the fact that displayed formulas seldom start a new paragraph while simultaneously being short enough
    as not to overlap with the above text, you are unlikely to ever encounter any difference between \[ and $$.

    Furthermore, in case there is a difference, the behavior of $$ is actually correct, unlike that of \[, which doesn't make any sense and can be considered a bug.

    Finally, amsmath fixes LaTeX's buggy behavior, so in case you use amsmath there is no difference in spacing.
  12.  
  13.  
    @Mark Meckes: One has to be extremely careful with these answers on TeX.SE.
    The top answer says the spacing is wrong, but it's wrong when you use \[, not $$!
  14.  

    Dmitri, I think it's unfair to say that either one is right or wrong. (They both work as intended.)

    The difference can be appreciated by typesetting the following in a plain article (without loading any packages).

    This part of the document is to test a
    \[very\ long\ displayed\ equation\ surrounded\ by\ square\ brackets\]
    without breaking the paragraph.
    
    This part of the document is to test a
    
    \[very\ long\ displayed\ equation\ surrounded\ by\ square\ brackets\]
    breaking the paragraph above but not below.
    
    This part of the document is to test a
    $$very\ long\ displayed\ equation\ surrounded\ by\ double\ dollar\ signs$$
    without breaking the paragraph.
    
    This part of the document is to test a
    
    $$very\ long\ displayed\ equation\ surrounded\ by\ double\ dollar\ signs$$
    breaking the paragraph above but not below.
    

    I think the outcome is an important lesson in LaTeX: Make sure you actually mean to start a new paragraph wherever you have a blank line.

    Another advantage of \[...\] over $$...$$ is that the first has distinct begin/end symbols while the second is ambiguous.

  15.  

    There is a great possibility that some matrix code from MO 1.0 will have issues in MO 2.0. On MO 1.0, \\\\ must be used instead of \\ to separate rows (unless the backtick hack is used) whereas \\ can be used as usual in MO 2.0. When migrated, the first \\ will create an extra blank row between the two matrix rows. (Example here)

    Posts that use \cr as a replacement for \\ will be unharmed. This issue may also affect other types of tables: definition by cases, split equations, etc.

  16.  

    @François: The second part of your example demonstrates the bug very clearly: even though you started a new paragraph, LaTeX still treats it as the same paragraph, at least in terms of vertical space. So it does not work as expected.

    Make sure you actually mean to start a new paragraph wherever you have a blank line.

    My point exactly.

    Another advantage of \[...\] over $$...$$ is that the first has distinct begin/end symbols while the second is ambiguous.

    Why is this an advantage? Brackets are perfectly legitimate mathematical symbols, whereas dollar signs are not. With the \[\] notation I find myself constantly confused, because I have to decide whether the brackets belong to the formula or are simply delimiters. The fact that \{\} typesets ordinary braces (very much unlike \[\]) is not very helpful either.

  17.  

    Maybe this discussion has veered off topic. I only wanted to point out that having to use $$ ... $$ rather than \[ ... \] is a peculiarity of Latex at MO, and causes confusion and inconvenience to some new users of MO.

    It's not exactly a "hack" (to quote François's opening message), but it's one of the ways in which MO Latex differs from ordinary Latex, and it's therefore something we might usefully keep in mind when negotiating the transition to 2.0.

  18.  

    Tom, your suggestion has been recorded! I believe Harry is correct so we may be unable to add this option for technical reasons. However, if we can't make that happen, we will try to make LaTeX instructions clearer so that users know to use $$...$$ rather than \[...\] for displayed equations.

  19.  

    Thanks, François. That sounds good.

  20.  

    I'm a bit hesitant at posting further in this thread as I have no real desire to get shouted at.

    1. One of the great things about a Q&A site is that when someone doesn't understand an answer, they can ask a fresh question and get further explanation. So when someone read the question that Mark linked to and felt that they needed further clarification, instead of dismissing the entire site with a pointless comment, they asked a fresh question: http://tex.stackexchange.com/q/21173/86 and got a more detailed answer.

    2. MathJaX is not (La)TeX and expecting it to behave like it is breaking the bounds of reason. TeX can do so much more than MathJaX. The best thing people can do to stop others getting confused is to stop referring to it as LaTeX. We get questions about MathJaX on TeX-SX and they are closed as "off topic" because the underlying engines are so different that expertise in TeX does not help one at all in helping solve the typical problems one encounters in MathJaX.

    3. @Geoff: Don't spoil our fun. If you didn't leave us these little puzzles to solve then we'd end up being more disruptive out of boredom so it's in your own interest not to belittle our efforts.

  21.  

    Andrew, re your first sentence in point 2, I'm sure you're right; you know much more about these things than I do. But the fact remains that almost all of us (I guess) who write answers on MO know nothing explicitly about Mathjax: we simply write Latex, and learn by experience which bits of Latex MO can't handle.

    In other words, we do expect Mathjax to behave like Latex. (That's "like", not "identically to".) Indeed, we're encouraged to do so: when you ask a question, the first sentence of the prominently-displayed help is "You can just type LaTeX formulas between dollar signs!" And I think most of us here operate successfully on the principle that MO-Latex is a scaled-down version of normal Latex, with some added peculiarities. Whether or not that's breaking the bounds of reason, I think that's how most of us do it, and it usually works.

  22.  

    "You can just type LaTeX formulas between dollar signs!"

    And that's what should be changed to avoid the "But I can do it in LaTeX" attitude. The problem is that most probably do not distinguish between "like" and "identical[ly] to". It's those peculiarities that catch people out and if there's a big notice saying "This site uses MathJaX to display equations" with a link to a help text of what you can and can't do, it would make it easier for people to realise that MathJaX is not LaTeX but very similar.