# Compiling a LaTeX document manually

I've created LaTeX documents before using 'nice IDEs' such as TeXnicCenter and have a little experience in general with TeX, however, now I'm wondering about creating one "manually". By that, I mean doing something such as writing the tex document in a very simple editor (such as VIM) and then compiling it myself with pdflatex via the command prompt. Has anyone ever done this and if so, I really just need to know how I'd go about it? What's the process to doing it? While the IDE is nice, I'd really like to be able to create LaTeX documents 'on my own'. Thanks for any information you can provide!

-
Err ... just go ahead and do it! This is how I've always created my LaTeX documents (except that I use Emacs, not vim). I don't even know what "IDE" stands for. – Loop Space Apr 28 '11 at 18:19
I can't tell if you're being facetious or not, but if not IDE == Integrated Development Environment. – JToland Apr 28 '11 at 18:22
"in a very simple editor (such as VIM)". VIM is one of the most complex editors in existence. I assume you mean "simple" as "without a fancy graphical interface", which is true for VIM. Also, I never knew that TeXnicCenter can create LaTeX documents "automatically". – Martin Scharrer Apr 28 '11 at 18:42
Well, in reality, probably not the command line, but something like Cygwin. And Yes, I'm on Windows. By TeXnicCenter automatically creating documents, I mean I just have to type the 'code', then push a button and somehow I have a pdf document -- all the work is done for me to get from code to pdf. I just wonder how (and what I'd need) to do it myself with commands starting with just the tex document. – JToland Apr 28 '11 at 18:51
You would need a functioning TeX distribution like MiKTeX. Then you just go to command prompt and write pdflatex yourdocument.tex, or yourtexengine yourdocument.tex. – ipavlic Apr 28 '11 at 20:41

Your question is a little confusing. What you mean is compiling a LaTeX document manually (into a PDF). You might want to adjust your title. Creating one would be the process of writing the document. This can be done in the command line using pdflatex <filename>. In VIM you could just use ESC:!pdflatex % (% can be used instead of the current filename) when you edit the main file. There is also the LaTeX Suite for VIM which gives you short cuts for the compilation and a lot of IDE functionality. The LaTeX compiler must be in your PATH for this to work, but this should be already the case for a proper installed LaTeX.

The latexmk script (also called with the filename) will compile the LaTeX document as often as required and also run external tools like bibtex and makeindex, which is basically the things the IDE is doing automatically when you press the compile button.

-
Oh come on, you don't have to tear his question to pieces like this. His last comment clarifies his post perfectly well. He has so far used a program that created the pdf with the press of a button, and now wants to know if there's anything he needs to know about producing (La)TeX output so by entering commands into some interface. There's really no reason to ridicule some minorly suboptimal wording in this manner. – doncherry Apr 28 '11 at 20:08
See, your edit about latexmk is something someone coming from TeXnicCenter wouldn't know, for example. That's the kind of thing he was asking for. I think a GUI made him feel like he's "triggering a whole bunch of complex commands" (I'm exaggerating), and I'm sure he's right in the respect that there's certainly a lot to learn what can be done instead of "clicking that button", just like latexmk. – doncherry Apr 28 '11 at 20:34
@doncherry: I rewrote the answer to be more useful. – Martin Scharrer Apr 28 '11 at 20:38
Great, I think he'll be much happier with this response :) I hope you didn't take my criticism amiss, I just didn't feel like this was the way we want to answer questions here. – doncherry Apr 28 '11 at 20:53
Thank you for the edit. This is supremely more helpful than your initial answer. – JToland Apr 28 '11 at 20:54

Create the file then compile it, just like you think you should. If your editor supports macros, define one (or two for Bibtex). However, I think it is better to stick with modern IDEs so you can take advantage of synchronized PDF previewing.

-

Here is a basic tutorial for a Unix-like system (tested on Debian GNU/Linux). Yes, one can use latexmk, arara, shell scripts, or editor functions to automate much of this, but I wanted to demonstrate the simplest way to write and compile a LaTeX file "by hand" in the terminal.

• Open Terminal emulator
• Enter a directory where you will create your files. Type the command cd /tmp, or instead of /tmp another directory you have permission to write to, like ~/Documents/.
• Open the text editor in the terminal. Enter one of these commands:
• nano hello.tex (easiest to use for first time)
• vim hello.tex
• emacs hello.tex
• Within the editor, type in the following code:

(file hello.tex:)

\documentclass{article}
\begin{document}

\title{Hello and Goodbye}
\date{\today}
\maketitle

\tableofcontents

\section{Hello}
Hello, world!
\section{Goodbye}
Goodbye, world!

\end{document}


• Save the file in the editor and quit the editor. Check for the file you created by listing the directory contents: ls.
• Compile the document. Run pdflatex twice to get the table of contents. (Remember, in most terminals you can use the Up arrow on the keyboard to get the most recently entered command.)
pdflatex hello
pdflatex hello

• View the PDF you created. Use any PDF viewer: mupdf hello.pdf or evince hello.pdf (on Mac, open hello.pdf)

This procedure then continues: edit the file in the text editor, compile the file, preview the PDF.

You can make this system less cumbersome (depending on your perspective) by using a terminal multiplexer like tmux or screen, or just using multiple Terminal application windows. Then you can have one panel or window for editing the document in the text editor, and another panel or window for compiling it. If you have screen space, you can even keep a third window open with a PDF viewer; evince on Debian and Preview on Mac will update the PDF every time you recompile.

(PS - It's also a good idea to use git or another version-control program. At the end of your session make sure you add the new file, or any changes to files, to your repository and then push to your offsite backup repository.)

-

You can try AutomaticTexPlugin. It can compile documents on the fly or in the backround, so you do not waste the time, while waiting for the compilation. It also has a nice progress bar, which is serves well especially for big files. But the best point of this plugin is its excellent completion with lots of features (some people say that the only feature that is missing is that of writing the proofs by itself). Checkout the list of features (which is not even complete). The forward and backward search works out of the box for major linux and macos pdf viewers.

-