How to type mathematical equations using LaTeX

  • Mathematica
  • Thread starter Greg Bernhardt
  • Start date
In summary, LaTeX is the standard language used by mathematicians, physicists, etc. for typesetting mathematical expressions. MathJax is a Javascript-based engine that processes LaTeX code in posts and renders it in the way you would see it in a textbook. If you're on a computer, you can see the LaTeX code for any equation displayed in the forum by right-clicking (under Windows) or control-clicking (under Mac OS) on it. This brings up a contextual popup menu. To practice your LaTeX, enter it in the editing box for a new thread or post, and click the "Preview" button. Don't click the "Create
  • #1
19,443
10,021
HTML:
<h1> How to type mathematical equations using LaTeX </h1>

<p> LaTeX is the standard language used by mathematicians, physicists, etc. for
typesetting mathematical expressions. 
PF uses <a href="http://docs.mathjax.org/en/latest/mathjax.html">MathJax</a>,
a Javascript-based engine, to process LaTeX code in posts and render it in the
way you would see it in a textbook. </p>

<p> <b>Note:</b> the PF apps for iOS (iPhone, iPad) and Android can only display
raw LaTeX code as plain text. You must use PF via a web browser in order to see
properly-rendered equations. </p>

<p> If you're on a computer, you can see the LaTeX code for any equation
displayed in the forum by right-clicking (under Windows) or control-clicking
(under Mac OS) on it. This brings up a contextual popup menu.  Choose <b>Show
Math As</b>, then <b>TeX Commands</b>. </p>

<p> To practice your LaTeX, enter it in the editing box for a new thread or
post, and click the "Preview" button. Don't click the "Create Thread" or "Post
Reply" button unless you want everybody else to see what you're doing! </p>

<p> This document aims to help people produce individual equations for
postings on PF. It does not include features of LaTeX for layout of full documents,
or precise formatting for print publication. If you have suggestions for additions
to this document that fit with its general aims, please post them in our
<a href="https://www.physicsforums.com/forums/feedback-and-announcements.19/">
Feedback and Announcements</a> forum. </p>

<h2> Delimiting your LaTeX code </h2>

<p> You must put special delimiters at the beginning and end of your LaTeX code,
in order for MathJax to recognize it and process it. If you want the equation
to appear inline with the surrounding text, put <code>##</code> before and after
it. If you want the equation to stand alone in a separate "paragraph", centered
horizontally on the screen as in most textbooks, put <code>$$</code> before and
after it. </p>

<p> Here's an example, first with the delimiters disabled so you can see the raw
code: </p>

<p style='margin-left: 10%; margin-right: 10%; background-color: Azure'>
A quadratic equation is of the form <code>##ax^2 + bx + c = 0##</code>. To
solve for x, use the quadratic formula <code>$$x = \frac {-b \pm \sqrt{b^2 -4ac}}
{2a},$$</code> substituting the values of the coefficients a, b and c. </p>

<p> And now with the delimiters enabled so as to render the equations: </p>

<p style='margin-left: 10%; margin-right: 10%; background-color: Azure'>
A quadratic equation is of the form ##ax^2 + bx + c = 0##. To solve for x,
use the quadratic formula $$x = \frac {-b \pm \sqrt{b^2 -4ac}} {2a},$$
substituting the values of the coefficients a, b and c. </p>

<p> Hereafter, I will omit the delimiters in code examples, to save space. </p>

<h2> Spaces </h2>

<p> Most blank spaces and end-of-line characters in your raw code are ignored.
Spaces will usually be placed in the rendered equation according to standard
mathematical conventions. For example, <code>a b + c / d</code> produces ##a b
+ c / d##. I'll try to note exceptions when they arise. </p>

<p> If you need to insert a visible space, the simplest way is usually to use a
<code>~</code> (tilde).  You can also use <code>\text{ }</code>.  There are examples
of both in the <b>Plain text</b> section below. </p>

<p> I like to use spaces generously in my code, just like with a programming
language, to separate sections of code visually and make it easier to read and
debug. </p>

<h2> Superscripts and subscripts </h2>

<p> The symbols <code>^</code> and <code>_</code> are the commands for
superscripts (e.g. exponents) and subscripts, respectively. If a superscript
or subscript has more than one character, enclose them in braces
<code>{ }</code>.  This is a general rule for LaTeX commands, by the way:
if they are to act on multiple characters, enclose those characters in
braces. </p>

<p> You can have both subscripts and superscripts on the same symbol. Normally
they appear one on top of the other. If you want them offset as in tensor
notation, attach some of them to a pair of empty braces, as in the example for
R below. </p>

<p> If a subscript or superscript is a label that should be displayed in upright
Roman text, not italic, enclose it in <code>\rm{ }</code>. </p>

<table>

<tr> <td style='width: 5em'> ##x^2, y_k, e^{ikx}## </td>
     <td> <code> x^2, y_k, e^{ikx} </code> </td> </tr>

<tr> <td> ##x^2_k, R^{ab}{}_{cd}## </td>
     <td> <code> x^2_k, R^{ab}{}_{cd} </code> </td> </tr>

<tr> <td> ##x_{old}, x_\rm{old}## </td>
     <td> <code> x_{old}, x_\rm{old} </code> </td> </tr>

</table>

<h2> Roots and fractions </h2>

<p> You can combine operations by using braces to nest them,
one inside another. See the last example below. </p>

<table>

<tr> <td style='width: 10em'> $$\sqrt x, \sqrt[3] x, \sqrt {b^2 - 4ac}$$ </td>
     <td> <code> \sqrt x, \sqrt[3] x, \sqrt {b^2 - 4ac} </code> </td> </tr>

<tr> <td> $$\frac a b, \frac {ab} {c + d}$$ </td>
     <td> <code> \frac a b, \frac {ab} {c + d} </code> </td> </tr>

<tr> <td> $$\frac 1 {\sqrt {1 - \frac {v^2} {c^2}}}$$ </td>
     <td> <code> \frac 1 {\sqrt {1 - \frac {v^2} {c^2}}} </code> </td> </tr>

</table>

<h2> Plain text </h2>

<p> By default, most "math text" is in italics. To get plain Roman text,
you can use <code>\text{ }</code> or <code>\rm{ }</code>, depending on
whether you want spaces or math operations to be rendered or not. </p>

<table>

<tr> <td style='width: 10em'> ##\text{some text \frac 1 2}## </td>
     <td> <code> \text{some text \frac 1 2} </code> </td> </tr>

<tr> <td> ##\rm{some text \frac 1 2}## </td>
     <td> <code> \rm{some text \frac 1 2} </code> </td> </tr>

<tr> <td> ##g = 9.81~\rm{m/s^2}## </td>
     <td> <code> g = 9.81~\rm{m/s^2} </code> </td> </tr>

</table>

<p> The last example above uses a <code>~</code> (tilde) to put a blank space
between the number and the units. <code>\text{ }</code> doesn't work here
because the exponent wouldn't display properly. </p>

<h2> Parentheses, brackets, etc. </h2>

<p> For single-line expressions you can use parentheses and brackets
normally.  However, braces are used by LaTeX itself for grouping
things, as you've seen above, so if you want them to actually appear, you
have to <b>escape</b> them by using backslashes. In this case the
braces lose their normal grouping function, so you have to use a second,
unescaped pair if you want them to be grouped. </p>

<p> For angle brackets, <code>\langle \rangle</code> looks better than
<code>&lt; &gt;</code>. </p>

<table>

<tr> <td style='width: 5em'> $$\{ a + b \}$$ </td>
     <td> <code> \{ a + b \} </code> </td> </tr>

<tr> <td> $$\frac 1  { \{ a + b \} }$$ </td>
     <td> <code> \frac 1  { \{ a + b \} } </code> </td> </tr>

<tr> <td> $$\langle x \rangle$$ </td>
     <td> <code> \langle x \rangle </code> </td> </tr>

</table>

<p> For "tall" expressions e.g. fractions, sums or integrals, you can make
parentheses etc. adjust their size automatically to fit their contents. </p>

<table>

<tr> <td style='width: 8em'> $$\left( \frac a b \right)$$ </td>
     <td> <code> \left( \frac a b \right) </code> </td> </tr>

<tr> <td> $$\left[ \frac a b \right]$$ </td>
     <td> <code> \left[ \frac a b \right] </code> </td> </tr>

<tr> <td> $$\left\{ \frac a b \right\}$$ </td>
     <td> <code> \left\{ \frac a b \right\} </code> </td> </tr>

<tr> <td> $$\left| \frac a b \right|$$ </td>
     <td> <code> \left| \frac a b \right| </code> </td> </tr>

<tr> <td> $$\left\| \frac a b \right\|$$ </td>
     <td> <code> \left\| \frac a b \right\| </code> </td> </tr>

<tr> <td> $$\left< \frac a b \right>$$ </td>
     <td> <code> \left< \frac a b \right> </code> </td> </tr>

<tr> <td> $$\left[ 1 -  \left( \frac v c \right)^2 \right]^{-1/2}$$ </td>
     <td> <code> \left[ 1 -  \left( \frac v c \right)^2 \right]^{-1/2} </code>
       </td> </tr>

</table>

<p> You can omit half of a pair of these "stretchy" delimiters by
replacing it with <code>\left.</code> or <code>\right.</code> as
appropriate.  See the <b>Integrals</b> section below for an example. </p>

<h2> Vectors (physics) </h2>

<p> Different people and textbooks use different notations for vectors. I hope
yours is included in the following list. Also included are some common vector
math operators. Of course, you can use any of the vector notations with these
operators. I showed only one for brevity. </p>

<table>

<tr> <td> Vector </td>
     <td style='width: 5em'> ##\mathbf A, \vec A, \tilde A## </td>
     <td> <code> \mathbf A, \vec A, \tilde A </code> </td> </tr>

<tr> <td> Unit vector </td>
     <td> ##\hat {\mathbf A}, \hat A## </td>
     <td> <code> \hat {\mathbf A}, \hat A </code> </td> </tr>

<tr> <td> Scalar (dot) product </td>
     <td> ##\vec A \cdot \vec B## </td>
     <td> <code> \vec A \cdot \vec B </code> </td> </tr>

<tr> <td> Vector (cross) product </td>
     <td> ##\vec A \times \vec B## </td>
     <td> <code> \vec A \times \vec B </code> </td> </tr>

<tr> <td> Magnitude </td>
     <td> ##| \vec A |## </td>
     <td> <code> | \vec A | </code> </td> </tr>

</table>

<h2> Derivatives </h2>

<table>

<tr> <td style='width: 10em'> $$y', y'', y^{(n)}, \dot x, \ddot x$$ </td>
     <td> <code> y', y'', y^{(n)}, \dot x, \ddot x </code> </td> </tr>

<tr> <td> $$\frac {df} {dx}, \frac {\partial f} {\partial x}$$ </td>
     <td> <code> \frac {df} {dx}, \frac {\partial f} {\partial x} </code> </td>
     </tr>

<tr> <td> $$\frac {\partial^2 \psi} {\partial x^2}$$ </td>
     <td> <code> \frac {\partial^2 \psi} {\partial x^2} </code> </td> </tr>

<tr> <td> $$\nabla f, \nabla^2 \psi, \Box^2 \phi$$ </td>
     <td> <code> \nabla f, \nabla^2 \psi, \Box^2 \phi </code> </td> </tr>

</table>

<h2> Integrals </h2>

<p> With integrals, use <code>\,</code> to insert a bit of space (not as much
as a full space) before the ##dx## (or whatever the variable of integration
is) at the end. </p>

<p> In the second example, note how the vertical bar representing the evaluation
of limits is specified.  It's half of a left/right pair of "stretchy"
absolute-value bars. The left half is hidden by specifying it as
<code>\left.</code> instead of <code>\left|</code>. </p>

<table>

<tr> <td style='width: 15em'> $$\int x^2e^x \, dx$$ </td>
     <td> <code> \int x^2e^x \, dx </code> </td> </tr>

<tr> <td> $$\int_a^b x^2 \, dx = \left. \frac 1 3 x^3 \right|_a^b$$ </td>
     <td> <code> \int_a^b x^2 \, dx = \left. \frac 1 3 x^3 \right|_a^b </code>
     </td> </tr>

<tr> <td> $$\oint \vec E \cdot d \vec A$$ </td>
     <td> <code> \oint \vec E \cdot d \vec A </code> </td> </tr>

<tr> <td> $$\int_{y=c}^d \int_{x=a}^b e^{x+y} \, dx \, dy$$ </td>
     <td> <code> \int_{y=c}^d \int_{x=a}^b e^{x+y} \, dx \, dy </code> </td> </tr>

<tr> <td> $$\iint, \iint_S, \iiint, \iiint_V$$ </td>
     <td> <code> \iint, \iint_S, \iiint, \iiint_V </code>
     </td> </tr>

