Useful LaTeX code

topsquark

Math Team
May 2013
2,508
1,048
The Astral plane
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

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

mathman

Forum Staff
May 2007
6,928
772
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
May 2013
2,508
1,048
The Astral plane
\(\displaystyle \sum_{n = 1}^{N} n^2\)

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

-Dan
 

SDK

Sep 2016
792
539
USA
\(\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$.
 
  • Like
Reactions: topsquark

mathman

Forum Staff
May 2007
6,928
772
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

Sep 2016
792
539
USA
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.
 
  • Like
Reactions: topsquark

mathman

Forum Staff
May 2007
6,928
772
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
Jul 2011
3,354
1,845
Texas
$\displaystyle \sum_{n=1}^N n^2$

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