# Useful LaTeX code

#### topsquark

Math Team
I thought I'd make a new thread for some snippets of more "advanced" LaTeX codes that are not covered by the basic LaTeX tutorial.

For example:
$$\displaystyle \enclose{circle}{x}$$
\enclose{circle}{x}

$$\displaystyle A \overset{u}{=} B$$
A \overset{u}{=} B

$$\displaystyle A \overset{u}{ \rightarrow} B$$
A \overset{u}{ \rightarrow } B

$$\displaystyle A \underset{d}{ \rightarrow } B$$
\underset{b}{ \rightarrow } B

$$\displaystyle A \overset{u}{\underset{d} \rightleftarrows} X$$
A \overset{u}{ \underset{d} \rightleftarrows } X

(I got the first one from Klaas van Aarsen. Thanks!)

-Dan

#### SDK

I've been using LaTeX daily for ~10 years and I never knew the first example. Thanks!

#### mathman

Forum Staff
When I want to express a sum, the indices always end up in front of the Sigma. How to I get them above and below?

#### topsquark

Math Team
$$\displaystyle \sum_{n = 1}^{N} n^2$$

\sum_{n = 1}^{N} n^2

-Dan

#### skipjack

Forum Staff
I never knew the first example.
One can even do $\enclose{circle}[mathcolor="green"]{\color{blue}{this}}$.

topsquark and SDK

#### SDK

$$\displaystyle \sum_{n = 1}^{N} n^2$$

\sum_{n = 1}^{N} n^2

-Dan
This only works in math mode. I think he is referring to inline mode where the same code produces this: $\sum_{n = 1}^{N} n^2$. However, you can produce the "nice" sums inline as well if you use /sum/limits_{n = 1}^{N} n^2 with forward slashes replaced by backslashes. This produces the inline formula $\sum\limits_{n = 1}^{N} n^2$.

topsquark

#### mathman

Forum Staff
This only works in math mode. I think he is referring to inline mode where the same code produces this: $\sum_{n = 1}^{N} n^2$. However, you can produce the "nice" sums inline as well if you use /sum/limits_{n = 1}^{N} n^2 with forward slashes replaced by backslashes. This produces the inline formula $\sum\limits_{n = 1}^{N} n^2$.
Is there a way to switch between in-line and math modes? When I use LaTex it is always in-line.

#### SDK

Is there a way to switch between in-line and math modes? When I use LaTex it is always in-line.
Inline formulas are delimited with \$\$ and math mode is delimited by \ [ \ ] without spaces between the slashes/brackets. Alternatively, you can use the equation environment for a similar effect which allows numbering/labeling.

topsquark

#### mathman

Forum Staff
Inline formulas are delimited with \$\$ and math mode is delimited by \ [ \ ] without spaces between the slashes/brackets. Alternatively, you can use the equation environment for a similar effect which allows numbering/labeling.
I have found there is no standard delimiting rules for LaTex. Each forum appears to have its own rule.

#### skeeter

Math Team
$\displaystyle \sum_{n=1}^N n^2$

\$\displaystyle \sum_{n=1}^N n^2\$