Generating output from a LaTeX project
After creating a LaTeX file, it needs to be built using the TeX distribution to generate an output PDF file. Lets look at how to generate an example output file from a LaTeX .tex
file.
Example HelloWorld.tex file
Here is an example Hello World file. You can type the following in a LaTeX editor and save the file as HelloWorld.tex
.
\documentclass{article}
\begin{document}
\title{Title of Document}
\author{Your Name}
\date{\today}
\maketitle
\tableofcontents
\section{Section Head}
Hello, world!
\section{Second Section Head}
This is the last thing I am going to say here!
\end{document}
Build the file
Next, build the file on the command line or in a LaTeX editor such as TeXworks. See Selecting a LaTeX distribution and editor for more information.
In TeXworks, for example, select the build option pdfLaTeX+MakeIndex+BibTex from the Build menu, then click Build (the arrow next to the dropdown menu).
Alternately, open a terminal (MAC) or Command Prompt (Windows) and change to the directory where you saved the file. Then run the following command twice to build the file and to generate a table of contents:
pdflatex HelloWorld.tex
pdflatex HelloWorld.tex
Completed build saved in root directory
In the directory containing HelloWorld.tex
you will find a whole bunch of new files in there. Find the file HelloWorld.pdf
and open it in a pdf viewer. You should see the following output.
LaTeX document with table of contents