</table>

<h2> Sums, products and limits </h2>

<table>

<tr> <td> $$\sum_{n=0}^\infty a_n x^n$$ </td>
     <td> <code> \sum_{n=0}^\infty a_n x^n </code> </td> </tr>

<tr> <td> $$\prod_{n=0}^\infty a_n$$ </td>
     <td> <code> \prod_{n=0}^\infty a_n </code> </td> </tr>

<tr> <td> $$\lim_{n \rightarrow +\infty} {\frac {\sin(x)} x}$$ </td>
     <td> <code> \lim_{n \rightarrow +\infty} {\frac {\sin(x)} x} </code>
     </td> </tr>

</table>

<h2> Greek letters </h2>

<table>

<tr> <td rowspan=4> Greek lowercase </td>
     <td> ##\alpha\ \beta\ \gamma\ \delta\ \epsilon\ \zeta## </td>
     <td> <code>\alpha \beta \gamma \delta \epsilon \zeta</code> </td> </tr>
<tr> <td> ##\eta\ \theta\ \iota\ \kappa\ \lambda\ \mu## </td>
     <td> <code>\eta \theta \iota \kappa \lambda \mu</code> </td> </tr>
<tr> <td> ##\nu\ \omicron\ \xi\ \pi\ \rho\ \sigma\ \tau## </td>
     <td> <code>\nu \omicron \xi \pi \rho \sigma \tau</code> </td> </tr>
<tr> <td> ##\upsilon\ \phi\ \chi\ \psi\ \omega## </td>
     <td> <code>\upsilon \phi \chi \psi \omega</code> </td> </tr>

<tr> <td> Greek lowercase<br>(variant forms) </td>
     <td> ##\varepsilon\ \vartheta\ \varpi\ \varrho\ \varsigma\ \varphi## </td>
     <td> <code>\varepsilon \vartheta \varpi \varrho \varsigma \varphi</code>
          </td> </tr>

<tr> <td rowspan=2> Greek uppercase </td>
     <td> ##\Gamma\ \Delta\ \Theta\ \Lambda\ \Xi\ \Pi## </td>
     <td> <code>\Gamma \Delta \Theta \Lambda \Xi \Pi</code> </td> </tr>
<tr> <td> ##\Sigma\ \Upsilon\ \Phi\ \Psi\ \Omega## </td>
     <td> <code>\Sigma \Upsilon \Phi \Psi \Omega</code> </td> </tr>

</table>

<h2> Other special symbols </h2>

<table>

<tr> <td>Planck's constant</td>
     <td>##\hbar##</td>
     <td><code>\hbar</code> </td> </tr>

<tr> <td>Infinity</td>
     <td>##\infty##</td>
     <td><code>\infty</code> </td> </tr>

<tr> <td>Plus or minus</td>
     <td>##\pm\ \mp##</td>
     <td><code>\pm \mp</code> </td> </tr>

<tr> <td>Parallel, perpendicular</td>
     <td>##\parallel\ \perp##</td>
     <td><code>\parallel \perp</code> </td> </tr>

<tr> <td>For all</td>
     <td>##\forall##</td>
     <td><code>\forall</code> </td> </tr>

<tr> <td>There exists</td>
     <td>##\exists##</td>
     <td><code>\exists</code> </td> </tr>

<tr> <td> Ellipsis </td>
     <td> ##\dots\ \cdots\ \vdots\ \ddots## </td>
     <td> <code> \dots \cdots \vdots \ddots </code> </td> </tr>

<tr> <td rowspan=4> Arrows </td>
     <td> ##\rightarrow\ \leftarrow\ \leftrightarrow## </td>
     <td> <code> \rightarrow \leftarrow \leftrightarrow </code> </td> </tr>
<tr> <td> ##\Rightarrow\ \Leftarrow\ \Leftrightarrow## </td>
     <td> <code> \Rightarrow \Leftarrow \Leftrightarrow </code> </td> </tr>
<tr> <td> ##\mapsto\ \to## </td>
     <td> <code> \mapsto \to </code> </td> </tr>
<tr> <td> ##\uparrow\ \downarrow## </td>
     <td> <code> \uparrow \downarrow </code> </td> </tr>

<tr> <td rowspan=3> Relations </td>
     <td> ##\gt\ \geq\ \lt\ \leq\ \neq## </td>
     <td> <code> \gt \geq \lt \leq \neq </code> </td> </tr>
<tr> <td> ##\gg\ \ll\ \equiv## </td>
     <td> <code> \gg \ll \equiv </code> </td> </tr>
<tr> <td> ##\approx\ \cong\ \sim## </td>
     <td> <code> \approx \cong \sim </code> </td> </tr>

<tr> <td> Absolute value, norm </td>
     <td> ##|x|, \|x\|## </td>
     <td> <code> |x|, \|x\| </code> </td> </tr>

<tr> <td> Complex conjugate, adjoint </td>
     <td> ##z^*, \bar z, z^\dagger## </td>
     <td> <code> z^*, \bar z, z^\dagger </code> </td> </tr>

<tr> <td> Dirac bracket notation </td>
     <td> ##\langle \phi | \psi \rangle## </td>
     <td> <code> \langle \phi | \psi \rangle </code> </td> </tr>

<tr> <td> Direct sum </td>
     <td> ##V \oplus W## </td>
     <td> <code> V \oplus W </code> </td> </tr>

<tr> <td> Tensor product </td>
     <td> ##S \otimes T## </td>
     <td> <code> S \otimes T </code> </td> </tr>

<tr> <td> Function composition </td>
     <td> ##f \circ g## </td>
     <td> <code> f \circ g </code> </td> </tr>

<tr> <td> Element of, not in </td>
     <td> ##x \in A, x \not\in A##</td>
     <td> <code> x \in A, x \not\in A </code> </td> </tr>

<tr> <td> Subset </td>
     <td> ##A \subset B, B \subseteq C##</td>
     <td> <code> A \subset B, B \subseteq C </code> </td> </tr>

<tr> <td> Set union, intersection </td>
     <td> ##A \cup B, A \cap B##</td>
     <td> <code> A \cup B, A \cap B </code> </td> </tr>

<tr> <td> Multiple set union, intersection </td>
     <td> $$\bigcup_i A_i, \bigcap_i A_i$$</td>
     <td> <code> \bigcup_i A_i, \bigcap_i A_i </code> </td> </tr>

<tr> <td> Set subtraction </td>
     <td> ##A \setminus B##</td>
     <td> <code> A \setminus B </code> </td> </tr>

<tr> <td> Binomial coefficient </td>
     <td> ##\binom n k, {_nC_r}##</td>
     <td> <code> \binom n k, {_nC_r} </code> </td> </tr>

</table>

<h2> Special functions </h2>

<table>

<tr> <td> Trigonometric </td>
     <td> ##\sin\ \cos\ \tan\ \sec\ \csc\ \cot## </td>
     <td> <code> \sin \cos \tan \sec \csc \cot </code> </td> </tr>

<tr> <td rowspan=2> Inverse trig </td>
     <td> ##\arcsin\ \arccos\ \arctan## </td>
     <td> <code> \arcsin \arccos \arctan </code> </td> </tr>
<tr> <td> ##\sin^{-1}\ \cos^{-1}\ \tan^{-1}\\\sec^{-1}\ \csc^{-1}\ \cot^{-1}##
          </td>
     <td> <code> \sin^{-1} \cos^{-1} \tan^{-1}<br>\sec^{-1} \csc^{-1} \cot^{-1}
          </code> </td> </tr>

<tr> <td> Logarithmic </td>
     <td> ##\ln\ \log\ \log_2\ \log_{10}## </td>
     <td> <code> \ln \log \log_2 \log_{10} </code> </td> </tr>

<tr> <td> Hyperbolic trig </td>
     <td> ##\sinh\ \cosh\ \tanh\ \coth## </td>
     <td> <code> \sinh \cosh \tanh \coth</code> </td> </tr>

<tr> <td> Inverse hyperbolic trig </td>
     <td> ##\sinh^{-1}\ \cosh^{-1}\ \tanh^{-1}\ \coth^{-1}## </td>
     <td> <code> \sinh^{-1} \cosh^{-1} \tanh^{-1} \coth^{-1} </code> </td> </tr>

<tr> <td> Other functions </td>
     <td> ##\operatorname {arcsec}## </td>
     <td> <code> \operatorname {arcsec} </code> </td> </tr>

</table>

<p> Functions that are not supported directly, e.g. <code>arcsec arccsc arccot sech csch arcsinh arccosh arctanh
arcsech arccsch arccoth</code>, can be used via <code>\operatorname</code> as
shown in the last example above. </p>

<h2> Multiple lines </h2>

<p> To split an equation or expression into multiple lines, use <code>\\</code>.
</p>

<p> To align them in a specific way (e.g. at <code>=</code> signs), enclose them
between <code>\begin{align}</code> and <code>\end{align}</code>, and use
<code>&amp;</code> to specify the points at which they are to be aligned.
By default, this adds equation numbers at the right side of the page.  To
suppress them, put <code>\nonumber</code> at the end of each line. </p>

<table>

<tr> <td> $$y = (a + b)^2 \\ = a^2 + 2ab + b^2$$ </td>
     <td> <code> y = (a + b)^2 \\ = a^2 + 2ab + b^2 </code> </td> </tr>

<tr> <td> $$\begin{align} y & = (a + b)^2 \\ & = a^2 + 2ab + b^2 \end{align}$$ </td>
     <td> <code> \begin{align}<br>y & = (a + b)^2 \\<br>& = a^2 + 2ab + b^2<br>
       \end{align}
     </code> </td> </tr>

<tr> <td> $$\begin{align} y & = (a + b)^2 \nonumber \\ & = a^2 + 2ab + b^2
     \nonumber \end{align}$$ </td>
     <td> <code> \begin{align}<br>y & = (a + b)^2 \nonumber  \\<br>
       & = a^2 + 2ab + b^2 \nonumber<br>\end{align}
     </code> </td> </tr>

</table>

<p> This sort of construction with <code>\begin{}</code> and <code>\end{}</code>
is called an <b>environment</b>. There are other environments for different kinds
of formatting. </p>

<h2> Matrices and Tables </h2>

<table>

<tr> <td style='width: 10em'> $$\begin{pmatrix} 1 & 2 & 3 & 4 \\ a & b & c & d
     \\ x & y & z & w \end{pmatrix}$$ </td>
     <td> <code> \begin{pmatrix}<br>1 & 2 & 3 & 4 \\<br>a & b & c & d \\<br>
     x & y & z & w<br>\end{pmatrix} </code> </td> </tr>
<tr> <td> $$\begin{vmatrix} 1 & 2 & 3 & 4 \\ a & b & c & d \\ x & y & z & w
     \end{vmatrix}$$ </td>
     <td> <code> \begin{vmatrix}<br>1 & 2 & 3 & 4 \\<br>a & b & c & d \\<br>
     x & y & z & w<br>\end{vmatrix} </code> </td> </tr>
<tr> <td> $$\begin{bmatrix} 1 & 2 & 3 & 4 \\ a & b & c & d \\ x & y & z & w
     \end{bmatrix}$$ </td>
     <td> <code> \begin{bmatrix}<br>1 & 2 & 3 & 4 \\<br>a & b & c & d \\<br>
     x & y & z & w<br>\end{bmatrix} </code> </td> </tr>
<tr> <td> $$\begin{matrix} 1 & 2 & 3 & 4 \\ a & b & c & d \\ x & y & z & w
     \end{matrix}$$ </td>
     <td> <code> \begin{matrix}<br>1 & 2 & 3 & 4 \\<br>a & b & c & d \\<br>
     x & y & z & w<br>\end{matrix} </code> </td> </tr>
<tr> <td> $$\begin{array}{|c|c|c|c|}
     \hline 1 & 2 & 3 & 4 \\
     \hline a & b & c & d \\
     \hline x & y & z & w \\
     \hline
     \end{array}$$ </td>
     <td> <code> \begin{array}{|c|c|c|c|} <br>
     \hline 1 & 2 & 3 & 4 \\ <br>
     \hline a & b & c & d \\ <br>
     \hline x & y & z & w \\ <br>
     \hline <br>
     \end{array} </code> </td> </tr>

</table>

<h2> Cases </h2>

<p> The <code>cases</code> environment let's you specify functions piecewise, with
a left brace grouping the cases together. </p>

<table>

<tr> <td style='width: 15em'> $$u(x) = \begin{cases} e^x & \text{if } x \geq 0
        \\ 1 & \text{if } x < 0 \end{cases}$$ </td>
     <td> <code> u(x) =<br>
        \begin{cases}<br>
        e^x & \text{if } x \geq 0 \\<br>
        1 & \text{if } x < 0<br>
        \end{cases} </code> </td> </tr>

<tr> <td> $$V(x) = \begin{cases} 0, & x \lt 0 \\ V_0, & 0 \leq x \lt L \\
        0, & x \geq L \end{cases}$$ </td>
     <td> <code> V(x) =<br> \begin{cases}<br>
        0, & x \lt 0 \\<br>
        V_0, & 0 \leq x \lt L \\<br>
        0, & x \geq L<br>
        \end{cases} </code> </td> </tr>

</table>

<h2> Fonts </h2>

<table>

<tr> <td> Blackboard bold </td>
     <td> ##\mathbb {ABCDE}## </td>
     <td> <code> \mathbb {ABCDE} </code> </td> </tr>

<tr> <td> Calligraphic </td>
     <td> ##\mathcal {ABCDE}## </td>
     <td> <code> \mathcal {ABCDE} </code> </td> </tr>

<tr> <td> Fraktur </td>
     <td> ##\mathfrak {ABCDE}## </td>
     <td> <code> \mathfrak {ABCDE} </code> </td> </tr>

<tr> <td> Sans serif </td>
     <td> ##\mathsf {ABCDE}## </td>
     <td> <code> \mathsf {ABCDE} </code> </td> </tr>

<tr> <td> Roman (upright) </td>
     <td> ##\mathrm {ABCDE}## </td>
     <td> <code> \mathrm {ABCDE} </code> </td> </tr>

<tr> <td> Bold </td>
     <td> ##\mathbf {ABCDE}## </td>
     <td> <code> \mathbf {ABCDE} </code> </td> </tr>

<tr> <td> Typewriter </td>
     <td> ##\mathtt {ABCDE}## </td>
     <td> <code> \mathtt {ABCDE} </code> </td> </tr>

</table>

<h2> Bugs, tips and other notes </h2>

<p> If your LaTeX code includes something that looks like a BBcode tag for
formatting text in a forum post, e.g. <code>[i]</code> for italics, this will
likely mess up the rendering of your equation.  This happens because the forum
software (Xenforo) on PF's server interprets BBcode tags and converts them to
HTML tags before sending the page to your browser, where our LaTeX engine
(MathJax) runs using Javascript. The simplest way to fix this is to include a
space inside the brackets, e.g. <code>[ i]</code>. </p>

<ul>
<li> <a href="https://www.physicsforums.com/help/bb-codes">Complete list of
BBcode tags</a>
</ul>

<p> An alternative way of delimiting your LaTeX code is to enclose it between the
following BBcode tags: <code>[itex]...[/itex]</code> for inline equations (instead
of <code>##...##</code>), and <code>[tex]...[/tex]</code> for display-style equations
(instead of <code>$$...$$</code>).  However, the following
delimiters that are often used elsewhere do <b>not</b> work here on PF: <code>$...$</code>, <code>\(...\)</code> and
<code>\[...\]</code>. </p>

<p> If you have LaTeX code that was prepared in some other software, and uses
the <code>$...$</code> delimiters that don't work here, you can convert them
to <code>##...##</code> in an editor that uses regular expressions. Replace
<code>(^|[^\$])\$([^\$]|$)</code> by <code>$1##$2</code>. (Thanks to mfb for this
tip!) </p>

<p> If for some reason you want to post raw LaTeX code that includes the
delimiters, you can prevent the delimiters from being interpreted as delimiters.
Select a delimiter (only), click the <b>Text Color</b> icon (the one that looks
like a half moon) in the palette at the top of the editing window, and choose
black. Repeat for the other delimiter. </p>

<h2> Further information </h2>

<p> If you have questions about using LaTeX, you can ask them in our
<a href="https://www.physicsforums.com/forums/math-software-and-latex.189/">Math
Software and LaTeX</a> forum. If you have questions or suggestions about this
document, please post them in our
<a href="https://www.physicsforums.com/forums/feedback-and-announcements.19/">
Feedback and Announcements</a> forum.</p>

<p> For MathJax documentation, see the
<a href="http://docs.mathjax.org/en/latest/mathjax.html">MathJax web site</a>.
In particular, you can find a complete list of LaTeX commands supported by
MathJax
<a href="http://docs.mathjax.org/en/latest/tex.html#supported-latex-commands">here</a></p>

<h2> Acknowledgements </h2>

