Tutorials, Guides, Tips, and Tricks from Everyday Experiences

Most of the guides I came across were just wildly all over the place, so I figured a short and simple guide that gets right to the point would be useful. Here’s how to set up Fedora 15 to build (compile might be another word) a .tex file into a .pdf file from the command line. It can be applied to other Linux distributions as well. There are GUIs to help with this, but it’s best to start with the basics. So, fire up a terminal and let’s get started.

Step 1: Install the TexLive Package

The first thing we need to do is install the texlive package.

su -c 'yum install -y texlive'

Depending on your distribution, you may also need to install the texlive-latex-extras package.

Step 2: Prepare a .tex Document

Next, we’ll create a “hello world” type .tex file. Fire up your favorite text editor and copy/paste the following (I enjoy using vim since I can stay in the command line while building the LaTeX file). When you’re finished, save the file (I’ve saved it as “hello.tex”).

Notice the text “Output written on hello.pdf (2 pages, 22507 bytes).”. That means it worked.

Step 4: View the New PDF File

Now, all you need to do is view the generated PDF document. Run the following command:

evince hello.pdf

Note, if you’re like me, you constantly flip between the source and the pdf. If that’s the case, evince will automatically update the pdf every time you re-build using pdflatex. Simply add “&” on the end of the command above:

evince hello.pdf &

This is what you should be seeing when completed:

Alternative: Rubber

I’d like to make a special note about the ‘rubber’ utility. It can take a lot of the guess work out of building LaTeX files and I strongly recommend using it over pdftex or pdflatex as mentioned above. You can install and run the ‘rubber’ utility with the following commands:

su -c 'yum install -y rubber'
rubber --pdf hello.tex

Conclusions

I hope this helps you get started moving quickly in the right direction. Comments and feedback are welcome.

Apparently, there’s a difference between pdflatex and pdftex. Understand this when moving forward. I would recommend using the command rubber --pdf hello.tex instead since it takes care of the decision for you (as well as offers many other benefits — man rubber for more info).

Related

Feel free to
donate if this post prevented any headaches! Another way to show your appreciation is to take a gander at these relative ads that you may be interested in: