Basically same as Formatting Sandbox in Meta Stack Exchange, but since this and Statistical Analysis are the only two sites (I know) supporting $\TeX$ formatting, I believe we also need one here for testing it.

Theoretical computer science also supports $\mathrm{\TeX/\LaTeX}$ formatting. – JeffE Jun 1 '12 at 7:29
@JeffE: You can use $\TeX$ and $\LaTeX$ (\Tex and \LaTeX) for the text. – Asaf Karagila Jun 2 '12 at 21:09
@JeffE: In 2010 only 'stats' and 'math' support TeX formatting. Of course now there is also 'cstheory', 'cs', 'chemistry', 'quant', etc. – kennytm Jun 3 '12 at 6:25
test $$\begin{align*}\text{middle line}\end{align*}$$ new line – Ruslan Jan 30 '14 at 13:06
test test $\not\in(1)\notin(2)$ Who's better??? – user93957 Jan 31 '14 at 22:25
$m^n + m^x + m^n = 555555$ test test – hichris123 Feb 2 '14 at 19:09
line $\begin{array}\phantom{i}\\\phantom{i} \end{array} $ line2 – Bill Dubuque Apr 18 '14 at 15:15
// ..... \\ – ahorn Oct 24 '14 at 9:47

35 Answers 35

up vote 17 down vote accepted

A suggestion: if you want to see you TeX previewed, pretend to type your question/answer. Then wait for 4 seconds. We have on the fly previewing for LaTeX here. This way we don't keep popping this question to the top of meta.

May be this (and the main sandbox) should be made special unbumpable question? – Vi0 Aug 24 '12 at 15:06
Except that there's no preview for comments. – shoover Sep 24 '14 at 18:22

Testing alternate way of implementing spoiler

$$ \require{action} \require{enclose} \toggle{ x\cdot 0 = 0\quad\enclose{roundedbox}{\text{ Click this for derivation }} }{ \begin{array}{rll} x\cdot 0 &= \mathtip{x\cdot 0 + 0}{0 \text{ is additive identity}} \\ &= \mathtip{x\cdot 0 + (x\cdot 0 + -(x\cdot 0))}{ -(x\cdot 0) \text{ is additive inverse of } x\cdot 0}\\ &= \mathtip{(x\cdot 0 + x\cdot 0) + -(x\cdot 0)}{ \text{ addition is associative }\;}\\ &= \mathtip{x\cdot(0 + 0) + -(x\cdot 0) }{ \text{ mulitplication is distributive }\;}\\ &= \mathtip{x\cdot 0 + -(x\cdot 0) }{ 0 \text{ is additive identity}} \\ &= \mathtip{0}{ -(x\cdot 0) \text{ is additive inverse of } x\cdot 0} \end{array} \quad\quad \bbox[4pt,border: 1px solid red]{ \begin{array}{l} \text{If you cannot figure out why a line}\\ \text{is true, move your mouse over}\\ \text{RHS of that line for hint.} \end{array}} }\endtoggle $$

This test uses the MathJAX extension Action, Enclose and BBox. The BBox seems to be automatically loaded. To use Action and Enclose. put \require{action} and require{enclose} somewhere between the $$.

  • the \enclose{roundedbox}{...} draws a rounded text around ....
  • the \texttip{math}{tip} and \mathtip{math}{tip} add a tooltip tip to a piece of math. The difference between textip and mathtip is the tip will be rendered in text and math mode respectively.
  • the \bbox[4pt,border: 1px outset red]{...} draws a red border with 4pt as padding around a piece of ...


  • toggle works properly.
  • even tooltip works, sometimes it doesn't go away properly.
  • missing a good construct to put multi-line text in math mode. \parbox doesn't work???

Fulling list of above test given below.

$$ \require{action} \require{enclose} \toggle{ x\cdot 0 = 0\quad\enclose{roundedbox}{\text{ Click this for derivation }} }{ \begin{array}{rll} x\cdot 0 &= \mathtip{x\cdot 0 + 0}{0 \text{ is additive identity}} \\ &= \mathtip{x\cdot 0 + (x\cdot 0 + -(x\cdot 0))}{ -(x\cdot 0) \text{ is additive inverse of } x\cdot 0}\\ &= \mathtip{(x\cdot 0 + x\cdot 0) + -(x\cdot 0)}{ \text{ addition is associative }\;}\\ &= \mathtip{x\cdot(0 + 0) + -(x\cdot 0) }{ \text{ mulitplication is distributive }\;}\\ &= \mathtip{x\cdot 0 + -(x\cdot 0) }{ 0 \text{ is additive identity}} \\ &= \mathtip{0}{ -(x\cdot 0) \text{ is additive inverse of } x\cdot 0} \end{array} \quad\quad \bbox[4pt,border: 1px solid red]{ \begin{array}{l} \text{If you cannot figure out why a line}\\ \text{is true, move your mouse over}\\ \text{RHS of that line for hint.} \end{array}} }\endtoggle $$


