Hot answers tagged

374

Matrices Use $$\begin{matrix}…\end{matrix}$$ In between the \begin and \end, put the matrix elements. End each matrix row with \\, and separate matrix elements with &. For example, $$ \begin{matrix} 1 & x & x^2 \\ 1 & y & y^2 \\ 1 & z & z^2 \\ \end{matrix} $$ produces: $$ \begin{matrix} 1 & x &...


272

Aligned equations Often people want a series of equations where the equals signs are aligned. To get this, use \begin{align}…\end{align}. Each line should end with \\, and should contain an ampersand at the point to align at, typically immediately before the equals sign. For example, \begin{align} \sqrt{37} & = \sqrt{\frac{73^2-1}{12^2}} \\ & = ...


222

Definitions by cases (piecewise functions) Use \begin{cases}…\end{cases}. End each case with a \\, and use & before parts that should be aligned. For example, you get this: $$f(n) = \begin{cases} n/2, & \text{if $n$ is even} \\ 3n+1, & \text{if $n$ is odd} \end{cases}$$ by writing this: f(n) = \begin{cases} n/2, & \text{if $n$ is ...


156

Arrays It is often easier to read tables formatted in MathJax rather than plain text or a fixed width font. Arrays and tables are created with the array environment. Just after \begin{array} the format of each column should be listed, use c for a center aligned column, r for right aligned, l for left aligned and a | for a vertical line. Just as with ...


147

Fussy spacing issues These are issues that won't affect the correctness of formulas, but might make them look significantly better or worse. Beginners should feel free to ignore this advice; someone else will correct it for them, or more likely nobody will care. Don't use \frac in exponents or limits of integrals; it looks bad and can be confusing, which is ...


120

Crossing things out Use \require{cancel} in the first formula in your post that requires cancelling; you need it only once per page. Then use: $$\require{cancel}\begin{array}{rl} \verb|y+\cancel{x}| & y+\cancel{x}\\ \verb|\cancel{y+x}| & \cancel{y+x}\\ \verb|y+\bcancel{x}| & y+\bcancel{x}\\ \verb|y+\xcancel{x}| & y+\xcancel{x}\\ \verb|y+\...


113

System of equations Use \begin{array}…\end{array} and \left\{…\right.. For example, you get this: $$ \left\{ \begin{array}{c} a_1x+b_1y+c_1z=d_1 \\ a_2x+b_2y+c_2z=d_2 \\ a_3x+b_3y+c_3z=d_3 \end{array} \right. $$ by writing this: $$ \left\{ \begin{array}{c} a_1x+b_1y+c_1z=d_1 \\ a_2x+b_2y+c_2z=d_2 \\ a_3x+b_3y+c_3z=d_3 \end{array} \right. $$ ...


107

Colors Named colors are browser-dependent; if a browser doesn't know a particular color name, it may render the text as black. The following colors are standard in HTML4 and CSS2 and should be interpreted the same by most browsers: $$\begin{array}{|rc|} \hline \verb+\color{black}{text}+ & \color{black}{text} \\ \verb+\color{gray}{text}+ & \color{...


103

Additional decorations $\def\demo#1#2{#1{#2}\ #1{#2#2}\ #1{#2#2#2}}$ \overline: $\demo\overline A$ \underline: $\demo\underline B$ \widetilde: $\demo\widetilde C$ \widehat: $\demo\widehat D$ \fbox: $\demo\fbox {$E$}$ \underleftarrow: $\demo\underleftarrow{F}\qquad$ variant: \xleftarrow{}: $\xleftarrow{abc}$ \underrightarrow: $\demo\underrightarrow{...


101

Provide Context Context matters. A question can sometimes be answered in one sentence when the discussion is between two experts familiar with each other's background, while the same question may take many paragraphs of detailed computation when being shown to an undergraduate student. By providing a context you help the potential responders to your ...


98

Commutative diagrams AMScd diagrams must start with a "require": $\require{AMScd}$ \begin{CD} A @>a>> B\\ @V b V V= @VV c V\\ C @>>d> D \end{CD} to get this diagram: $\require{AMScd}$ \begin{CD} A @>a>> B\\ @V b V V= @VV c V\\ C @>>d> D \end{CD} @>>> is used for arrow right @<<< is used for arrow ...


87

Continued fractions To make a continued fraction, use \cfrac, which works just like \frac but typesets the results differently: $$ x = a_0 + \cfrac{1^2}{a_1 + \cfrac{2^2}{a_2 + \cfrac{3^2}{a_3 + \cfrac{4^4}{a_4 + \cdots}}}}$$ Don't use regular \frac or \over, or it will look awful: $$ x = a_0 + \frac{1^2}{a_1 + \frac{2^2}{...


83

Using \newcommand I would like to remark that it is possible to define LaTeX commands as you do in your TeX files. I felt so happy when I first discovered it! It's enough to insert something like $ \newcommand{\SES}[3]{ 0 \to #1 \to #2 \to #3 \to 0 } $ $ \newcommand{\SES}[3]{ 0 \to #1 \to #2 \to #3 \to 0 }$ at the top of your post (remember the dollars!). ...


83

Tags & References For longer calculations (or referring to other post's results) it is convenient to use the tagging/labelling/referencing system. To tag an equation use \tag{yourtag}, and if you want to refer to that tag later on, add \label{somelabel} right after the \tag. It is not necessary that yourtag and somelabel are the same, but it usually is ...


79

\implies ($\implies$) is a marginally preferable alternative to \Rightarrow ($\Rightarrow$) for implication. There's also \iff $\iff$ and \impliedby $\impliedby$. \to ($\to$) is preferable to \rightarrow or \longrightarrow for things like $f\colon A \to B$. The reverse is \gets ($\gets$).


68

Big braces Use \left and \right to make braces - (round), [square] and {curly} - scale up to be the size of their arguments. Thus $$ f\left( \left[ \frac{ 1+\left\{x,y\right\} }{ \left( \frac{x}{y}+\frac{y}{x} \right) \left(u+1\right) }+a \right]^{3/2} \right) $$ renders as $$ f\left(\left[ \frac{...


66

My view has always been that programming questions are very much borderline. Here is the border, as I see it. Your question is about the mathematics of the algorithm. This could be about a specific implementation, but the question has to be mathematical. That question is on-topic here. Your question is about the implementation of your code. It is about the ...


65

Limits To make a limit (like $\lim \limits_{x \to 1} \frac{x^2-1}{x-1}$), use this syntax: First, start off with $\lim. This renders as $\lim$. The backslash is there to prevent things like $lim$, where the letters are slanted. Second, add \limits_{x \to 1} inside. The code now looks like $\lim \limits_{x \to 1}$, and renders as $\lim \limits_{x \to 1}$. ...


57

Arbitrary operators If an operator is not available as a built-in command, use \operatorname{…}. So for things like $$\operatorname{arsinh}(x)$$ write \operatorname{arsinh}(x) since \arsinh(x) will give an error and arsinh(x) has wrong font and spacing: $arsinh(x)$. This was already mentioned in a comment by Charles Staats. You might consider this an ...


55

A good title The title of a question is the first thing people see. Like headings in newspapers, book, song and album titles, their importance is not to be underestimated -- the presence of a good, descriptive title for your question often greatly improves the exposure (and hence the amount and quality of answers) it gets. To ensure maximal descriptiveness ...


52

Highlighting equation To highlight an equation, \bbox can be used. E.g, $$ \bbox[yellow] { e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (1) } $$ produces $$ \bbox[yellow] { e^x=\lim_{n\to\infty} \left( 1+\frac{x}{n} \right)^n \qquad (1) } $$ By default, the bounding box is "tight", so it doesn't extend beyond the characters used in the ...


48

Absolute values and norms The absolute value of some expression can be denoted as \lvert x\rvert or, more generally, as \left\lvert … \right\rvert. It renders as $\lvert x\rvert$. The norm of a vector (or similar) can be denoted as \lVert v\rVert or, more generally, as \left\lVert … \right\rVert. It renders as $\lVert v\rVert$. (You may also write \left\|…\...


48

Giving reasons on each line of a sequence of equations To produce this: \begin{align} v + w & = 0 &&\text{Given} \tag 1\\ -w & = -w + 0 && \text{additive identity} \tag 2\\ -w + 0 & = -w + (v + w) && \text{equations $(1)$ and $(2)$} \end{align} write this: \begin{align} v + w & = 0 &&\text{...


45

Avoid "no clue" questions Too many questions begin or end with "I don't even know how to begin with this problem". While this may be true (you may genuinely have no idea how to approach the problem), it is still not a valid reason to limit your post to the statement of the problem without any mention of your own thoughts. Such questions will most of the ...


42

Pack of cards If you are asking (or answering) a combinatorics question involving packs of cards you can make it look more elegant by using \spadesuit, \heartsuit, \diamondsuit, \clubsuit in math mode: $$\spadesuit\quad\heartsuit\quad\diamondsuit\quad\clubsuit$$ Or if you're really fussy: \color{red}{\heartsuit} and \color{red}{\diamondsuit} $$\color{red}{\...


40

Why do we have a policy? First and foremost: we believe that the responsibility for the integrity of an exam, contest, competition, etc. ultimately falls on the shoulders of the organizers. That said, the Mathematics Stack Exchange community is not an island unto itself: rather we exist within a larger macrocosm of people who do or are interested by ...


39

Left and Right Implication Arrows Another way to display the arrows for right and left implication instead of using $\Rightarrow$, $\Leftarrow$ and $\Leftrightarrow$ which produces $\Rightarrow$, $\Leftarrow$ and $\Leftrightarrow$ respectively, you can use $\implies$ for $\implies$, $\impliedby$ for $\impliedby$ and $\iff$ for $\iff$ The latter of which ...


39

Mathematical typesetting using MathJax Mathematics.SE uses the emulation engine MathJax for providing $\TeX$-like mathematical typesetting. This means that you can use mathematical notation in your questions in a visually appealing way. How can I use MathJax? Basic information: This gives a quick start for people familiar with the $\TeX$-family of markup ...


36

In addition to the below title-specific $\rm\LaTeX$ guidelines, there is of course the MathJax tutorial and quick reference. The primary rule for using $\rm\LaTeX$ in titles is to be vertically terse. Try to make your title take up as little vertical space as possible (the height of $\sum\limits_{n=1}^\infty$ is an approximate upper bound for what is ...


Only top voted, non community-wiki answers of a minimum length are eligible