<p> LaTeX was originally implemented on PF thanks to the efforts of former admin
chroot.  Greg Bernhardt installed the current MathJax processor.  The original
version of this FAQ, for the vBulletin forum software that PF originally used,
was written or contributed to by Fredrik, micromass, Redbelly98, vela, Mark44, LCKurtz
and jtbell.  It was reformatted for the current Xenforo forum software by jtbell.
</p>
 
Physics news on Phys.org
  • #2
I would like to add 5 or so frequently asked questions and the answer to this page. It's a common resource and I get we can think of 5 FAQ questions and answers. Any come to mind?
 
  • #3
I haven't seen questions asked about the details of LaTeX; what I frequently have to do is point people to the primer in the first place because they aren't using LaTeX at all.
 
  • #4
Greg Bernhardt said:
I would like to add 5 or so frequently asked questions and the answer to this page.
  • How do I write a fraction?
Ans: ##\frac{num}{denom}## (inline)​
Examples: ##\frac 1 3## and ##\frac{x + 2}{2x + 6}##​
These render as ##\frac 1 3## and ##\frac{x + 2}{2x + 6}##​
Braces are necessary only if the numerator or denominator is longer than a single character.​
  • How do I write exponents and subscripts?
Ans: ##x^{-1}## and ##c_{10}(x + 1)^3##​
These render as ##x^{-1}## and ##c_{10}(x + 1)^3##​
Braces are required for exponents and subscripts only if the exponent/subscript is longer than a single character.​
  • How do I write an integral?
Ans: ##\int 2x + 3 ~dx## and ##\int_{t=0}^{10}t^2 + 1 ~dt##
These render as ##\int 2x + 3~dx## and ##\int_{t=0}^{10}t^2 + 1~dt##​
  • How do I write a summation?
Ans: ##\sum_{k=0}^\infty a_k##
This renders as ##\sum_{k=0}^\infty a_k##​
Using $ delimiters, this renders as $$\sum_{k=0}^\infty a_k$$​
  • How do I write Greek letters?
Ans: Here are a few lowercase Greek letters - ##\alpha, \beta, \theta, \lambda, \sigma##​
And a few uppercase Greek letters - ##\Gamma, \Psi, \Phi, \Theta, \Lambda, \Sigma##​
These render as ##\alpha, \beta, \theta, \lambda, \sigma## and ##\Gamma, \Psi, \Phi, \Theta, \Lambda, \Sigma##​
 
  • Love
Likes Greg Bernhardt

1. How do I start typing mathematical equations in LaTeX?

To start typing mathematical equations in LaTeX, you will need to use the \begin{equation} and \end{equation} commands to indicate the beginning and end of the equation. Inside these commands, you can use various symbols and commands to create your equation.

2. What is the syntax for typing mathematical equations in LaTeX?

The syntax for typing mathematical equations in LaTeX involves using a combination of symbols, commands, and text. Common symbols include + for addition, - for subtraction, * for multiplication, and / for division. Commands such as \frac for fractions and ^ for exponents can also be used. Text can be added using the \text command.

3. How do I add special symbols or characters in my equations?

To add special symbols or characters such as Greek letters or mathematical symbols in your equations, you can use the corresponding command in LaTeX. For example, \alpha for α, \beta for β, and \pi for π. You can also use the \symbolname command to add any symbol by its name.

4. Can I add equations in line with text in LaTeX?

Yes, you can add equations in line with text in LaTeX by using the \(equation\) command. This will put the equation in the same line as the text without numbering it. Alternatively, you can use the \begin{equation*} and \end{equation*} commands to create unnumbered equations.

5. How do I align multiple equations in LaTeX?

To align multiple equations in LaTeX, you can use the align environment. Within this environment, you can use the & symbol to indicate where you want the equations to be aligned. You can also use the split environment within align to align multiple equations on different lines.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Set Theory, Logic, Probability, Statistics
Replies
8
Views
141
  • High Energy, Nuclear, Particle Physics
Replies
7
Views
414
  • Precalculus Mathematics Homework Help
Replies
7
Views
882
  • Introductory Physics Homework Help
Replies
10
Views
927
  • Engineering and Comp Sci Homework Help
Replies
2
Views
4K
  • General Math
2
Replies
35
Views
2K
  • Programming and Computer Science
2
Replies
36
Views
2K
Back
Top