How can I convert a .tex file to a PDF via the command line?

Is there a package that contains a TeX to PDF converter/renderer available on Ubuntu 12.04?

If not, can you recommend a tool for me to download from elsewhere that can do this that is simple to install?

• Welcome Triss, I investigated this a while back and I'm not sure there is a way via the command line. I use Lyx. You might find some useful information here though latex2rtf.sourceforge.net/ Jul 22, 2012 at 11:05
• @StephenMyall: Lyx is not a command line utility. Jul 23, 2012 at 6:40
• Im aware of that and thats why I commented rather than answer your question. I wanted to let you know that I had looked for a command line utility before for this type of conversion with no luck. I hope you have better luck. Jul 23, 2012 at 6:46

At the command line, first install the texlive package if it isn't already installed:

``````sudo apt-get install texlive
``````

Then use the pdflatex utility to convert the file like this:

``````pdftex /path/to/myfile.tex
``````

The path /path/to/myfile.tex is, of course, an example path. You would put the path to your own file on your system.

Notice that although the utility is called pdflatex you execute it with the command pdftex (without the la).

There are several settings that you can read about in the help for pdflatex:

``````pdflatex --help
``````

The setting I use the most is the one to generate the pdf in a different directory:

``````pdflatex --output-directory=../otherdir /path/to/myfile.tex
``````

The pdflatex utility is also interactive, so that if you forget to supply necessary information it will prompt you to enter it before converting the file.

• This should be the accepted answer.
– Sam
Oct 1, 2016 at 22:45
• pdftex and pdflatex don't seem to be the same thing. pdflatex supports LaTeX but pdftex doesn't (tex.stackexchange.com/a/258622) Oct 24, 2017 at 19:01
• I support @bmaupin's comment. TeX and LaTeX are not the same. If you force me to answer I had to make an educated guess that LaTeX is a 'superset' of TeX. Once aware it's trivial to switch between an e.g. wrongly `pdftex file.tex` to `pdflatex` but for the uninitiated it might be confusing as you casually switch from the former to the latter in your answer. Aug 27, 2020 at 17:45

As far as I know, you won't find a single standalone binary that will do this for you. The typical utility is called `pdflatex` and is part of the TeX Live package. It's in the repositories, so simply opening the terminal and typing the below will install `pdflatex` and lots of other essential TeX stuff:

``````sudo apt-get install texlive
``````
• For people who see this QnA, do visit tex.stackexchange.com and a sample pdf question tex.stackexchange.com/questions/149649/…
– abel
Dec 12, 2013 at 17:11
• The difficulty with this answer is that it doesn't actually tell the asker how to use the pdflatex utility to make the conversion on the command line. Since that was the question, this doesn't provide a full answer. (Some of us may be able to just read man pages, but for command-line novices who might read this some more explanation is important.) Jun 5, 2014 at 17:46
• You may also need `sudo apt install texinfo`. I did. Oct 28, 2016 at 11:41

You should try rubber. It is a command-line tool to handle all the tasks associated with compiling TeX documents into pdf, dvi, etc.

• rubber --pdf file.tex Apr 27, 2018 at 16:30

For Ubuntu 13.10 I suggest you use texlive-full. It worked for me but I'm non experienced user (:-)

To install it, open a terminal window and type or copy/paste:

``````sudo apt-get install texlive-full
``````
• Does this still apply for 15.x? Jan 4, 2016 at 18:59
• Better? No. `texlive-full` is just a huge archive that include lots of Latex related packages, including `texlive` itself (which in fact is shorthand for `texlive-base`). By installing `texlive-full` you will get lots of things you probably will never use, like `texlive-lang-czechslovak`. May 16, 2018 at 14:34