This is a 1e1ea2ce-0342-4835-a7cc-ee70fbdfe27d

[Click on this][1] [1]:… – ahorn Mar 29 '15 at 14:42
How do I create a hyperlink in a comment? – ahorn Mar 29 '15 at 14:43
@ahorn: Test. Put the link text in square brackets, and the link in normal brackets, like this: [text](link) – Aryabhata Mar 29 '15 at 15:44

$\hskip -3em \color{red}{\Rule{2em}{1em}{1em}}$Testing of negative skips to overlap the buttons on the left.

\rlap{\smash{\lower 3em{\color{red}{\Rule{8em}{2em}{0em}}}}}

Testing overlapping on the bottom. OK, both seem to be problems.

a comment with overlaps $\rlap{\color{red}{\Rule{10em}{1em}{0.5em}}}$ – Davide Cervone Jun 14 '12 at 21:56
The extension linked to this answer can be used to improve the situation. – Davide Cervone Jun 14 '12 at 22:00
$\rlap{\color{grey}{\Rule{200em}{1em}{0.75em}}}$ – user93957 Jan 7 '14 at 13:01

How does newcommand and renewcommand work?

$$\newcommand{\sin}{FOO} \sin x$$

$$\sin y$$

$$\renewcommand{\nonexistent}{QUX} \nonexistent$$




And now what does it look like to another user who doesn't suspect that the command has been redefined?

$$\sin x$$

Very interesting.

Oh wow - that is interesting. How does one clear newcommands? – mixedmath Jun 1 '12 at 7:07
@mixedmath: See… – Nate Eldredge Jun 1 '12 at 13:17

Testing spoiler:

Without newlines:

$$\lim_{x \rightarrow \infty} \dfrac{\ln(x^2+4)}{\ln(x+\sqrt{1+x^2})} = \lim_{x \rightarrow \infty} \dfrac{\ln(x^2) + \ln(1+4/x^2)}{\ln(x) + \ln(1+\sqrt{1+1/x^2})}$$ $$ = \lim_{x \rightarrow \infty} \dfrac{\ln(x^2)}{\ln(x)} \dfrac{\left(1+\dfrac{\ln(1+4/x^2)}{\ln(x^2)} \right)}{\left(1 + \dfrac{\ln(1+\sqrt{1+1/x^2})}{\ln(x)} \right)}$$ $$ = \lim_{x \rightarrow \infty} 2 \dfrac{\ln(x)}{\ln(x)} \lim_{x \rightarrow \infty} \dfrac{\left(1+\dfrac{\ln(1+4/x^2)}{\ln(x^2)} \right)}{\left(1 + \dfrac{\ln(1+\sqrt{1+1/x^2})}{\ln(x)} \right)}$$ $$ = 2 \lim_{x \rightarrow \infty} \dfrac{\left(1+\dfrac{\ln(1+4/x^2)}{\ln(x^2)} \right)}{\left(1 + \dfrac{\ln(1+\sqrt{1+1/x^2})}{\ln(x)} \right)} =2 $$

With newlines:

! $$\lim_{x \rightarrow \infty} \dfrac{\ln(x^2+4)}{\ln(x+\sqrt{1+x^2})} = \lim_{x \rightarrow \infty} \dfrac{\ln(x^2) + \ln(1+4/x^2)}{\ln(x) + \ln(1+\sqrt{1+1/x^2})}\\ = \lim_{x \rightarrow \infty} \dfrac{\ln(x^2)}{\ln(x)} \dfrac{\left(1+\dfrac{\ln(1+4/x^2)}{\ln(x^2)} \right)}{\left(1 + \dfrac{\ln(1+\sqrt{1+1/x^2})}{\ln(x)} \right)}\\ = \lim_{x \rightarrow \infty} 2 \dfrac{\ln(x)}{\ln(x)} \lim_{x \rightarrow \infty} \dfrac{\left(1+\dfrac{\ln(1+4/x^2)}{\ln(x^2)} \right)}{\left(1 + \dfrac{\ln(1+\sqrt{1+1/x^2})}{\ln(x)} \right)}\\ = 2 \lim_{x \rightarrow \infty} \dfrac{\left(1+\dfrac{\ln(1+4/x^2)}{\ln(x^2)} \right)}{\left(1 + \dfrac{\ln(1+\sqrt{1+1/x^2})}{\ln(x)} \right)} =2 $$

I was trying this here because of the problems the poster had with this answer. – Martin Sleziak Jun 1 '12 at 9:51
this is a test. – ahorn Mar 30 '15 at 9:20
AHA! Martin's name did not appear when I tagged him! – ahorn Mar 30 '15 at 9:21
@ahorn See… and other related threads. (BTW I think that the correct word in this context is to ping and not to tag.) And if you are wonrdering, the notification from your comment reached me. – Martin Sleziak Mar 30 '15 at 9:36


I am testing whether there are any uses of the #rrggbb color notation to represent usefully distinguishable colors. Certainly $\col{#d10000}$ is distinguishable from $\col{#df0000}$, but the former is indistinguishable from $\col{#d00}$ and the latter from $\col{#e00}$.


$$ \col{#000}\col{#080000}\col{#100}\\ \col{#100}\col{#190000}\col{#200}\\ \col{#200}\col{#2a0000}\col{#300}\\ \col{#300}\col{#3b0000}\col{#400}\\ \col{#400}\col{#4c0000}\col{#500}\\ \col{#500}\col{#5d0000}\col{#600}\\ \col{#600}\col{#6e0000}\col{#700}\\ \col{#700}\col{#7f0000}\col{#800}\\ \col{#800}\col{#900000}\col{#900}\\ \col{#900}\col{#a10000}\col{#a00}\\ \col{#a00}\col{#b20000}\col{#b00}\\ \col{#b00}\col{#c30000}\col{#c00}\\ \col{#c00}\col{#d40000}\col{#d00}\\ \col{#d00}\col{#e50000}\col{#e00}\\ \col{#e00}\col{#f60000}\col{#f00}\\ $$


$$ \col{#000}\col{#080800}\col{#110}\\ \col{#110}\col{#191900}\col{#220}\\ \col{#220}\col{#2a2a00}\col{#330}\\ \col{#330}\col{#3b3b00}\col{#440}\\ \col{#440}\col{#4c4c00}\col{#550}\\ \col{#550}\col{#5d5d00}\col{#660}\\ \col{#660}\col{#6e6e00}\col{#770}\\ \col{#770}\col{#7f7f00}\col{#880}\\ \col{#880}\col{#909000}\col{#990}\\ \col{#990}\col{#a1a100}\col{#aa0}\\ \col{#aa0}\col{#b2b200}\col{#bb0}\\ \col{#bb0}\col{#c3c300}\col{#cc0}\\ \col{#cc0}\col{#d4d400}\col{#dd0}\\ \col{#dd0}\col{#e5e500}\col{#ee0}\\ \col{#ee0}\col{#f6f600}\col{#ff0}\\ $$


$$ \col{#000}\col{#000800}\col{#010}\\ \col{#010}\col{#001900}\col{#020}\\ \col{#020}\col{#002a00}\col{#030}\\ \col{#030}\col{#003b00}\col{#040}\\ \col{#040}\col{#004c00}\col{#050}\\ \col{#050}\col{#005d00}\col{#060}\\ \col{#060}\col{#006e00}\col{#070}\\ \col{#070}\col{#007f00}\col{#080}\\ \col{#080}\col{#009000}\col{#090}\\ \col{#090}\col{#00a100}\col{#0a0}\\ \col{#0a0}\col{#00b200}\col{#0b0}\\ \col{#0b0}\col{#00c300}\col{#0c0}\\ \col{#0c0}\col{#00d400}\col{#0d0}\\ \col{#0d0}\col{#00e500}\col{#0e0}\\ \col{#0e0}\col{#00f600}\col{#0f0}\\ $$


$$ \col{#000}\col{#000008}\col{#001}\\ \col{#001}\col{#000019}\col{#002}\\ \col{#002}\col{#00002a}\col{#003}\\ \col{#003}\col{#00003b}\col{#004}\\ \col{#004}\col{#00004c}\col{#005}\\ \col{#005}\col{#00005d}\col{#006}\\ \col{#006}\col{#00006e}\col{#007}\\ \col{#007}\col{#00007f}\col{#008}\\ \col{#008}\col{#000090}\col{#009}\\ \col{#009}\col{#0000a1}\col{#00a}\\ \col{#00a}\col{#0000b2}\col{#00b}\\ \col{#00b}\col{#0000c3}\col{#00c}\\ \col{#00c}\col{#0000d4}\col{#00d}\\ \col{#00d}\col{#0000e5}\col{#00e}\\ \col{#00e}\col{#0000f6}\col{#00f}\\ $$


$$ \col{#000}\col{#080808}\col{#111}\\ \col{#111}\col{#191919}\col{#222}\\ \col{#222}\col{#2a2a2a}\col{#333}\\ \col{#333}\col{#3b3b3b}\col{#444}\\ \col{#444}\col{#4c4c4c}\col{#555}\\ \col{#555}\col{#5d5d5d}\col{#666}\\ \col{#666}\col{#6e6e6e}\col{#777}\\ \col{#777}\col{#7f7f7f}\col{#888}\\ \col{#888}\col{#909090}\col{#999}\\ \col{#999}\col{#a1a1a1}\col{#aaa}\\ \col{#aaa}\col{#b2b2b2}\col{#bbb}\\ \col{#bbb}\col{#c3c3c3}\col{#ccc}\\ \col{#ccc}\col{#d4d4d4}\col{#ddd}\\ \col{#ddd}\col{#e5e5e5}\col{#eee}\\ \col{#eee}\col{#f6f6f6}\col{#fff}\\ $$

Conclusion: on a typical LCD monitor, a half-step (#08) is perceptible in the lighter colors, but not in the darker ones. Even a full step (#11) is too small to be useful for distinguishing different text in a post on this web site.

Note that whether or not those colors are distinguishable depends upon the capabilities of the monitor and graphics system. Most consumer level displays have limited capabilities (8-bit,low gamut). For some discussion see e.g. here. – Bill Dubuque Jan 16 '14 at 1:47
#00e means #0000ee not #0000e0. – kennytm Jan 16 '14 at 8:12
@KennyTM Thanks! Of course it must be so, or else #FFF wouldn't be white. Thanks for pointing this out. – MJD Jan 16 '14 at 14:13
@Bill That is interesting, but not relevant to the issue of mathematical typesetting on this web site. – MJD Jan 16 '14 at 15:32
@MJD Sure it is. You are attempting to judge if color differences are perceptible on MSE. My point is that it is very difficult to accurately judge that unless one has professional-level graphics hardware and specialized knowledge in this area. For example, what you see as different may display the same to someone else using a monitor with less capability (e.g. one using dithering/interpolation from 8bit to 10bit color). – Bill Dubuque Jan 16 '14 at 15:48
I am trying to judge if color differences are usefully different. For example, you are fond of using colored text to highlight parts of equations, as here. The fact that $\color{#0000c3}{\text{#0000c3}}$ might be distinguishable from $\color{#0000cc}{\text{#0000cc}}$ on a professional-quality wide-gamut monitor is of absolutely no use to you in doing that. – MJD Jan 16 '14 at 15:52
My goal in writing this post was to decide if I should mention the #rrggbb notation in this post about typesetting colors, in addition to the #rgb notation. My conclusion is that there is no need to do that. – MJD Jan 16 '14 at 15:55
$\rlap{\color{#000}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#010}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#020}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#030}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#040}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#050}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#060}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#070}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#080}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#090}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#0a0}{\Rule{200em}{1em}{0.75em}}}\\ \rlap{\color{#0b0}{\Rule{200em}{1em}{0.75em}}}\\ $ – user93957 Jan 31 '14 at 22:29

Let me try if there is a difference between single dollar signs $\sum_{i = 0}^n k^i$ and double dollar signs $$\sum_{i = 0}^n k^i$$

You can always use this: $\sum\limits_{i = 0}^n k^i$ – Quixotic Sep 19 '11 at 20:12

$\hskip 36em {\require{cancel}\require{cancelto} _\text{psst! over here!}\cancelto{\hspace{1pt}}{\hspace{20pt}}}$


Move your mouse around each symbol to know which font was used:

$$\require{action} \overset{\rlap{\overset{\,{\rlap{\overset{\overset{\overset{\color{red}{\rlap{\color{\green}{\,\,\star}}{\Rule{1em}{0.5em}{0.25em}}}}{}}{}}{}}{\Huge|}}}{}}{\Rule{0.5em}{0.25em}{0.05em}}}{\overset{\Rule{2em}{0.05em}{0.05em}}{\overset{\Rule{5em}{0.05em}{0.05em}}{\overset{\Rule{9em}{0.05em}{0.05em}}{\overset{\Rule{14em}{0.05em}{0.05em}} {\overline{\left\rfloor\left\rfloor\overset{\underline{{\displaystyle \Huge {\scr F\sf o\rm n\cal t\frak s}} }}{\underline{\underline{\underline{\underline{\underline{\underline{\left[\overline{\begin{matrix} \mathtip{\overset{\infty}{\underset{j=0}{\LARGE\rm K}}}{\text{\rm}}\,\overset{\displaystyle f(c)}{} &\qquad \mathtip{\overset{\infty}{\underset{j=0}{\LARGE\cal K}}}{\text{\cal}} \,\overset{\displaystyle f(c)}{}&\qquad \mathtip{\overset{\infty}{\underset{j=0}{\LARGE\sf K}}}{\text{\sf}}\,\overset{\displaystyle f(c)}{} \\ \mathtip{\overset{\infty}{\underset{j=0}{\LARGE\tt K}}}{\text{\tt}}\,\overset{\displaystyle f(c)}{} &\qquad \mathtip{\overset{ \ \ \, \infty}{\underset{j=0}{\LARGE\it K}}}{\text{\it}}\,\overset{\displaystyle f(c)}{} &\qquad \mathtip{\overset{\quad\infty}{\underset{j=0}{\LARGE\scr K}}}{\text{\scr}}\,\overset{\displaystyle f(c)}{} \\ \mathtip{\overset{\infty}{\underset{j=0}{\LARGE\bf K}}}{\text{\bf}}\,\overset{\displaystyle f(c)}{} &\qquad \mathtip{\overset{\infty}{\underset{j=0}{\LARGE\frak K}}}{\text{\frak}}\,\overset{\displaystyle f(c)}{} &\qquad \mathtip{\overset{\infty}{\underset{j=0}{\LARGE\Bbb K}}}{\text{\Bbb}}\,\overset{\displaystyle f(c)}{} \\\end{matrix}}\right]}}}}}}}\right\lfloor\right\lfloor}}}}}} $$ where $\:\color{red}{\rlap{\color{\green}{\,\,\tiny\star}}{\Rule{1em}{0.5em}{0.25em}}}\:$ is the flag of my country. $\overset{\cdot\cdot}\smile$


Country Flags (to be put in your profile)

Some codes are too long to fit in the location section, that's why I'm working on making less long codes. $\checkmark$ denotes ones that can fit in.


$\phantom{XXXXX}$enter image description here

$\checkmark$ Morocco Preview: (don't use the codes associated with the previews, instead use the ones written under)



$\checkmark$ France Preview:



$\checkmark$ Italy Preview:



Ireland Preview:



Mali Preview:



Senegal Preview:



Romania Preview:



Belgium Preview:



More are to be added, you can contribute by making any flag you want :-)

Consider replacing all of your \color{white} with \color{#}. The same can be done with other colors such as replacing \color{darkblue} with \color{#009}. – Brad Jun 30 '14 at 6:14
Looks like codegolf.SE material... – kennytm Jun 30 '14 at 10:20
@Brad Yes, thanks! – Hakim Jun 30 '14 at 23:02

you may also go to MathURL and write your formula there; just remember the dollar signs before putting it here.


$\rm{\bf Hint}\:\ (p\!-\!1)^2\! \mid p^q\!-1 \!\iff\! p\!-\!1\ \bigg|\ \dfrac{p^q\!-1}{p\!-\!1} = p^{q-1}\! +\cdots\!+p\! +\! 1$ $\rm\equiv q\ (mod\ p\!-\!1)$

\rm ${}{}{}{}{}$ – user93957 Jan 7 '14 at 13:00



To put multiple "hats" over a letter $f$:

$$\hat{\hat{\hat{f}}}\colon X\rightarrow Y \qquad \hat{\hat{\hat{\mbox{$f$}}}}\colon X\rightarrow Y$$ $$\hat{\hat{\hat{xf}}}\colon X\rightarrow Y \qquad \hat{\hat{\hat{\mbox{$xf$}}}}\colon X\rightarrow Y$$ $$\hat{\hat{\hat{fx}}}\colon X\rightarrow Y \qquad \hat{\hat{\hat{\mbox{$fx$}}}}\colon X\rightarrow Y$$ The attempt on the right isn't perfect (because the hats aren't aligned horizontally with the top of the $f$) but it's much better than the attempt on the left (where the hats are not aligned with each other).

To indicate an indefinite number of hats atop the letter $f$ by putting three dots between the topmost hat and the bottommost hat: $$\hat{\dot{\dot{\dot{\hat{\mbox{$f$}}}}}}\colon X\rightarrow Y$$ $$\hat{\dot{\dot{\dot{\hat{\mbox{$xxxxxf$}}}}}}\colon X\rightarrow Y$$ $$\hat{\dot{\dot{\dot{\hat{\mbox{$fxxxxx$}}}}}}\colon X\rightarrow Y$$

This is the best I've done so far; it would be interesting to know if it can be done better. Less vertical space would be nice, for one thing, both for the three-hat case and the many-hats case. And of course fixing the horizontal alignment.

I don't know if anyone is still looking into this issue, but note the offset of the innermost (lowest) hat is affected by what ever is the last letter inside. E.g. if you add an $x$ after the $f$ the alignment is almost perfect. If you add lots of $xxxxs$ the alignment doesn't change. Then if you add one $f$ at the end you have a full alignment error again (\hat doesn't render in comments :-( ), not mitigated by "averaging" over multiple $xs$ as I'd expect. – Mark Hurd Apr 19 at 8:20
I no longer see any difference between the "left" and "right" examples. (It's strange that I did before, and I can't explain why I did.) It also seems to me that the alignment over $xf$ is even worse than the alignment over $f$. – David K Apr 19 at 10:54

Can we do pictures?

\begin{picture}(2,2) \put(0,0){\line(1,0){1}} \put(0,0){\line(0,1){1}} \end{picture}

\begin{math} 2 \end{math}

aw dang..

See here – t.b. Sep 18 '11 at 22:10
@TheoBuehler: Aw, dang. Thanks for the link. – Mehrdad Sep 18 '11 at 22:28

$ (\not \in \notin) 1 \times 2 \in S \implies S \notin S$

$$ \lim_ {k\to\infty}^{\diamond \circ \square \sum \int} \sum_{j=1}^k {j^{2^j_k}_3}_{x_i} \int_2^3x\ dx $$

$C3^\#_\flat\natural\colon$ musical stuff!

$$¡^IGNORE\ \ M_e!$$

$$¡^IGNORE\ \ M_e!$$

$$!`^IGNORE\ \ M_e!$$

$$\unicode{xA1}^IGNORE\ \ M_e!$$

Hm... odd... ¡^IGNORE\ \ M_e! works in the preview. – Ryan O'Hara Dec 3 '11 at 6:31
Okay, only one of three variants work... – J. M. Dec 3 '11 at 6:53
Make that two.${}$ – J. M. Dec 6 '11 at 14:23
Test: $\mathbb{R}^{n+1}$ – Dan Moore Jul 12 '12 at 15:27

Can we enter nested math inside \text now, and have it saved? $$ \{\,p\mid\text{$p$ and $p+2$ are prime}\,\} $$ Edit: it seems we can.

But will Markdown respect it? $\text{This should not become a hyperlink: $[test]($}$ – celtschk Jul 14 '12 at 10:28
The changes don't affect comments, only questions and answers. Comments seem to be processed quite differently. – Davide Cervone Jul 14 '12 at 13:57
That's interesting. So $\text{does this $x^2$ also not work properly?}$ Well, it seems to work. – celtschk Jul 14 '12 at 16:06
MathJax properly handles nested dollars, but they are not protected from MarkDown when used in comments. They are when used in questions and answers. – Davide Cervone Jul 14 '12 at 18:30

The preview recognizes $\rm\LaTeX$ environments and protects the contents from Markdown. Does that work once saved?

\begin{equation} x _1 = y_ 1 \end{equation}

Edit: It seems that it does!


Testing striking out:

math: text $a^2-b^2=(a-b)(a+b)$ text

tag: text text

url: text math.SE text

What about comments? math: <s> text $a^2-b^2=(a-b)(a+b)$ text </s> tag: <s> text tex text </s> url: <s> text math.SE text </s> – Martin Sleziak Jun 20 '12 at 12:53
Any concave function $f\colon[0,\infty)\to\mathbb R$ such that $f(0)=0$ is subadditive. – Martin Sleziak Jun 28 '12 at 14:10
Any concave function $f\colon[0,\infty]\to\mathbb R$ such that $f(0)=0$ is subadditive. – Martin Sleziak Jun 28 '12 at 14:12
What about \left[\right)? Any concave function $f\colon\left[0,\infty\right)\to\mathbb R$ such that $f(0)=0$ is subadditive. – Martin Sleziak Jun 28 '12 at 14:33
$\left[0,\infty\right)$ and [link]( produces $\left[0,\infty\right)$ and link. – Martin Sleziak Jun 28 '12 at 14:43
Do you mean that in one dimension the definition of a manifold with boundary is: "A topological space such that each point has a neighbourhood homeomorphic to an open subset of $(-\infty, 0]$ or $[0, \infty)"? Or do you mean you can define a one dimensional manifold with boundary as a topological space such that each point has a neighbourhood homeomorphic to an open subset of $(-\infty, 0]$, or equivalently, $[0, \infty)$? Surely you mean the latter as $\phi : [0, \infty) \to (-\infty, 0]$, $\phi(x) = -x$ is a homeomorphism. – Martin Sleziak Oct 12 '12 at 13:36
What happens if I put here link to a cooment? – Martin Sleziak Apr 5 '13 at 17:19

Preview seems to "leak" macro definitions, even to before the macro is defined. Let's see what happens with saving.

This macro should be undefined here (and thus show the name in red): $\NobodyWouldCreateSuchALongMacroName$

So should this: $\AnotherRidiculouslyLongName$

Now start a local group. $\require{begingroup}\begingroup$

Define the first macro to $1$ $\def\NobodyWouldCreateSuchALongMacroName{1}$ and use it: $\NobodyWouldCreateSuchALongMacroName$ — This should display as $1$.

Now define the second one, this time using gdef, to the value $2$. $\gdef\AnotherRidiculouslyLongName{2}$ Again, use it: $\AnotherRidiculouslyLongName$ — This should show up as $2$.

Now end the group. $\endgroup$

Now the first macro should be undefined again: $\NobodyWouldCreateSuchALongMacroName$

The second macro, however, should still be defined (or I've misunderstood something): $\AnotherRidiculouslyLongName$

OK, so as soon as it's posted, obviously everything works as it should. – celtschk Jul 12 '12 at 16:41
Tangentially related: The scope of \newcommand is the entire page. (But it is about \newcommand, not \def.) – Martin Sleziak Jul 14 '12 at 6:46

$\varnothing$ -- porton says this does not work.

testing.......... – Douglas S. Stones Jul 24 '13 at 14:43
@DouglasS.Stones: hello – Douglas S. Stones Jul 24 '13 at 14:43
@DouglasS.Stones testing... – Douglas S. Stones Jul 24 '13 at 14:45

The following gives [Math Processing Error] on iOS Safari, but OK on iOS Chrome and on desktop browsers.

$ \newcommand{\ket}[1]{\left| #1 \right\rangle} \newcommand{\Psih}{\hat{\Psi}} \newcommand{\Psihd}{\hat{\Psi}^\dagger} \newcommand{\bx}{\mathbf{x}} \newcommand{\Hh}{\hat{H}} \newcommand{\Hsp}{\Hh_{\mathrm{sp}}} \newcommand{\cn}{\chi(\bx_1,\dots\bx_n)} $

$\frac12 \sum_{i,j} V(\bx_i-\bx_j)\cn$

$$\ket{\chi_n} = \int d\bx_1 \dots d\bx_n \cn\prod_k \Psihd(\bx_k)\ket{0}$$

$$\begin{align} \hat{V}\ket{\chi_n} &= \frac12 \int d\bx d \bx'd\bx_1 \dots d\bx_n V(\bx-\bx')\cn\Psihd(\bx) \Psihd(\bx') \Psih(\bx')\Psih(\bx)\prod_k \Psihd(\bx_k)\ket{0} \\ &= \frac12 \int d\bx d \bx'd\bx_1 \dots d\bx_n V(\bx-\bx') \sum_{i,j:i\ne j}\delta(\bx-\bx_i) \delta(\bx'-\bx_j) \cn\prod_k \Psihd(\bx_k)\ket{0}\\ &= \frac12 \int d\bx_1 \dots d\bx_n \sum_{i,j:i\ne j} V(\bx_i-\bx_j) \cn\prod_k \Psihd(\bx_k)\ket{0} \end{align} $$ which is the interaction we expect.


This was done in an attempt (so far unsuccessful) to replicate the problem mentioned in line breaks in incorrect places

However, when I was trying this, I stumbled upon some strange behavior of MathJax, which I can't explain. (And I am unable to spot a mistake in the TeX code below.)

Two separate formulas - they work fine:

$\|e^A\|=\|I+A+A^2/2!+A^3/3!+\ldots\|=\sup_{|x|=1}\|(I+A+A^2/2!+A^3/3!+\ldots)x\|=$ $\sup_{|x|}\|Ix+Ax+(A^2x)/2!+(A^3x)/3!+\ldots\|\leq \sup_{|x|}\|Ix\|+\sup_{|x|=1}\|Ax\|+\frac{\sup_{|x|}\|A^2x\|}{2!}+\frac{\sup_{|x|}\|A^3x\|}{3!}+\ldots$

Now without any changes they are put together and everything is broken: $\|e^A\|=\|I+A+A^2/2!+A^3/3!+\ldots\|=\sup_{|x|=1}\|(I+A+A^2/2!+A^3/3!+\ldots)x\|= \sup_{|x|}\|Ix+Ax+(A^2x)/2!+(A^3x)/3!+\ldots\|\leq \sup_{|x|}\|Ix\|+\sup_{|x|=1}\|Ax\|+\frac{\sup_{|x|}\|A^2x\|}{2!}+\frac{\sup_{|x|}\|A^3x\|}{3!}+\ldots$

This first part of the fromula still works ok: $\|e^A\|=\|I+A+A^2/2!+A^3/3!+\ldots\|=\sup_{|x|=1}\|(I+A+A^2/2!+A^3/3!+\ldots)x\|= \sup_{|x|}\|Ix+Ax+(A^2x)/2!+(A^3x)/3!+\ldots\|\leq$

When I add the next bit, it becomes weird: $\|e^A\|=\|I+A+A^2/2!+A^3/3!+\ldots\|=\sup_{|x|=1}\|(I+A+A^2/2!+A^3/3!+\ldots)x\|= \sup_{|x|}\|Ix+Ax+(A^2x)/2!+(A^3x)/3!+\ldots\|\leq \sup_{|x|}\|Ix\|+\sup_{|x|=1}\|Ax\|+$

$\|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| \|A\| \|B\| \|C\| $


I'm trying to prove this inequality:

$\|e^A\|\le e^{\|A\|}$, where $A$ is a matrix and $\|A\|:=\sup_{|x|=1} |Ax|$.

My attempt of solution:

Since $e^A:=I+A+A^2/2!+A^3/3!+\ldots$

we have

$\|e^A\|=\|I+A+A^2/2!+A^3/3!+\ldots\|=\sup_{|x|=1}\|(I+A+A^2/2!+A^3/3!+\ldots)x\|=$ $\sup_{|x|}\|Ix+Ax+(A^2x)/2!+(A^3x)/3!+\ldots\|\leq \sup_{|x|}\|Ix\|+\sup_{|x|=1}\|Ax\|+\frac{\sup_{|x|}\|A^2x\|}{2!}+\frac{\sup_{|x|}\|A^3x\|}{3!}+\ldots$

Am I right so far? I couldn't go further

I need help!

Thanks a lot.


Testing matrix environments - are multiple backslashes needed?

The following (with each line ending only with two backslashes) renders ok for me: $$\begin{pmatrix} 1/2 & 1/2 & 1/2 & 1/2 & 1/2 & 1/2 & 1/2 & 0 \\ 1/2 & 0 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 1/2 & 0 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 1/2 & 0 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 1/2 & 0 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 1/2 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 1/2 & 0 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1/2 & 1 \end{pmatrix}$$

I've tried this because of this question. – Martin Sleziak Jul 8 '13 at 8:13



\begin{array}{| r | r | r |} \hline N & \frac{1}{\sqrt{N-2^{1/2}}} & \frac{1}{c_4(N)\sqrt{N-1}} \\ \hline 3 & 0,7941 & 0,7979 \\ 4 & 0,6219 & 0,6267 \\ 5 & 0,5281 & 0,5319 \\ \hline \end{array}


This line $$\int \frac{1}{f} \frac{df}{dx} dx = \frac{1}{f} f - \int f \left(-\frac{1}{f^2} \frac{df}{dx}\right) dx$$ should be $$\int_a^b \frac{1}{f} \frac{df}{dx} dx = \left[\frac{1}{f} f\right]_a^b - \int_a^b f \left(-\frac{1}{f^2} \frac{df}{dx}\right) dx$$ so $$\int_a^b \frac{1}{f} \frac{df}{dx} dx = \left[1\right]_a^b - \int_a^b f \left(-\frac{1}{f^2} \frac{df}{dx}\right) dx$$ and $\left[1\right]_a^b=0$


Demonstrating the issue from this question


$\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b} + \frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b} - \frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b} = \frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\times\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}\frac{a}{b}$


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .