Purpose of question

We now 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}\$

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 Source highlighted

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

This question should be community wiki (No one should get rep from it, and it should be easy to edit), so you can also see the source that way.

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.

link
2  
It also works in comments: \$\Rightarrow \LaTeX\$ \$\Rightarrow \LaTeX\$ – Kevin Vermeer Mar 8 '11 at 22:20
By the way, it will take a second to render in preview while editing and in normal view, especially once this page starts filling up. Give it time. – Kevin Vermeer Mar 8 '11 at 22:23
What is meant by "module" in TeX context? I don't think there is such a thing in TeX anyway. – AndreKR Mar 9 '11 at 2:07
1  
This kinda sucks having a meta question on the main site, but TeX isn't enabled on meta, so not sure what to do. – Nick T Mar 9 '11 at 3:18
2  
and now it's moved to meta, so it doesn't work :( – Martin Thompson Mar 9 '11 at 16:04
@Martin - I tried to rectify that problem with this question – Kevin Vermeer Mar 9 '11 at 16:20
$100 test $60... – Earlz Mar 13 '11 at 17:28
It says "misplaced on the main site" – Brian Carlton Mar 17 '11 at 14:39
feedback

migrated from electronics.stackexchange.com Mar 9 '11 at 4:50

This question came from our site for electronics and electrical engineering professionals, students, and enthusiasts.

12 Answers

Entering Units:

\$Because TeX just jams everything together\$,
\$Because TeX just jams everything together\$
...in order to use units well, you need to use the power of the \text{}

e.g.:

ugly:

$$P_{max} = \frac{V_{max}{}^2}{4R_{sink}} = \frac{(150 volts)^2}{4 \times 10 k\Omega} = 9/16 watts$$ $$P_{max} = \frac{V_{max}{}^2}{4R_{sink}} = \frac{(150 volts)^2}{4 \times 10 k\Omega} = 9/16 watts$$

less ugly:

$$P_{max} = \frac{V_{max}{}^2}{4R_{sink}} = \frac{(150 \text{ volts})^2}{4 \times 10\text{ k}\Omega} = 9/16 \text{ watts}$$ $$P_{max} = \frac{V_{max}{}^2}{4R_{sink}} = \frac{(150 \text{ volts})^2}{4 \times 10\text{ k}\Omega} = 9/16 \text{ watts}$$

I don't really like having to put the \Omega outside of the text though, but if it's inside, then it doesn't parse it...

alternative:

$$P_{max} = \frac{V_{max}{}^2}{4R_{sink}} = \frac{(150\ \mathrm{volts})^2}{4 \times 10\ \mathrm{k\Omega}} = 9/16\ \mathrm{watts}$$ $$P_{max} = \frac{V_{max}{}^2}{4R_{sink}} = \frac{(150\ \mathrm{volts})^2}{4 \times 10\ \mathrm{k\Omega}} = 9/16\ \mathrm{watts}$$

Using \mathrm instead of \text makes commands like \Omega work, but means that spaces must be written as .

(The technical explanation is that \text switches the TeX parser from "math mode" to "text mode", where the parsing works differently, while \mathrm simply changes the font while staying in math mode.)

Ps. {\rm watts} will also work instead of \mathrm{watts}. Those two commands are basically equivalent, just with different syntax. (\rm is a basic TeX command, while \mathrm is LaTeX. That's pretty much the only difference.)

link
You can put only the space in the mbox: \rightarrow 10\mbox{ }k\Omega $\rightarrow 10\mbox{ }k\Omega$ – Kevin Vermeer Mar 17 '11 at 2:02
@reem, your italicized $k$ looks strange. – Nick T Mar 17 '11 at 2:18
Hm, looks pretty similar to me. Test: 10\mbox{ k}\Omega\mbox{ vs. }10\mbox{ }k\Omega $\rightarrow 10\mbox{ k}\Omega\mbox{ vs. }10\mbox{ }k\Omega$ – Kevin Vermeer Mar 17 '11 at 13:17
@reem, it's not italicized? I can see it, but it's even more glaring with longer units; e.g. 10\mbox{ }volts $10\mbox{ }volts$ versus 10\mbox{ volts} $10\mbox{ volts}$ – Nick T Mar 18 '11 at 12:10
Still no difference: i.imgur.com/YdYba.png – Kevin Vermeer Mar 18 '11 at 14:23
1  
It's better to use \text instead of \mbox, since \mbox behaves oddly e.g. in super/subscripts (compare \$V_\mbox{max}\$ with \$V_\text{max}\$). Also, \mathrm (or just plain old \rm) is IMO even better suited for typesetting units. – Ilmari Karonen Mar 4 at 17:59
@IlmariKaronen good to know, I am a total TeX noob, it was just the first thing I happened across that (sort of) worked. – Nick T Mar 24 at 22:45
feedback

Subscripts and Superscripts

Easy enough:

  • \$R_{max} = 42\$
    • R_{max} = 42

  • \$e^{i\pi} = -1\$
    • e^{i\pi} = -1

What if you want \$R_{max}\$ squared?

  • \$R_{max}^2\$
    • R_{max}^2

perhaps not what you wanted, with the subscript and superscript lining up. If you want the superscript to start at the end of the subscript you can jam and empty field(?) to separate them, e.g.:

  • \$R_{max}{}^2\$
    • R_{max}{}^2

(from here)

link
feedback

\$\triangledown \cdot E = \frac{\rho}{\epsilon_0}\$

\$\triangledown \cdot B = 0\$

\$\triangledown \times E = - \frac{\partial B}{\partial t}\$

\$\triangledown \times B = \mu_0 J + \mu_0 \epsilon_0 \frac{\partial E}{\partial t}\$

Pretty sweet...

link
$\frac{1}{2}$... – drxzcl Mar 8 '11 at 23:24
hmm .. $e^{x^{2}}$ – JustJeff May 9 '11 at 1:19
feedback

And if you want to draft/sandbox your MathJax equations on your own PC, Julian Bucknall has a blog post here on how to create an HTML page to do this. It works a treat. Just remember you don't need the \$ delimiters.

link
feedback

Here's my try:\$50 \mbox{ }\Omega\$. But that was too short.

link
1  
@Brian, see my thing about attaching units – Nick T Mar 9 '11 at 3:04
feedback

\$\LaTeX\$ is superset of \$\TeX\$

link
feedback

$100 <- Testing dollar

Your transformer will convert 120\$V_{ac}\$ to 12\$V_{ac}\$. So you'll need to regulate it to 5\$V_{dc}\$.

  • \$I_{ce}\$ = \$I_{be}\$ * HFE

  • \$V_{ceo}\$ \$I_{c}MAX\$

  • ASCII:
    16 - log((5 - 0)/(5 - 4))/log(2) = 13.68

  • TeX:
    \$16 - \frac{log\frac{(5 - 0)}{(5 - 4)}}{log 2} = 13.68\$

  • \$I_{F_{max}} = 30mA\$

  • \$V_{F_{typ}} = 1.7V\$
  • \$V_{F_{max}} = 2.1V\$
  • \$V_{R_{max}} = 5V\$
link
These are all things that being able to get the source from would be valuable. – Kortuk May 10 '11 at 3:32
@Kortuk - Just right-click the equation and MathJax will populate your context menu with a "Show Source" option. Or, this is CW and it's been edited, so anyone can view the post source. – Kevin Vermeer Sep 27 '11 at 12:35
feedback

This chip costs \$$1.21\$, but an alternative is only \$$0.88\$.

One complaint about using dollar signs is that prices are used too often in electronics questions. Can we at least change it to double-dollar on each end?

Using normal $ signs is no longer a problem. The above sentence looked like this when we used `$ .. $` as the delimiters:

This chip costs \$1.21, but an alternative is only \$0.88.

but this has been fixed. Just use normal dollar signs:

This chip costs $1.21, but an alternative is only $0.88.

If something funny happens to your prose, you've probably got an unmatched delimiter in your equations somewhere. Make sure that \$ only appears around equations.

link
See this question and the MathJax documentation for more about this issue. – Kevin Vermeer May 16 '11 at 12:41
1  
Other SE sites, like Math and TeX, use the single dollar signs. Jeff has said "we don't want different basic usage of MathJax across the network; that would be like Markdown changing essentials like "how to bold" on a site by side basis." Therefore, it's essentially a closed issue. Use $\$$ for now. – Kevin Vermeer May 16 '11 at 12:43
feedback

Need a new sandbox -- one without cat poop. (Testing comments w/o bugging authors.)

\$\infty\$

link
\$ Al^{2+}_{0} \$ – tyblu Dec 18 '11 at 21:42
\$ \frac{1}{2} \$ – tyblu Dec 18 '11 at 21:46
\$ L = \frac{area R_s}{\Delta V}\$ – tyblu Dec 18 '11 at 21:53
\$V_{inductor} = L \frac{dI}{dt}\$ – tyblu Dec 18 '11 at 21:53
\$\infty\$ 5 more to go... – tyblu Mar 4 at 1:22
feedback

Tables

Inline math doesn't work for tables: \$begin{array}...\end{array}\$ produces the array on one line:

Apparently, something's changed since this answer was originally written, and tables now work just fine in inline math:

\$ \begin{array}{ccc}x&S(n,x)&x^n \log\left(\frac{x}{x-1}\right)\\-5&-1780484.04&-1780483.95\\-3&-16987.42&-16987.34\\2&709.598&709.783\\ 4&301656.39&301656.52\\6&1.102428722 \times 10^7&1.102428734 \times 10^7\end{array} \$

For arrays, equation arrays, matrices, piecewise equations, aligned equations, and other multi-line constructs, you no longer need to use the displayed math $$..$$ delimiter set, which places the equation on its own line(s):

$$ \begin{eqnarray} f_p(x) & = & \sum_{j=0}^{n} c_j \phi(||x - x_j||) \\ & = & \sum_{j=0}^{n} c_j \phi_j(x) \\ & = & c_0 \phi_0(x) + c_1 \phi_1(x) + \cdots + c_n \phi_n(x) \end{eqnarray} $$

link
I pulled the fix for this example from meta.quant.stackexchange.com/q/143/989. Make sure you check the other SE sites with TeX for examples! We're all on basically the same engine. – Kevin Vermeer Jun 16 '11 at 11:53
@Kevin, I pulled that example that didn't work from math.SE, where it does work. math.stackexchange.com/questions/15008/sum-of-series-fracxkn-k/… – W5VO Jun 16 '11 at 19:29
It's surrounded by double dollar signs there: link to source – Kevin Vermeer Jun 16 '11 at 20:24
@Kevin - wait... so this whole "no other site uses $$" argument was bogus? – W5VO Jun 17 '11 at 2:03
I'm not sure what argument you're referring to. All sites on the SE network, and many off of it, use $$..$$ as the displayed math delimiters. MathJax recommends against using $..$ as the inline delimiters, but many sites (including most of the SE network) do. – Kevin Vermeer Jun 18 '11 at 12:18
feedback

And you can use Unicode when typing your maths:

$$ A = πr^2 $$

A better way of doing what he did:

$$ P_{max} = \frac{V_{max}{}^2}{4R_{sink}} = \frac{(150 \text{ volts})^2}{4 \times 10\text{ kΩ}} = 9/16 \text{ watts} $$

$$ P_{max} = \frac{V_{max}{}^2}{4R_{sink}} =
   \frac{(150 \text{ volts})^2}{4 \times 10\text{ kΩ}} = 9/16 \text{ watts} $$
link
Yeah, but that requires to insert the Omega character, not really handy – clabacchio Mar 17 at 9:43
Unless you use AutoKey or something similar. :) – Andres Riofrio Mar 17 at 21:46
feedback

Nested dfracs: \$ \dfrac{ \dfrac{\alpha \beta ^{j2 \pi f t}}{j \omega} }{ \dfrac{\gamma \delta}{\Omega \Phi} } \$ these are meant to create inline equations without resizing them to the size of a single line of text. The line is in effect streched to contain the full equation becoming much higher :)

link
feedback

You must log in to answer this question.

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