Tuesday, January 4, 2011

LaTeX

I found out about LaTeX last year (oh wait -- 2009's two years ago now!).  It's similar to Word in that it makes typed documents, but it's really not the same.

Microsoft Word is a WYSIWYG (What-You-See-Is-What-You-Get) program, meaning that whatever is currently displayed on the screen is exactly what you're getting.  If you hit the print button, it will print out the document for you, as it is shown on the screen.

However, LaTeX is like programming.  You type in "code" that tells the program what kind of document to create and what text, pictures, and other stuff to include in it.  Then, you "build" your document, similar to compiling code in a programming language like C#.  It can output to several different file formats, but I prefer the PDF because it is so universal and widely used.

There are a few advantages of this:
  1. The document after it is processed appears much more professional, and uses advanced typesetting algorithms and such.  For example, if there are two "f" letters in a row, they are supposed to be connected.  Of course, Word doesn't do this for you, but LaTeX will.
  2. Although you can make Word documents into PDFs, it's not automatic whereas PDF files can be opened anywhere.  The code can be edited with a simple text editor, such as the feature-empty Notepad that comes with Windows.
  3. You can even use online compilers, (just Google : "Online LaTeX Compiler").  That means you can do your stuff anywhere you want.
  4. LaTeX is designed especially for writing professional-looking reports, including scientific ones.  As such, processing code for math typesetting (like the fraction bar, nested radicals, and Greek letters).
  5. You're learning how to use a handy tool that you might have to use when you go to college (or whenever you do professional science work).

Now that you're totally excited and want to try this out, you probably want to know how to get it on your computer!  Luckily, it's really easy.

First, download and install MiKTeX, which includes all the files you'll need to format these documents and build them from the ground up.  I recommend going to http://miktex.org/ and downloading the latest version.  You can either get the Basic or Complete setup.  It's barely worth mentioning due to the obviousness, but the Basic setup will take less time to install than the full thing.  NOTE: Remember what folder you installed MiKTeX to because you'll need to reference that folder later!


Now that you have the files that form the backbone, we need some User Interface.  TeXnicCenter was created to work with MiKTeX and make your job as easy as possible.  Go to http://www.texniccenter.org/resources/downloads to download it, and again, get the latest stable version.

This one should install pretty quickly, so just follow the prompts.  When it's done, run the program, and it will give you a wizard to help you set it up.  It will ask for the location of the executables, so go to your install folder to MiKTeX, and find the a folder called "miktex".  In that folder, there's another folder called "bin".  Copy the entire address of this folder and put it into the prompt for the path to the executable files.  You can leave everything else blank.

If you screw up, then you can just open up TeXnicCenter and go to "Build" --> "Define Output Profiles..." (or Alt + F7), and click "Wizard..." at the bottom-left corner of the dialog window that pops up.  Now you can try again!

After you set it up correctly, it's all yours to play with.  First, you should change the dropdown menu to say "LaTeX => PDF" unless you want to build to some other format.  I like to rearrange the toolbars so that they only take up 2 rows at the top.  Then, I close the "Navigator" on the left side so I can have more screen space.  It's all up to you to do what you want to make it as nice as possible.  You might want to play with the options in the "Tools" menu.

Now you can create your first document.  I recommend that you start with this as a template, since LaTeX needs a few things before you can actually type out your stuff.  Here's the code that you can use:


\documentclass[12pt,letterpaper]{article}
\usepackage[margin=2.5cm]{geometry}
\begin{document}
\title{}
\author{}
\maketitle

\end{document}


In the blank line, you can start typing out your document.  You can put your title in the brackets after "\title" and your name in the brackets after "\author".  If you don't want a cool, fancy header, you can just delete the lines between (but not including) "\begin{document}" and "\end{document}".

Now you have to build an output file.  Just go to the "Build" menu and then use the things there.  A few nice shortcuts are [Ctrl + Shift + F5] to build and view the output, [F7] to just build the file, and [F5] to just view the output.

That was just a very brief introduction to the world of LaTeX.  I'm not a complete pro at this, but I'll probably make a post in the future about how to do the basics.

Have fun making professional-looking PDF documents now!

No comments:

Post a Comment