8
\$\begingroup\$

Purpose of question

We have \$\LaTeX\$ support through MathJax! Now, instead of writing equations like this:

w0 = 1 / sqrt(L * C)

we can write:

\$\displaystyle \omega_0 = \frac{1}{\sqrt{LC}}\$

Beautiful! However, TeX has a steep learning curve, and it will take some time to figure out how to use this feature. This question is a sandbox in which to practice its use.

Documentation

You'll see in the right sidebar, when writing a question, the line:

MathJaX[sic] equations \$sin^2\theta\$

and a link to generic TeX help. I find that the math mode section is most helpful. The special symbols article is particularly useful:

\$\$ \alpha \beta \mu \Omega \omega \theta \$\$

Note that not all of TeX is included; you'll get this message if you try to include a module that's not in MathJax, such as Tabular:

\$\begin{tabular}1 & 2\\3 & 4\end{tabular}\$

How did they do that?

You can always get at the source by right-clicking an equation. A MathJax context menu will come up, like the following:

Context Menu with Show Math As - TeX Commands highlighted

(some versions of MathJax use Show Source menu) Context Menu with Show Source highlighted

and "Show Math As - TeX Commands" will bring up a window with the source for the equations. Just drop the text contained \$between a pair of escaped dollar signs!\$ Or, you can $$surround it with two dollar signs for centering.$$

Begin \$\LaTeX\$ Sandbox

The markdown for a question should be identical to what you get from an answer, but I'll leave the rest of this question for testing more TeX in case that assumption is mistaken.

Note: This is a recreated version of the original MathJax sandbox question. At some point, that post evolved to cause crashing in some web browsers, and was deleted.

\$\endgroup\$
8
\$\begingroup\$

Some MathJax frequently used here:

Equation in-line: \$123\$ \$\rightarrow\$ \$123\$

Equation centered on a separate line: $$123$$ \$\rightarrow\$ $$123$$

Fractions: 1/2 \$\rightarrow\$ \$\frac{1}{2}\$ \$\rightarrow\$ \$\frac{1}{2}\$

Bigger fractions: 1/2 \$\rightarrow\$ \$\dfrac{1}{2}\$ \$\rightarrow\$ \$\dfrac{1}{2}\$

Something enclosed by full parentheses: (1/2) \$\rightarrow\$ \$\left(\frac{1}{2}\right)\$ \$\rightarrow\$ \$\left(\frac{1}{2}\right)\$

Exponent: I^2 \$\rightarrow\$ \$I^2\$ \$\rightarrow\$ \$I^2\$

Exponent: e^-1 \$\rightarrow\$ \$e^{-1}\$ \$\rightarrow\$ \$e^{-1}\$ ... or \$e^{\text{-1}}\$ \$\rightarrow\$ \$e^{\text{-1}}\$

Subscript: t0 \$\rightarrow\$ \$t_0\$ \$\rightarrow\$ \$t_0\$

Removing the italics from previous: \$\rightarrow\$ \text{t}_0 \$\rightarrow\$ \$\text{t}_0\$ (now omitting \$ tags for display brevity but they are still required.)

Square Root: sqrt(9) \$\rightarrow\$ \sqrt{9} \$\rightarrow\$ \$\sqrt{9}\$

Cubic Root: ? \$\rightarrow\$ \sqrt[3]{27} \$\rightarrow\$ \$\sqrt[3]{27}\$

Greek symbols: \alpha \$\alpha\quad\$ \beta \$\beta\quad\$ \gamma \$\gamma\quad\$ \delta \$\delta\quad\$ \epsilon \$\epsilon\quad\$ \varepsilon \$\varepsilon\quad\$ \zeta \$\zeta\quad\$ \eta \$\eta\quad\$ \theta \$\theta\quad\$ \vartheta \$\vartheta\quad\$ \iota \$\iota\quad\$ \kappa \$\kappa\quad\$ \lambda \$\lambda\quad\$ \mu \$\mu\quad\$ \nu \$\nu\quad\$ \xi \$\xi\quad\$ \omicron \$\omicron\quad\$ \pi \$\pi\quad\$ \varpi \$\varpi\quad\$ \rho \$\rho\quad\$ \varrho \$\varrho\quad\$ \sigma \$\sigma\quad\$ \varsigma \$\varsigma\quad\$ \tau \$\tau\quad\$ \upsilon \$\upsilon\quad\$ \phi \$\phi\quad\$ \varphi \$\varphi\quad\$ \chi \$\chi\quad\$ \psi \$\psi\quad\$ \omega \$\omega\quad\$ \Gamma \$\Gamma\quad\$ \Delta \$\Delta\quad\$ \Theta \$\Theta\quad\$ \Lambda \$\Lambda\quad\$ \Sigma \$\Sigma\quad\$ \Upsilon \$\Upsilon\quad\$ \Psi \$\Psi\quad\$ \Omega \$\Omega\quad\$

Comparisons: i < 5 \$\rightarrow\$ i\lt 5 \$\rightarrow\$ \$i\lt 5\$ ... \neq \$\rightarrow \:\neq\quad\$ \approx \$\rightarrow \:\approx\quad\$ \simeq \$\rightarrow \:\simeq\quad\$

Operators: \times \$\rightarrow \:\times\quad\$ \pm \$\rightarrow \:\pm\quad\$ \cdot \$\rightarrow \:\cdot\quad\$ \oplus \$\rightarrow \:\oplus\quad\$ \infty \$\rightarrow \:\infty\quad\$

Trigonometry: sin(x) \$\rightarrow\$ \sin x \$\rightarrow\$ \$\sin x\$

Logs: nat log(n) \$\rightarrow\$ \ln x \$\rightarrow\$ \$\ln x\$ ... \log_{20}(x) \$\rightarrow \:\log_{20}(x)\quad\$

Sum: \sum_{a=1} ^{B} c \$\rightarrow \sum_{a=1} ^{B} c\$

Product: \prod_{a=1} ^{B} c \$\rightarrow \prod_{a=1} ^{B} c\$

Integral: \int_{0} ^{\infty} x dx \$\rightarrow \int_{0} ^{\infty} x dx\$

Limit: \lim_{x \to \infty} \$\rightarrow \lim_{x \to \infty}\$

Overline: /nRESET \$\rightarrow\$ \overline{\text{nRESET}} \$\rightarrow\$ \$\overline{\text{nRESET}}\$

Vector: \vec{x} \$\rightarrow\$ \$\vec{x}\$ also \overrightarrow{x} \$\rightarrow\$ \$\overrightarrow{x}\$

\$\endgroup\$
5
\$\begingroup\$

Sadly there is no siunitx support, so to get the units right, it gets a bit clumsy like this:

3 V \$\rightarrow\$ 3~\text{V} \$\rightarrow\$ \$3~\text{V}\$

The ~ is there to generate the space and as units are written upright and not in italics we need to use \text{unit}

As Massimo Ortolando suggests using \, typesets a smaller space, which is used in the siunitx package to make the combination look more like a single entity:

3 V \$\rightarrow\$ 3\,\text{V} \$\rightarrow\$ \$3\,\text{V}\$

Instead of just having \SI{3}{\volt}.

\$\endgroup\$
2
  • 1
    \$\begingroup\$ Yeah, unfortunately siunitx is not supported is any site. For the space, I suggest to use the small space \,, which better represents the fact that the quantity is a single object (siunitx uses this). \$\endgroup\$ May 12 at 17:38
  • \$\begingroup\$ @MassimoOrtolano nice, thanks for that. I incorporated this in my answer and the difference is small but visible. \$\endgroup\$
    – Arsenal
    May 12 at 19:04
3
\$\begingroup\$

MathJax resources on the other stackexchange sites:

meta.SE: Which Sites Use MathJax -- Which Stack Exchange sites use MathJax?

meta.SE: questions tagged MathJax -- https://meta.stackexchange.com/questions/tagged/mathjax?tab=Active

math.SE: MathJax basic tutorial and quick reference -- https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference

  1. Parentheses

Ordinary symbols () [] make parentheses and brackets \$(2+3)[4+4]\$.
Use \{ and \} for curly braces \$\{\}\$.

These do not scale with the formula in between,
so if you write (\frac{\sqrt x}{y^3}) the parentheses will be too small: \$(\frac{\sqrt x}{y^3})\$.
Using \left(\right) will make the sizes adjust automatically to the formula they enclose:
\left(\frac{\sqrt x}{y^3}\right) is \$\left(\frac{\sqrt x}{y^3}\right)\$.

\left and \right apply to all the following sorts of parentheses:
( and ) \$(x)\$,
[ and ] \$[x]\$,
\{ and \} \$\{x\}\$,
| \$|x|\$,
\vert \$\vert x \vert\$,
\Vert \$\Vert x \Vert\$,
\langle and \rangle \$\langle x \rangle\$,
\lceil and \rceil \$\lceil x \rceil\$,
\lfloor and \rfloor \$\lfloor x \rfloor\$.
\middle can be used to add additional dividers.

\left[\frac{\sqrt x}{y^3}\right] is \$\left[\frac{\sqrt x}{y^3}\right]\$.

There are also invisible parentheses, denoted by .:
\left.\frac12\right\rbrace is \$\left.\frac12\right\rbrace\$.

If manual size adjustments are required: \Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr) gives \$\Biggl(\biggl(\Bigl(\bigl((x)\bigr)\Bigr)\biggr)\Biggr)\$.

Fractions

\frac{a+1}{b+1} is \$\frac{a+1}{b+1}\$
{a+1\over b+1} is \${a+1\over b+1}\$

Roots

Use sqrt, which adjusts to the size of its argument:
\sqrt{x^3} \$\sqrt{x^3}\$
\sqrt[3]{\frac xy} \$\sqrt[3]{\frac xy}\$
\left({\frac qr}\right)^{1/2} \$\left({\frac qr}\right)^{1/2}\$

\operatorname{myfunction}(x) \$\operatorname{myfunction}(x)\$

\$\endgroup\$
0
2
\$\begingroup\$

Matrices:

$$G_{\text{MNA}} = \begin{bmatrix}
g_1 & -g_1 & \cdots \\
-g_1 & g_1 & \cdots \\
\vdots & \vdots & \ddots 
\end{bmatrix}$$

$$G_{\text{MNA}} = \begin{bmatrix} g_1 & -g_1 & \cdots \\ -g_1 & g_1 & \cdots \\ \vdots & \vdots & \ddots \end{bmatrix}$$

Cases:

$$I_\text{LED} = \begin{cases} (V - V_F) / R;& V > V_F\\ 0;&V < V_F\end{cases} $$

$$I_\text{LED} = \begin{cases} (V - V_F) / R;& V > V_F\\ 0;&V < V_F\end{cases} $$

\$\endgroup\$
0
\$\begingroup\$

Here's a resource I found useful

https://arachnoid.com/latex/

(be sure to click the "mathjax" radio button, as it has other latex renderings too)

\$\endgroup\$

You must log in to answer this question.

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