# Commands and Special Characters¶

Commands are what LaTeX uses to translate plain text into a formatted document. Also known as control sequences, commands usually begin with a backslash, \ .

## Using Commands¶

Commands generally fall into one of two categories: commands which take arguments, and those which do not. Arguments are data given to the command in order for it to run. Most commands which do not take arguments are symbols, such as \epsilon. Others, such as the ubiquitous \begin, always take an argument. Some, like the \newcommand command, take two required arguments and one optional argument.

Optional arguments are included in square brackets. Optional arguments are not necessary for the command to be evaluated, and add more functionality to otherwise limited arguments.

The square root command, \sqrt{x}, can be made into an arbitrary root by using its optional argument \sqrt[10]{x}.

## Special Characters¶

Nine special characters within LaTeX are

### Caret and Underscore¶

The ^ and _ are used to create superscripts and subscripts respectively. They are considered control sequences, and act on the following token. They only work in math mode. Since LaTeX does not include native subscripts and superscripts in text mode, I use these commands as a workaround.

%Preamble
\newcommand{\subs}[1]{$_{\text{#1}}$}
\newcommand{\supe}[1]{$^{\text{#1}}$}

To use, pass the desired token to the appropriate command. For example, a\subs{0} will produce $$\text{a}_\text{0}$$ and a\supe{0} will produce $$\text{a}^\text{0}$$.

### Percent¶

The percent symbol creates comments. Everything following the percent sign on the same line will not be typeset.

### Tilde¶

The tilde is a non-breaking space character. It is a typography tool which prevents the insertion of a line break between tokens. So water~main will never allow the words water and main to be placed on separate lines. More accurately, between the tokens r and m as LaTeX will not normally break the words water and main into multiple lines. The non-breaking space also cannot be enlarged or shrunk, so it will force a standard space size. Normally, LaTeX automatically modifies individual spaces to justify the text.

### Poundsign¶

The poundsign is essential for creating new commands, indicating where the arguments of a command to be placed. See the New Commands lesson for more information.

### Ampersand¶

This is used within the align environments defined in the amsmath package. They allow equations to be precisely aligned. When just one ampersand is used in each line of equations, the characters immediately succeeding the ampersands will have their left sides lined up. There are more complex relations when more than one ampersand is used per line, and these are described in the amsmath package lesson.