(click anywhere to close)

# [LaTeX] Basic Syntax I

category: Writing | course: LaTeX | difficulty:

Because LaTeX’s a markup language, the majority of your file will simply be regular text. Therefore, something is needed to tell the computer when a piece of text is actually a command. For this, we always use the backslash: \.

For example, \emph is used for emphasizing a piece of text, and \newline is used to start text on a new line.

Commands are often called command sequences or macros. This is because of the fact that one command encompasses a sequence of steps to be taken. For example, a command to create a table, has to perform lots of sequential calculations and operations to do so.

## Arguments

Commands require arguments, which can be required or optional. These can be mixed – a command can have some required and some optional arguments, or only optional ones, or only required ones. And in some rare cases, no arguments at all.

## Required Arguments

For example, when emphasizing a piece of text, we need to supply which piece of text we want emphasized. It’s required – if we leave it out, it emphasizes nothing. Some commands go even further, and throw errors when you don’t supply the required arguments.

Required arguments are placed between braces:

\command{argument1}{argument2}{…}

This text is \textit{written in italics}


## Optional Arguments

For example, if we want to insert a new line, we could supply how much white space we want between this new line and the previous one. But, if we leave it out, everything’s fine, and it just takes the standard line height.

Optional arguments are placed between brackets, and separated by commas if there are multiple:

\command[argument1, argument2, …]

This is a\\regular line break.

This is a\\[20mm] longer line break


## Combined Arguments

When a command has both optional and required arguments, you always need to provide the optional ones first.

\begin{thebibliography}{2}
\bibitem[SomeText]{book1} Book 1, written by Someone, in 1900
\bibitem{book2} Book 2, written by Someone Else, in 1950
\end{thebibliography}


The only moments it’s possible that you need to switch around the order of arguments, is when working with special commands provided by packages. In these cases, this deviation from standard syntax will be mentioned.

## Nesting Commands

As you’d expect, you can nest commands as much as you like, although it’s of course preferred to keep the mark up as simple and readable as possible.

CONTINUE WITH THIS COURSE
Do you like my tutorials?
To keep this site running, donate some motivational food!
Crisps
(€2.00)
Chocolate Milk
(€3.50)
Pizza
(€5.00)