LaTeX Follow Up

So we only had three people show up, but that’s better than none! If anyone else is interested, post a comment, and we’ll try to set up another session.As for what we discussed — see below!

Although there were only three of us, we managed to cover the basics of installing WinEdt and MiKTex, and basic document formatting.

Installation

I already have both WinEdt and MiKTex on my laptop, as well as having Cygwin (a unix-like-shell for windows) with LaTeX installed as an add-on. If I boot up in Linux, (SUSE), then I have LaTeX installed there also. The nice thing about Mac OSX, is that it is built over unix, so installing LaTeX is pretty easy and you can use it in a shell terminal, but I am not aware of an editor similar to WinEdt available for the Mac. (If anyone knows, post a comment, and I’ll add a link).

It seems as though it doesn’t matter in which order you install WinEdt and MiKTeX: WinEdt will recognize MiKTeX if it’s already there, and will incorporate it if you add it later. Nick already had MiKTeX on his laptop, so we only had to add in WinEdt (which I just put the .exe on my thumb drive and handed it to him, no internet connection was required). He ran the executable and everything came up just fine. Note that WinEdt is shareware, and you’ll get an annoying pop-up after 31 days. I have tried registering (since I like the software enough to pay for it), but the link is (annoyingly) broken, so I just put up with it. I’ll try again in a month or so and see if they’ve fixed it.

Document Formatting

So – now that we (and hopefully you too have) had some version of LaTeX and an editor on our computer, we began to talk about document formatting. Sam’s comment was quite true, “Aw great – computer programming.” A Latex document is written in a markup language, a text document formatted to be read by some program (in this case, LaTeX or MiKTeX) and used to produce some output. Here’s the basic layout:

\documentclass{article}
\begin{document}
Text Here.
\end{document}

Everything between ‘\begin{document}’ and ‘\end{document}’ is what LaTeX turns into an output. The first line (and everything else before ‘\begin{document}’ in more complex documents) tells LaTeX how to format everything.

My homework assignments for Dr. Erdman’s class begin with:

\documentclass{article}
\usepackage{fancyhdr}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{amssymb}

\setlength{\parskip}{1ex}

\pagestyle{fancy}
\lhead{}
\chead{}
\rhead{\bfseries Eric Riley}

\author{Eric Riley}
\date{\today}
\title{Homework \#12 for MTH 511}

\begin{document}

That’s a lot of stuff, but let’s break it down a bit: we’ve already seen the ‘\documentclass{article}’, there are other document classes as well, but I haven’t needed to use them; next we have a series of ‘\usepackage{stuff}’, this tells LaTeX to go look up some specific files that allow me to use some commands that don’t exist in the basic LaTeX setup. Most of them are AMS packages (that allow some extra math symbols), and there’s also the ‘fancyhdr’ package that I use to put a bar across the top of each page with my name in the upper right; next we have a command to put some space between paragraphs (because I like it that way); and the series of fancy header commands that make the bar and put my name in the upper right (notice how I could also add something to the center and left if I want – leaving them blank doesn’t hurt); finally, I let LaTex know who wrote this thing, what I want to call it, and what date to use (‘\today’ will insert the date you run LaTeX on the file, not the date you write the file!)

Then we’re ready to \begin{document}!

Commands and Comments (a digression)

Some things to notice: every single thing I’ve put in starts with a ‘\’, and many of them have something in ‘{}’. Commands in LaTeX start with the backslash, and take parameters in curly braces. If the command also has options, these can be put into square braces: [option]. As an example, we could:

\documentclass[11pt, A4paper]{article}

Which tells LaTeX pretty clearly that we want to change from the default ‘article’ format to a smaller font size and a different paper (A4 instead of letter).

If you want to comment what you are writing, or stop some command from being used, use the ‘%’ to comment. Everything after the % to the end of the line will be ignored (as well as the linebreak and any white space at the start of the next line…). Homework is simple enough that I usually don’t comment any of it (or very rarely), but more complex documents might need some comments so when you re-use your format, you know what is going on!

Content: What are we going to write?

So now we are to the meat of the document: the stuff between ‘\begin{document}’ and ‘\end{document}’. This part is pretty easy – expecially if you are using WinEdt! You type what you are going to say. That’s it. Well- there’s a little more:

First we need to tell Latex to make the title (using the information about author and title and date we already gave it:

\maketitle

For homework, I break each problem into its own section, so the next thing we see is:

\section*{Example 8.2.3}

If I want the sections numbered, I would use ‘\section{}’ instead of ‘\section*{}’ and everything in the braces gets printed in bold as the section heading (I usually use the statement of the problem there). In general, any of the commands that ‘section’ the document in any way have a starred version that eliminated section numbering, and an unstarred version that automatically numbers the sections.

Math Environments

Now – as I am typing mathematics, I may need to use some math symbol, for example, I may want to talk about the intersection of two sets: A ∩ B. In LaTeX, I would do this as:

… two sets: $A \cap B$. In…

Notice that I used the ‘$’ to surround the expression. This puts everything into an italic font and lets LaTeX know that it should process commands in the math environment (instead of the text environment). In WinEdt, you have to put the ‘$’ down, but you don’t have to remember that ‘\cap’ is the command for the intersection symbol; there is a tabbed toolbar with buttons for all of the symbols you will need!

After this, we went over some examples and then looked at the ‘equation’ and ‘align’ commands. Equation is used when you want to put an equation on a separate line (and like all sectioning commands can be starred or not):

\begin{equation*}
E = mc^2
\end{equation*}

This would produce an output that looked like:

E=mc²

and without the star, we would get:

E=mc² (1)

with the number being adjusted appropriately (that is, if you add something before, then the numbers all shift as you need them to).

The align command looks much the same, but allows you to basically make a table of (numbered) equations. It’s best to avoid this if you can (especially in Dr. Erdman’s class – unless you want him to give you the ‘SWM13’ remark!).  Notice that you do not need to use ‘$’ within equation and align, but if you want to write some text, you need to use the ‘\text{ this stuff }’ command if you do not want ‘this stuff’ to look like: thisstuff; as the math environment ignores white space and italicizes everything!

Conclusion:

That about covers it all- there is a lot of documentation available at the websites and online, and I have a load of pdf files that cover all of this in far greater detail! (Hunt me down if you want them all).

Anyone interested in going over this again- drop a comment and let me know!

ex animo-

Eric

Advertisements

2 Responses

  1. […] let me know when you would like to meet. As for what I am going to cover, look here and here and you’ll see what I did last time.  If anyone has some specific questions, post […]

  2. […] also known as the ‘preamble’ to a document. If you are interested, you can see more here. While chatting, we went into a discussion of proof-verification systems using Coq and Mizar, and […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: