(Quote: Henry Cloud)
As you might have noticed, so far all we have done is insert text and equations into a document, which is sufficient to produce the main body of text. However we will also be wanting document titles, abstracts, section headers and breaks, author names, and the like in our document too - and all of these will need to be formatted differently to the main body of text. $\LaTeX$ helps us with this by the use of some more predefined commands; these commands impose a common structure and format across the entire document to provide us with that professional finish.
Let's start simple and have $\LaTeX$ automatically generate the title of our document, and automatically insert the author.
To do this we need to make use of the \maketitle
command, and also predefine a few things in the document preamble.
In the preamble we need to tell $\LaTeX$ the title of the document (via \title
) and the author(s) (via \author
).
We can also optionally provide $\LaTeX$ with the date the document should be signed with (via \date
) or let $\LaTeX$ autofill the date for us (\date{\today}
).
Then once we \begin{document}
, we insert the \maketitle
command and $\LaTeX$ will look up the information we added, and render the title in the default style for the document class.
NOTE: You can put the \maketitle
command anywhere in the document (and even in multiple times) and $\LaTeX$ will happily render your title in the place it is told, as many times as it's told.
Needless to say, this isn't recommended, but you can do it!
Try the following code in your editor and see for yourself:
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\title{On Contact with the Wizarding World}
\author{Phillip D. Student}
\date{\today}
\begin{document}
\maketitle % This line make the title show up at the beginning of your document
This is some text after your title has rendered.
\end{document}
%%pdflatex
\title{On Contact with the Wizarding World}
\author{Phillip D. Student}
\date{\today}
\maketitle % This line make the title show up at the beginning of your document
This is some text after your title has rendered.
In scientific documents, it's a common practice to include a brief overview of the main subject of the paper, or an abstract.
$\LaTeX$ has an environment, the creatively named abstract
environment, for this purpose.
The abstract
environment will put the text in a special format, typically making the text centre-aligned (rather than fixed-width alignment) and smaller than the main body of text.
Abstracts are typically short (no more than a paragraph say) but $\LaTeX$ won't stop you from entering as much as you want into the environment!
NOTE: Again, like the \maketitle
command, the abstract
environment can be placed anywhere and as many times as you like in a document, so make sure you put it in the right place.
In general it is bad practice to have more than one abstract
environment in a document, but again, $\LaTeX$ won't stop you (but it might complain).
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\title{On Contact with the Wizarding World}
\author{Phillip D. Student}
\date{\today}
\begin{document}
\maketitle % This line make the title show up at the beginning of your document
\begin{abstract}
The failure of world governments to make contact with the wizarding world, or rather the wizarding world's continued ability to shield themselves from us, has long stifled international development and induced tensions between non-magic users (so called ``muggles") and those with magic capabilities.
The work in this thesis explores methods that could potentially be exploited for removing the barrier that has been so carefully constructed to separate these two societies, by study of sources detailing life in the wizarding world.
The work in this thesis builds off the studies of Rowling, J. K; Lewis, C. S.; and Tolkien, J.R.R in it's investigation into the origin of the magic world and potential avenues to make contact.
\end{abstract}
This is some text after your title and abstract has rendered.
\end{document}
%%pdflatex
\title{On Contact with the Wizarding World}
\author{Phillip D. Student}
\date{\today}
\maketitle % This line make the title show up at the beginning of your document
\begin{abstract}
The failure of world governments to make contact with the wizarding world, or rather the wizarding world's continued ability to shield themselves from us, has long stifled international development and induced tensions between non-magic users (so called ``muggles") and those with magic capabilities.
The work in this thesis explores methods that could potentially be exploited for removing the barrier that has been so carefully constructed to separate these two societies, by study of sources detailing life in the wizarding world.
The work in this thesis builds off the studies of Rowling, J. K; Lewis, C. S.; and Tolkien, J.R.R in it's investigation into the origin of the magic world and potential avenues to make contact.
\end{abstract}
This is some text after your title and abstract has rendered.
As mentioned previously, commands to organise and break a document into parts depend on the document class you are using.
$\LaTeX$ uses these commands to automatically number and index parts of a document.
The most commonly used command to divide up a document is \section
; the command \section{title here}
will create a new section called title here
, a header in your document, and will renumber all the other sections
in your document to account for the new one.
Using sections also allows $\LaTeX$ to automatically generate a contents page in some documents.
Sections will be automatically numbered for you - if you don't want your section labelled, you put an asterisk after the \section
command (similarly to environments).
There are also commands for creating subsections, again creatively called \subsection{subtitle here}
which work in the same way as the parent \section
command.
In total, $\LaTeX$ will let you nest all the way into \subsubsubsection
- IE three levels below \section
!
You can also suppress the automatic numbering of \subsections
(and below) using an asterisk.
See the example below illustrating the use of sections and subsections.
%%pdflatex
\section{Benefits of Magic}
In this section we consider some of the benefits that having access to magic would bring on mankind.
\subsection{Benefits of Magical Animals}
There are several magical animals that are yet undiscovered that could provide huge boons to our everyday lifestyle and working environment.
Oliphaunts have the potential to eliminate the need for heavy construction machinery and heavy-goods transport, and provide little to no air pollution as an additional benefit.
Phoenixes, with their healing ability and ease of flight, could effectively act quickly to prevent disaster in environmental crises.
\section{Socio-Economic Considerations}
In this section we will explore some of the social and economic considerations that governments should discuss prior to making contact with the wizarding world.
\subsection*{On Responsible Use of Magic}
With great power comes great responsibility, and so it is only natural that the general population should be subject to a vetting process before being granted access to magical abilities and training.
In turn we should ensure that governments are not dominated by magic-using and muggle faction splits, else we create the very divide in society that we are working so hard to eliminate.
\subsection*{On Global Trade and Industry}
With the ability to apparate, several industries will be negatively impacted.
Commercial travel will be particularly affected, with predictions of up to 95\% loss of gross capital.
In turn the oil and gas industries will suffer from the decreased demand for commercially available fuel, but may benefit substantially from use of the alchemical craft to ``go greener", so to speak.latex article
Note that \section
(and the various sub
-s) are commands and not environments; this is why we don't \begin
and \end
them.
Also notice the placement of the asterisk on the \subsection*
command - it goes between the curly braces and the name of the command itself.
In $\LaTeX$ almost anything can be numbered, tracked, and referred back to using the \ref
and \label
commands.
Combined with the fact that $\LaTeX$ automatically handles updating the numbering, this means you can write and restructure your document almost at will.
Some of the common objects which can be referenced include:
The commands are used in the following way:
\label{marker}
: Gives the object you want to reference a marker, named marker
. Use this name when you want to refer back to this object.\ref{marker}
: Calls on the object with the specified marker. This will print the number that was assigned (automatically by $\LaTeX$) to the object.We can see some examples in the code below.
\documentclass[]{article}
\usepackage[utf8]{inputenc}
\begin{document}
\section{Benefits of Magic} \label{sec:BenefitsOfMagic}
In this section we consider some of the benefits that having access to magic would bring on mankind.
\subsection{Benefits of Magical Animals} \label{sec:Animals}
There are several magical animals that are yet undiscovered that could provide huge boons to our everyday lifestyle and working environment.
Oliphaunts have the potential to eliminate the need for heavy construction machinery and heavy-goods transport, and provide little to no air pollution as an additional benefit.
Indeed, we can even predict the resulting pattern in the concentration of carbon dioxide in the atmosphere ($c_{atm}$) on a timescale of years ($t$) after this switch, using equation (\ref{eq:C02Reduction}):
\begin{equation} \label{eq:CO2Reduction}
c_{atm} = c_{0} e^{-\sigma t},
\end{equation}
where $c_{0}$ is the current concentration of carbon dioxide in the atmosphere and $\sigma>0$ is the so-called ``Oliphaunt efficiency coefficient".
\section{Socio-Economic Considerations}
In this section we will explore some of the social and economic considerations that governments should discuss prior to making contact with the wizarding world.
\subsection*{On Global Trade and Industry}
In particular, in section \ref{sec:Animals} we highlighted some of the beneficial impacts of oliphaunts.
In particular we demonstrated that the concentration of carbon dioxide in the atmosphere would evolve according to equation \ref{eq:CO2Reduction}; inserting our predicted values for $\sigma$ and reported values for $c_{0}$ yields the conclusion that global carbon dioxide levels will fall to pre-industrial levels in as few as 7.5 years.
\end{document}
Notice how we don't have to label things we don't want to refer back to (so we didn't give \section{Socio-Economic Considerations}
a label), nor does $\LaTeX$ mind if we give something a label and then don't ever refer to it (\section{Benefits of Magic}
).
There is also no need to include the sec:
or eq:
parts of the markers in your labels, however we recommend adopting a system like this as it will help you keep track of the content of your document!
You'll notice that the \ref
command for our equation reference is placed in brackets - removing these brackets will simply print the equation number, however it is common practice to reference equation numbers in parentheses.
If you have loaded the amsmath
package, you can replace the \ref
command with the \eqref
command; it behaves in exactly the same way but will automatically enclose the reference number in brackets.
From here on out, we will tend to use \eqref
for equations, and \ref
for everything else.
You can download the source code (.tex
) file for the document that was created in this lesson by clicking here.