Categories : Linux

4. Liscence

5. References

6. Errata

Copyright (c) 2003 starX. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

## 1. Introduction

Before we begin, the basics: latex is a rubber material used to make condoms. LaTeX (la-tech) is a document processing system used to make pretty documents. While it’s seldom talked about outside of publishing and computer science circles, LaTeX is a powerful markup language that will allow you to produce robust documents on any system. The aim of this guide is to get you used to using LaTeX’s basic features, with the overall aim that, by the time you have finished this tutorial, you will be able to write all of your papers, reports, letters, etc., in LaTeX.

### 1.1. What is LaTeX?

LaTeX (yes that is how you are supposed to write it) is a document mark up language that allows you to create pretty looking reports, papers, letters, articles, books, etc., without the bloat of a word processor. You know HTML, right? LaTeX is based on the same idea; interspersed among your document’s content are various mark up symbols that tell an interpreter how the document should look. You write your own format codes into the document and run the document processor, which in turn spits out a device independent (*.dvi) file, which can be printed (lpr myfile.dvi“), or viewed on your system using a DVI viewer. While LaTeX is exceptionally handy on Linux systems, there are versions available for Windows and Macintosh platforms, and while LaTeX is widely used in the scientific community (due to it’s ability to render formulas and equations accurately), it is also useful in humanities fields. LaTeX requires only a text editor and a LaTeX processor to write clean and professional looking documents, and is freely available. In short, there are many reasons to use LaTeX.

Of course, for all of these reasons, one of the reasons why people don’t use LaTeX is that it has a bit of a learning curve. LaTeX requires you to have a knowledge of document structure, and forces you to think about how you want the document to look as you write it. It’s a little like using an HTML editor (like Page Mill) to write your web page instead of doing it by hand with a text editor (like Emacs or Notepad). This analogy is quite accurate in terms of complexity; learning to format your documents using LaTeX is no more difficult than it is to learn to format your documents using HTML, but the latter of these two is more popular due to standardization of the web. For those of you looking to free yourself from having to use bloated word processors that consume lots of storage space and RAM, LaTeX could be just the tool you’re looking for, and this document will help you along the way.

### 1.2. Getting LaTeX

If you have Linux or UNIX, chances are that LaTeX is installed on your system. At the command line, try typing latex -v; if LaTeX is installed on your system, this will display the version information. If LaTeX is not on your system, the first thing you should do is try and find it on one of the Cd’s that you used to install your system. It should be on there somewhere. If you cannot find it, fear not, LaTeX can be downloaded from http://www.latex-project.org.

If you have Windows, LaTeX will not be included with the default install on your system, so you’ll have to download a version of it. Although I haven’t played around much with LaTeX for Windows, I have found that MiKTeX ( http://www.miktex.org) works well, and has a fairly intuitive interface. You can download it for free by following the appropriate link from the above URL.

Top

## 2. Simple Formatting

There are an infinite number of ways to format a document, and you can make it look anyway you want. Even though LaTeX’s native features may seem limited, there are a number of packages that can expand this functionality. But before we get into that, let’s take a look at what some simple formatting can do.

 Example A Simple Document ========================= \documentclass[12pt, helvetica]{article} \pagestyle{empty} \begin{document} \begin{center} My Title\\ My Name\\ \end{center} My killer content. \end{document} ========================= 

Looks a little different than HTML, I know, but the effect that it achieves is similar. These directives collectively tell the LaTeX document processor to produce a document in the style of a short article, using a 12pt. Helvetica font. There are no page numbers printed, and title and author are centered at the top of the document, and the content follows below.

I’m willing to bet that if you read my above description, and then take a look at the code, you’re already following along nicely, but I’m going to spend some amount of time talking about the various format codes now, and exactly what it is they do. When I’m finished, I will present you with a commented version of the above code that should help you see how all the parts work together to create a document that is more professional looking than a simple text file.

### 2.1. Simple Document Explained

Before I begin, I feel the urge to explain that everything that begins with a slash (\) is a format code. King of like how in HTML the format codes are contained between angle brackets.

In my obsessive compulsive style, I will now present an examination of EACH of the format codes I used in the simple document above. If you don’t need such a meticulous description, feel free to jump down to Example B, the Simple Document with Comments.

### 2.1.1. \documentclass Directive

The documentclass directive does exactly what you think, it tells the document processor what kind of document to make, and how to make it. The required argument, in this case “article” describes the type of document to create, which influences the default spacing, paragraphing, and pagestyle of the document. Other alternatives include “letter”, “report”, and “book”, among others. The optional arguments given specify the font type and size. Size may only include between 10 and 12 inclusive. Type can include many of the standard fonts, including “arial” and “times”.

### 2.1.2. \pagestyle Directive

The pagestyle directive is used to determine what may appear in the head and foot of the document, usually the page number. The argument “empty” tells the document processor to leave the header and footer blank. Other possible arguments can include “headings”, which puts the page number in the header, and “UNKNOWN”, which allows you to place items on the left and right side of the header. These built ins are a bit limiting, but there are packages that allow you more control. We’ll discuss these later.

### 2.1.3. \begin{} Directive

The begin directive tells the document processor to begin processing the document in a certain way. For example, \begin{center} tells the document processor that after this point, text is to be centered.

### 2.1.3.1. \begin{document} Directive

Okay, okay, so I’m fudging here. \begin{} is in and of itself a directive, and “document” is a variable argument passed to the directive. However, the \begin{document} directive stands apart, as it is the root of the document content. Think of it as being equivalent to the &lt;BODY&gt; tag in HTML. Before you start writing content, you have to write one of these.

### 2.1.4. \\ (linebreak) Directive

The double slash is a shorthand way of telling the document processor to make a line break at that point. The uses for this should be obvious, but to explain in detail, LaTeX does not treat a newline character as a line break when compiling the document. Creating a new paragraph usually involves creating multiple newlines, but on some occasions, such as creating a title and byline, you’ll want to break the line without creating a new paragraph.

### 2.1.5. \end{} Directive

What goes up must come down, and what begins must end, which is as true for LaTeX formats as it is for anything else. Just as &lt;HTML&gt; and &lt;BODY&gt; tags must be closed with &lt;/HTML&gt; and &lt;/BODY&lt; (respectively), if you use the \begin{} directive to open a new block of code, you must use a complimentary \end{} directive to close it before you try and compile the document, or else the document processor will signal an error. This is just as true for \begin{document} and \end{document} as it is for \begin{center} and \end{center}.

 Example B) Simple Document with Comments ======================================== % The documentclass directive is used to specify the type of document % we are creating, as well as the size and type of the font that we % will use in the document \documentclass[12pt, helvetica]{article} % The pagestyle directive is used to tell LaTeX what to put in the % headers and footers, and where to put it. In this case, we just % want them blank. \pagestyle{empty} % The first \begin directive with "document" as an argument tells % LaTeX that we are going to begin writing the content of the document % itself \begin{document} % This begin directive tells LaTeX that the text that follows should % centered. \begin{center} % The double slash tells LaTeX to make a line break in the document. My Title\\ My Name\\ % This end directive tells LaTeX that the text that we are done % centering. \end{center} My killer content. % This end directive tells LaTeX that we are done with the document. \end{document} ======================================== 

Got that? Good. I should probably mention that a percent sign (%) is used to begin a comment in LaTeX, and everything on the line after the % is treated as if it were a comment (unless of course it’s escaped, but we’ll talk about that later). Now that we’ve covered the basics, lets move on to some of the more interesting stuff.

### 2.2. Marking Up the Text

As I’m sure you know, there are many times during the course of a paper/letter/etc., when you are going to need to change the weight, alignment, size, and type of font that you are using. The names of books need to be italicized or underlined, writing variable names in a font that is different from the that of the rest of the text, and block quotations are often times written using single spacing when the rest of the text is written with double-spacing. Getting used to doing these things will make it a lot easier to write a paper without needing to constantly refer to the documentation you’re using, so lets get to it.

### 2.2.1. \begin{} Directive

You’ve already seen this in action in the example above, but it is one of the more powerful directives, and can take virtually anything as an argument, so it bears repeating. The text between a set of \begin{} and \end{} directives will be inherit the properties of the rest of the variable passed to the directives regardless of what the text outside of the block of code looks like. In the above examples, everything between \begin{center} and \end{center} is centered, while the rest of the text is justified. Using this same technique, you could create an entire block of code that is bold faced, italicized, of a completely different font, etc.

This technique is the basis for just about everything else you’ll use to actually markup the text, so learn it, practice it, be it.

### 2.2.2. Italicizing

You can change the weight of your text to italicized using the \it directive. This tells the document processor that all of the text that follows should be italicized. Pretty simple, right? But before you dive in, just keep in mind that this is short hand for \begin{\it}.

To “turn off” italicizing, you have to switch to another font face. So, for example, if you are using a sans-serif font (like Helvetica), and you want to italicize the name of the book, you would change back to the regular font using \sf. It would look like this: \it Dune, \sf by Frank Herbert. But wait, you say, couldn’t I just use an \end(\it} directive? Yes you could, but only if you began you italics using \begin{\it}.

### 2.2.3. Boldface

Did you think italics was easy? I hope so, because bold facing follows the same rules, with the exception that you begin a bold faced line using the \bf or \begin{\bf} directive. Cool, huh?

### 2.2.4. Underline

I know this is going to be a big surprise given the complexity of bold facing, but the directive is either \ul or \begin{\ul}.

### 2.3. Line Spacing

If you’re going to write your papers using LaTeX, you’re going to need to know how to double space the font of the text. Most teachers and professors prefer double spacing so they can write comments between the lines, and in some cases you’ll want double spacing just to make it easier to read. But then, just because you’ve chosen one style of spacing doesn’t mean you won’t want to change it mid text.

### 2.3.1. Setting the Default Spacing

This is going to introduce something that I haven’t discussed yet, and won’t discuss until later on in the text. If you want, you could skip ahead, but I would recommend that you just take my word for it here and worry about understanding what it means when you’ve mastered the basics.

LaTeX does not natively support double spacing, so to set your default line spacing to double space, you’ll need to import the double-space package. You do this by issuing the \usepackage{} directive, with double-space as an argument, right after the \documentclass{} directive. That’s as simple as it is, your document’s default line spacing has now been set to double space.

I’ll talk about packages later on, just trust me for now.

### 2.3.2. Changing the Spacing within the Document

Remember our old friend the \begin{} directive? Well here he is again. Say you’re writing a paper and you need to write a block quotation. This usually means you’ll want to single space that portion of the text, which can easily be achieved by creating a single space block with the \begin{singlespace} …. \end{singlespace} directives. If, on the other hand, you only want a few portions of you paper to be double-spaced, you would still need to import the double-space package, but you would simply include the majority of the text inside the single space block.

### 2.4. Paragraphing

I’m going to throw a lot under this heading, because this subject broaches many different topics within LaTeX. How your documents paragraphs are configured depends upon the alignment of you paragraphs, the size of the page you use, and whether or not you choose to use indentation. Hold onto your hats, ladies and gentleman, we’re going in!

### 2.4.1. Alignment

By default, LaTeX will justify your paragraphs to both the right and left margins, which should suffice in most cases. However, for those instances when you want your text to be centered, or non-aligned with a margin, there are ways around the default indentation.

### 2.4.1.1. Centering

Probably the most you’ll ever need to change the alignment of your paragraphs is for centered text. I’ve already shown you how to do this in the above examples, but to recap everything between \begin{center} \end{center} directive will be aligned with the center of the page.

### 2.4.1.2. Left Alignment Only

Sometimes this is necessary, a good example being when a teacher or professor insists on strict adherence to MLA style which demands that your papers be aligned only with the left margin. To turn off alignment with the right margin (but leave it on with the left margin), enclose your text between \begin{raggedright} and \end{raggedright} directives. The raggedright argument will force all text that is not explicitly aligned elsewhere to align with the left margin, which will effect automatic indentation… but we’ll talk about that later.

### 2.4.1.3. Right Alignment Only

Yes, this is possible, although I have never needed to do it. Like the raggedright counterpart, raggedleft will force alignment with the right margin, and turn off alignment with the left margin. You can activate this by enclosing your text between \begin{raggedleft} \end{raggedleft} directives.

### 2.4.1.4. Bottom Alignment

I’m willing to bet this is something that you’ve never even considered, but there are times when you want to make the bottom margin of the page conform to the amount of text on the page. For example, if you have an extremely long footnote, and it is important to have the entire footnote on the same page as the part of the text you are referring to, you can simply use the \raggedbottom declaration on that page, and use page breaks (more on that subject later) to force all other text off of the page until the footnote fits. A fair warning though… unless it’s a pretty long footnote, and it absolutely MUST fit on that page, I wouldn’t do this, it’s libel to get you marks off your reports.

### 2.4.2. Indentation

Indentation is a bit of a tricky subject. Most of the time, you are going to want to indent the first line of your paragraphs, and LaTeX is even good enough to do this for you… most of the time. However, certain cases can arise where it is advantageous to NOT indent the first line of your paragraph, and there are times when LaTeX will automatically suppress indentation when you actually want it. At other times, LaTeX may indent too little or too much to suite your needs. That being said, I will try to deal with each of these issues individually so that you can get a better understanding of the specific situations that you are likely to encounter.

### 2.4.2.1. Automatic Indentation

Most of the available document classes (article, report, book, letter) will automatically indent the first line of a new paragraph about five spaces. This may not necessarily be what you want, and it may not be available (depending on what other options you choose), but it is convenient and easy to implement. To take advantage of this feature, simply leave a blank line between your paragraphs when writing the source document. It should look like this:

 Paragraph1..... Paragraph2... 

There you go… automatic indentation.

### 2.4.2.2. Suppressing Indentation

Sometimes you just don’t want the first line of your paragraph to be indented. Consider the following example:

 Example C ======================================= \documentclass{article} \begin{document} My Name\\ My Class\\ The Date\\ This is my report...... \end{document} ====================================== 

Because we’ve done nothing to suppress indentation, when LaTeX processes the document, MyName, which is the first line of a new paragraph to LaTeX, will be indented the standard number of spaces. This is incorrect in most cases, and just looks sloppy. To turn this off, issue a \noindent directive on the line that you DON’T want indented. In this case \noindent MyName \\ would do the trick nicely.

Keep in mind that you don’t need to issue a \noindent directive every time you don’t want indentation. You only need to use it if you don’t want indentation and LaTeX would put it there for you anyway, as in Example C.

### 2.4.2.3. Forcing Indentation

Remember before when I told you about how some teachers and professors insist that MLA format be strictly followed, and hence you’ll need to use a raggedright declaration to turn off right alignment? Remember I also said it forces alignment with the left margin unless we explicitly tell it to do otherwise, which includes LaTeX’s automatic indentation. If you use the raggedright directive, and you want indentation, you have to tell LaTeX to put it there explicitly.

To force indentation anywhere in your document, there are two directives you’ll need to know. The first thing you must do is issue the \indent directive, which tells LaTeX that we want indentation. But you must also tell LaTeX how much you want to indent, and you do this by using the \hspace{} command. \hspace{} takes an argument that specifies exactly how much space to indent. I find that most of my professors don’t have a problem with a quarter of an inch for simple paragraph indentation, so if I am writing a paper with raggedright on, and I need to make a new paragraph, I do the following before I start typing any of the text for that paragraph

 Example D Forcing Indentation ============================= \begin{raggedright} ... \indent \hspace{.25in} And so it should be clear to the reader that... ... \end{raggedright} ============================= 

Voila, we have forced precisely LaTeX to indent precisely the amount of space we’ve requested. Not too painful, I know, but that can trip you up rather easily.

### 2.4.3. Page Configuration

Page configuration is more often than not a secondary concern. Paragraphs are, after all, the meat of the document, and will require you to do different things at different times, whereas page configuration is, by and large, static to your document. That is to say, once you’ve configured how your pages will look, unless you need different page styles within your document, you never have to touch them again.

### 2.4.3.1. Page Size

By default, LaTeX uses roughly only about a half of the page, increasing the all around margin size to somewhere between two and three inches. This may be preferable in some cases, but more often than not, you’ll want to use the full size of the page, leaving only an inch or so for the margin width. Since LaTeX does not support this natively, you’ll need to import the full size package. As with double spacing, just put the \usepackage{fullpage} directive right below the \documentclass{} directive.

Again, I’ll talk about packages and \usepackage{} later on.

### 2.4.3.2. Simple Header and Footer Manipulation

LaTeX’s native support for header and footer manipulation is rather limited. Fortunately, there is a package available that expands this functionality, but I’ll talk about this later on as using this package definitely falls outside of the realm of “simple formating.” However, if you’re looking for MLA style, you may want to skip down to using Fancy Header, as there isn’t really much LaTeX can do for you natively.

You control what goes into the head and foot of your document using the \pagestyle{} directive. When issued, the \pagestyle{} directive changes the style of the header and footer from the page of issue through the end of the document, or up to the next \pagestyle{} directive, whichever comes first. You can pass one of several different arguments to \pagestyle, each of which effects what goes into the head or foot of the document in a different way, although it should note that default behavior will depend somewhat on the class of document that you have created. For example, if your document class is “article”, then page numbers appear centered in the footer by default, but if you use the “book” class, then the default is for the page number to appear in the right of the head of the document.

Valid arguments for \pagestyle{} include “plain”, “empty”, “headings”, and “myheadings”. The “plain” argument will put a page number in the default spot on the page; “empty” leaves the header and footer of your document blank; “headings” puts a consistent heading on each page of the document, what goes into the header depends upon the document class you are using. The “myheadings” style gives you the most flexibility out of all of these, but it is also a little more complicated, so I will deal with it separately.

If you use “myheadings”, you’ll be able to specify what goes into the left and right header of your document, but to do this you will also need to call the \markboth{}{} directive. \markboth{}{} takes two arguments, be careful here, what you give as the first argument (the left one) appears on the right side of the header, and what you give as the second argument (the one on the right) appears on the left side of the header. Confused? Let’s take a look at an example:

 Example E: Using "myheadings" and "\markboth{}{}" ================================================= \documentclass[12pt, helvetica]{article} \pagestyle{myheadings} \markboth{}{MyLastName} \begin{document} \begin{center} My Title\\ MyName\\ \end{center} Content...... \end{document} ================================================= 

This produces an article-class document with a centered title and author, and content following below. On the left side of each header the author’s last name appears, and on the right side of each header the page number appears. Unfortunately, it doesn’t get much more fancy then that without resorting to using an external package, but as I said before, I’ll talk about that later on. Top

### 2.4.3.3. Multi-Column Layout

Yes, emacs can produce a page with two columns on it, which is useful if you need to create a newsletter, or see how your document will look when formatted differently. Starting a page with two columns is easy; simply issue the \twocolumn[heading] command. \twocolumn[] will start a new page, and format all the text thereafter to use two columns per page instead of just one. The \twocolumn[] directive can take the optional argument “heading;” any text passed to \twocolumn[] will appear above the columns: i.e. \twocolumn[These are columns].

### 2.4.3.4. Page Breaks

Again, this is pretty simple. Use the \pagebreak directive when you want a new page. Any available space left on that page will be left blank, and any text following the directive will start on a new page.

### 2.4.4. Simple Format Conclusion

Well there you have it, the very basics of formatting a document for the LaTeX document processor. What follows will go beyond these basics, and by this point I’m going to assume you know what a directive is, what the beginning of a LaTeX document generally looks like, and how to start and end blocks using \begin{} \end{} directives. If so, then the world of tables, pictures, equations, packages, and environments awaits you. If you’re still having some trouble understanding any of the general concepts mentioned above, then by all means read it over again, practice, and play around a little bit more. Okay, that being said….

Top

## 3. Advanced Formatting

Well, I’ll call it advanced anyway. By advanced, I’m speaking of doing things like inserting tables, pictures, and equations in the text, and I’ll also talk about various citation techniques. These are things that you don’t necessarily need to do to write a common report, or letter, but they are things that many people often need to do. While everything up to this point has been a tutorial approach meant to be taken as a whole, the following segments are intended to be read as references to solve problems that have come up in the process of editing you files, and are best read as that. I’ve tried to keep them as independent as possible, so if you understand up through section 2, you should be able to understand any one of the things that follows. Good luck!

### 3.1. Lists

Lists are one of those all important things that come in many shapes and sizes. There are outlines, schedules for who is doing what when, points of a presentation, and on and on. LaTeX provides list functionality in several different ways, one of which will probably suite your needs.

### 3.1.1. Itemized Lists

To begin a simple list, issue a \begin{itemize} directive. Each item contained within this list is so designated by the \item directive. To put it simply, every time you want something to have a bullet, use the \item directive. Of course, you’ll need to end the list with an \end{itemize} directive. You can nest itemize lists up to four level deep.

I mentioned bulleted lists because that is precisely what an itemized list is. If you want numbers, you should use an enumerated list.

### 3.1.2. Enumerated Lists

Enumerated lists are a lot like the itemized lists, except they are begun with the \begin{enumerate} directive and ended with an \end{enumerate}. Aside from this, they are the same relative to how you designate an item in the list, and that you can nest an enumerated list up to four levels deep.

### 3.1.3. Customizable Lists

Itemized and enumerated lists may not suffice for all cases, but LaTeX provides a way of defining one’s own list structure with a generic list template, and so these limitations can be overcome with a little bit of effort. The generic list template is begun differently from the other directives: \begin{list}{label}{space}, where “list” is the name of the directive (like enumerate and itemize), “label” is a variable that designated what will be used to denote an item of the list (like a bullet), and “space” is a variable that indicates what type of spacing should be used to offset your list.

The label variable is somewhat complex, but hopefully I can clarify it enough so that you’ll be writing your own list types in no time. Lets take a look at this example:

 EXAMPLE F: A Custom List ======================== \begin{list}{X}{} \item this is an item \item so is this \item this is too \end{list} ======================== 

If compiled, this will create a custom list that uses a capital letter X in the place of a bullet or a numeral, and uses the default spacing (which should be adequate under any circumstance, so it’s usually best to leave the final argument blank). While this is cool, it’s not exactly useful. Fortunately we can feed the second argument of the directive a LaTeX command that will tell it to do something else.

Here I go again, discussing topics that I haven’t introduced yet. I’ll talk about counters later on when I get into the REALLY complicated stuff. For now, just take my word for it, and worry about writing your own macros and environments when the time comes.

 EXAMPLE F2 A More Interesting Custom List ========================================= \newcounter{nums} \stepcounter{nums} \begin{list}{\Roman{nums}}{} \item \stepcounter{romans} this is an item. \item \stepcounter{romans} so is this. \item \stepcounter{romans} this is another. \end{list} ============================================ 

Every directive with the word counter in it has something to do with initializing or advancing a counter. The \Romans{} directive just tells the counter to print the results as capital roman numerals. And as you’ve probably guessed from that, this prints out the items of the list using upper case roman numerals as the itemization method. This has its obvious uses… again that MLA thing comes to mind. Using this technique, you could define a list technique that conforms to MLA format by using several different custom nested lists.

 EXAMPLE F3 An MLA Outline-styled list ===================================== \newcounter{ROMANS} \stepcounter{ROMANS} % create and initialize to 1 \newcounter{LETTERS} \stepcounter{LETTERS} % create and initialize to 1 \newcounter{romans} \stepcounter{romans} % create and initialize to 1 \newcounter{letters} \stepcounter{letters} % create and initialize to 1 \begin{list}{\Roman{ROMANS}}{} % begins level 1 \item \stepcounter{ROMANS} LEVEL 1 ITEM. \begin{list}{\Alph{LETTERS}}{} % begins level 2 \item \stepcounter{LETTERS}Level 2 Item. \begin{list}{\roman{romans}}{} % begins level 3 \item \stepcounter{romans} level 3 item. \item \stepcounter{romans} level 3 item. \begin{list}{\alph{letters}}{} % begins level 4 \item \stepcounter{letters} level 4 item. \item \stepcounter{letters} level 4 item. \end{list} % ends level 4 \setcounter{letters}{1} % resets the level 4 counter to 1 \item \stepcounter{romans} level 3 item. \end{list} % ends level 3 \setcounter{romans}{1} % resets level 3 counter to 1. \item \stepcounter{LETTERS}Level 2 Item. \begin{list}{\roman{romans}}{} % begins level 3 \item \stepcounter{romans} level 3 item. \item \stepcounter{romans} level 3 item. \end{list} %ends level 3 \setcounter{romans}{1} % resets level 3 counter to 1 \end{list} % ends level 2 \setcounter{LETTERS}{1} % resets level 2 counter to 1 \item \stepcounter{ROMANS} LEVEL 1 ITEM. \end{list} % ends level 1 \setcounter{ROMANS}{1} % sets level 1 counter to 1. ===================================================== 

So, if you’re sitting there staring blankly at this example, I will completely understand. I’ve tried to space it out as much as possible to help you follow along, but if you’re still having trouble, I recommend cutting and pasting it into a LaTeX document and taking a look at the finished product while studying the example. That, along with my comments in the mark-up, should help you. If you do understand this example, mad props to you… you probably also know a thing or two about counters by now too. Again, if you don’t understand the counters, I will be discussing those a bit later on.

### 3.2. Graphics

While it may not be something you do all the time, sooner or later you are going to come upon a situation that at the very least recommends the use of a graphic to supplement your text. And why not? A picture does say a thousand words, after all. A nice pie chart showing the percentages of what operating system is most popular in your institution might mean the difference between convincing management to switch, or being stuck using something nobody likes; or a bar graph that shows an increase in your consulting firms net profit margin may mean the difference between you and your arch-nemesis getting the job. People like to look at graphics, and it’s good to know how to put them in the text of your documents.

### 3.2.1. Including Pictures in Your Document

Before I get too involved, I should probably define a picture as LaTeX understands it. Pictures are collections of text, boxes, arrows, and circles that can appear in any sort of configuration in your document. You use the \begin{picture}(width, height)(width-offset, height-offset) to start a picture, where “width” and “height” are the size of the picture within the document (specified in millimeters), and “width-offset” and “height-offset” (also specified in millimeters)are optional arguments that can allow you to shift the picture after it has been drawn (if, that is, you decide you want the position to change). It is probably worth noting that LaTeX will let you put drawing anywhere on or off the page, when you specify the size of the picture you are actually specifying the space that LaTeX will reserve for the picture. It is also worth noting that the numbers

To insert objects into your picture, you use the \put(x,y){content} directive, where “x,y” is a set of Cartesian coordinates (i.e., (1,1)) that specifies where to put the content, and “content” is the content that you are actually putting in the picture, which can be one of several different commands for drawing various objects.It’s also worth noting that there are a number of ways to surround your picture with different types of boxes to offset it from the rest of the text. Before I get into these topics, lets take a look at an example of how to draw a simple line.

 EXAMPLE G: A Line Segment ========================= \begin{picture}(200, 100)(0,0) \put (10,10){\line(0,1){50}} \end{picture} ========================= 

Don’t worry if you don’t understand the \line(){} directive, I’ll explain that in a minute.

### 3.2.1.1. Objects Available for Your Pictures

There are several different types of objects that you can put in your pictures, and with a little imagination, you should be able to create just about any geometric shape possible. After discussing how to go about putting these images into your document, I’ll finish up with an example that uses several of the geometric shapes.

### 3.2.1.1.1. Lines

The most fundamental unit is, of course, the line segment. You could, theoretically, make any image out of a collection of line segments (but fortunately more complicated shapes like circles and ellipses are provided for), and so it is important to know how to make line segments work if you are going to be using pictures extensively.

The directive for drawing a line is: \line(x slope, y slope){length}. The “length” argument is fairly strait forward; a line will start at the position you’ve specified with the \put directive, and finish at the end of the length unit specified. Like everything else, length is in millimeters. The slope arguments specify the angle of the line; where x is 0 and y is 1, the line will be a strait vertical line, where x is 1 and y is 0, the line will be a strait horizontal line, and where both the x and y values are 1, the line will be a diagonal that starts at the low position and ends at the high position forming a 45 degree angle at the base. Negative and decimal values for slope are also accepted.

It is worth noting here that you can change the thickness of your line using the \linethickness directive: \linethickness{dimension}. Where dimension, which must be a positive number, is the thickness of the line. Be advised, however, that this thickness will only apply to lines that are perfectly horizontal or vertical. Slanted lines, circles, and ovals do NOT inherit this thickness.

### 3.2.1.1.2. Arrows

Related to the line is an arrow, or a vector in LaTeX speak. The directive for a vector is remarkably similar to that of a line: \vector(x slope, y slope){length}, the difference being that there is an arrow at the end of the vector line.

### 3.2.1.1.3. New Sub-section

Circles are another common geometrical shape, and while it would be technically possible to draw them using small lines segments, this would most likely result in blindness and insanity. The circle directive allows you to draw a circle up to a 40pt diameter by simply giving the diameter. The directive looks like: \circle{diameter}. Remember that a 40pt. diameter is your limit. If you specify a diameter greater than 40, LaTeX will draw a circle with a 40pt. diameter.

### 3.2.1.1.4. Ellipses

Okay… so LaTeX is kind of cheating on this one. When LaTeX draws an ellipse (or an oval), it is actually just drawing a box with 1/4-circle corners. This is due to the 40pt diameter maximum of the circles, and if you try drawing an ellipse as a circle (with equal width and height), you’ll see exactly what I’m talking about.

To draw an ellipse, use the \oval(width, height)[] directive. The optional argument to oval can be one of four letters, which will cause only that portion of the ellipse to be drawn. t selects the top portion, b the bottom, l the left, and r the right. For example, to draw the right half of an oval only: \oval(20, 20)[r]. Note that you can only specify one portion argument per oval.

 EXAMPLE G2 A Simple DFA Using All of the Shapes =============================================== \begin{picture}(200, 100)(0,0) \put(0,20){\line(1,-1){10}} \put(0, 0){\line(1,1){10}} \put(21,10){\circle{20}} \put(30,10){\vector(1,0){20}} \put(60,10){\oval(20,20)} \put(60,10){\oval(15,15)} \end{picture} =============================================== 

A DFA is a Computer Science term that you probably don’t need to know about unless you study language and machine theory, but the over all style of a DFA serves our purposes quite well. You can see how all of the different shapes interact to form a picture that is, at the very least, a collection of recognizable shapes, which to some actually serves a meaningful purpose. I fully encourage you to copy and paste this into a LaTeX document and see for yourself.

### 3.2.1.2. Placement Methods

I’ve already talked about placement methods to some extent, and by now you should be familiar with the \put directive, but there are other methods available of putting these objects into your pictures, which I will discuss below.

### 3.2.1.2.1. Simple Placement

I’ve already mentioned this, and have used it in my examples, but I would be negligent if I didn’t state it here as well. So strait from above:

To insert objects into your picture, you use the \put(x,y){content} directive, where “x,y” is a set of Cartesian coordinates (i.e., (1,1)) that specifies where to put the content, and “content” is the content that you are actually putting in the picture, which can be one of several different commands for drawing various objects.

Again, this is probably the most common method of actually placing pictures inside of your documents.

### 3.2.1.2.2. Repeated/Pattern Placement

While you could do it by hand, LaTeX provides you a way of placing an object repeatedly into your picture to create patterns. This is achieved by using the “\multiput” directive, which looks like: \multiput(x,y)(delta x, delta y){number}{object} That’s a long one, and there’s quite a lot going on here, so lets take it one step at a time. The “x,y” variable is exactly what it was in the \put directive; the coordinates in the picture where you are going to put the shape. If you recall your high school Geometry class (or maybe Trigonometry?), “delta” simply means “change,” and so “delta x, delta y” simply means the coordinate change for x and y. “number” is just the number of times to repeat the object, and “object” is just the object you’re going to draw. Okay, so as to alleviate any confusion…

 EXAMPLE G3 A Pattern of Circles =============================== \begin{picture}(200, 100)(0,0) \multiput(5,5)(20,0){10}{\circle{20}} \end{picture} =============================== 

The Result of this is ten circles whose diameters touch lined up in a strait horizontal line. Just to clarify that “delta x, delta y” thing again, the “delta x” value is 20 because I want the circles to touch ends, and since each circle has a diameter of 20, I have to offset the point where I begin drawing the next circle by 20 so that I can begin drawing the next circle where the previous circle ends. The “delta Y” value is 0 because I want a strait horizontal line, and adding any shifts to the y coordinate would result in the line of circles forming a diagonal.

### 3.2.1.2.3. Stacking Objects

LaTeX just happens to be kind enough to provide a method of stacking objects on top of one another. This is achieved by using the \shortstack directive, which looks like: \shortstack[]{item 1 \\ item 2 \\ item N} This is fairly strait forward. Valid entries for the optional argument (between the []), are r, l, and c, which stand for right, left, and center respectively. These commands tell LaTeX whether you want the objects on left, right, or center of stack, center being the default.

### 3.2.1.3. Framing your Pictures

The fact that LaTeX doesn’t automatically put a box around your pictures can be a bit of a nuisance, but fortunately there are ways for you to do it manually. This is a good thing to do when you want the picture clearly separated from your text, which can be rather often when you are trying to make an easy to read presentation. Crisp lines around your pictures will give your audience an easy distinction between the visual aid and the text itself. The again, you may want something more informal; whether you want a box, no box, or a styled box around your pictures, LaTeX provides a way.

### 3.2.1.3.1. No Frame

It is probably worth mentioning again that LaTeX does not, by default, define clear boundaries for your pictures. Remember that LaTeX only reserves the space, but does not make you stay within those bounds (hence the ability to shift). However, if you are going to leave you picture without a frame, it is generally good form to leave a “buffer” of space around the picture itself, so if you don’t want a frame, you should probably request a little more space than you otherwise would.

### 3.2.1.3.2. Solid Line Frame

Remember all the way back when we talked about the \makebox directive? To refresh, that’s the directive that actually reserves the space for your picture. The \framebox directive is a close cousin of \makebox, the notable different being that \framebox draws a solid-line frame around the box instead of leaving it blank. Don’t believe me? Pick any one of the above examples and substitute \framebox for \makebox, and you’ll see. For ease of reference, \framebox in its entirety looks like: \framebox(width, height)[position]{content}.

### 3.2.1.3.3. Dashed Line Frame

The dashed line frame can be useful when you want to create a “cut out” (like a coupon), or when you want to represent a picture as separate from your text but without the formality of a solid line. You can create a frame with a dashed line using the \dashbox directive, which looks like: \dashbox{dash length}(width, height){content}. The only thing really new here is the “dash length” argument, which you will notice is mandatory. I doubt you will be surprised to learn that this variable is what determines how long each dash will be.

 Example G4 A Document with Pictures =================================== \documentclass[12pt, helvetica]{article} \pagestyle{myheadings} \markboth{}{MyLastName} \begin{document} \begin{center} \begin{bf}This is My Title\end{bf}\\ This is My Name \end{center} This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. I will now demonstrate how we can arrive at point B directly from point A, which should be obvious. \begin{picture}(65, 30)(-110,0) \makebox(65, 30)[c]{ \put(10,20){\circle{20}} \put(6,0){A} \put(20,20){\vector(1,0){30}} \put(60,20){\circle{20}} \put(56,0){B} } % End box \end{picture} By this we are able to see that there is a direct path between point A and point B. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. Now let us assume that there is a 3rd point, point C, which is accessible by a direct path from B, but not from A. To go from point A to point C, we must create a meta-point; point B', and use that as a way-point to get directly'' from A to C. Only by using a meta point can we say that A goes to C. As such it would look like: \begin{picture}(120, 90)(-115,5) \framebox(120, 90)[lb]{ \put(10,20){\circle{20}} \put(6,0){A} \put(10,30){\vector(1,1){45}} \put(50,75){\line(1,1){10}} \put(50,75){\line(1,0){20}} \put(70,75){\line(-1,1){10}} \put(56,65){B'} \put(70,73){\vector(1,-1){45}} \put(20,20){\vector(1,0){30}} \put(60,20){\circle{20}} \put(56,0){B} \put(70,20){\vector(1,0){30}} \put(110,20){\circle{20}} \put(106,0){C} } % End box \end{picture} Thus you can clearly see from this demonstration blah blah blah This is my text. This is my text. This is my text. This is my text. This is my text. This is my text. \end{document} ================================================= 

I know it’s a long example, but I think it’s worth it to show you all the sorts of things you can do with actually putting pictures in your documents. There are a variety of issues to consider, and hopefully this example has helped you see how you can use pictures as part of the “big picture” that is your document.

### 3.2.2. Images

With all this talk about pictures, I bet you thought I wouldn’t mention how to include images inside your files. Wrong! Although this is probably the more interesting then making pictures with LaTeX’s built in system, there are actually a number of complexities that go along with including graphics from an external file.

The first and most obvious problem is that LaTeX has no native support for importing images into your document. To do this, you will have to use the graphicx package, which should come standard with your distribution. If not, check at the place where you downloaded LaTeX to see if you can find the package.

A secondary problem is that the image file itself must be in either Postscript (.ps) or encapsulated Postscript (.eps) format. Most graphics these days do not come in these formats, so chances are you’ll have to convert the file. While I can’t speak for other programs, The GNU Image Manipulation Program (GIMP) can open a graphics file, and will allow you to “save as” Postscript format, and Adobe Photo Shop will allow you to save your images as encapsulated Postscript. Either way will make the image readable by LaTeX, although the image quality may not be what it was before the conversion.

Those are the main problems… now lets talk about some of the solutions…

### 3.2.2.1. Including Images in Your Document

As I said before, the first thing you’ll need to do is include the graphicx package using the good old \usepackage{} directive. Once that’s done, the various commands for including the image in the document will be at your disposal.

The first thing we need to do to import the image is to open the environment for it. LaTeX calls images of this sort “figures,” and so you would naturally start and end the environment for including a figure with the \begin{figure}…\end{figure} directives, with everything in between the two being the commands you’ll use to place the image. To actually include the image, use the \includegraphics directive, which in its entirety looks like: \includegraphics[scale, width, height, totalheight, angle, keepaspectratio, origin, draft, clip, bb, viewport, trim, highresbb]{File Name}. Where the optional arguments are all in the form of arg=value; i.e. “width=2in” as an optional argument would set the width of the image in the document to two inches. And of course, these are all optional arguments, most of which you probably won’t have to use. The only required argument to \includegraphics[]{} is the name of the image file. I will discuss each of the optional arguments, and what they do, but first lets take a look at a simple example.

 G5 Including an Image in Your Document ====================================== \usepackage{graphicx} . . . \begin{figure} \includegraphics{mygraphic.ps} \end{figure} ===================================== 

Hopefully this will help put things in perspective; for all of the complexities that go along with including an image file in your document, the process of doing so is actually remarkably easy.

That being said, hold on tight as I talk about the optional arguments. Again, remember that these are all optional, and I’m willing to bet that you won’t even use most of them.

There you have it, the list of arguments that you can give to your image file. Don’t be surprised if you have to play around a bit with some of the ones from the bb family, but since that is pretty much the only way of putting your image anywhere except for the top of the page, it can be worth it.

### 3.2.2.2. Captioning Your Images

Captions are usually necessary components to images in reports and presentations. They give your audience the ability to immediately associate the image they’re looking at with meaning that may be obvious somewhere else in the text. A good caption can be anything from a simple description to an line from the paragraph where you mention the image. In any case, to put a caption in your image put the \caption{} tag somewhere in the figure environment: \caption{Caption Text} Where “Caption Text” can be just about anything you could want or imagine, including LaTeX functions. I know what you’re thinking… “Cool! That way I can have a counter keep track of what figure number the image is!” Yes, you are right, and yes it is cool. So cool, in fact, that LaTeX will do that for you.

With this, I bring my discussion of pictures in documents to a close. You should be able to go on to figuring out exactly where pictures fit into your document. If you want more information on some of these commands, you should have enough of a grasp on them to see the online help (“info latex”) and look up the pictures section. For information on the graphicx package, see the references section below. Have fun!

### 3.3. Tables

Tables are one of the most common ways of presenting data to your audience, and for a good reason. When used properly, tables will present your data in a clear and easy to read manner that no one should have trouble following. And since LaTeX provides us with the capacity to make counters and draw pictures, it only makes sense that it provides us with what is perhaps a more rudimentary data presentation system than any other.

There is a crucial point that needs clarification before I proceed. The environment used for making tables in the sense that I’m talking about (and that I’ll bet you’re thinking about) is called “tabular.” There is an environment called “table,” but LaTeX uses this to create objects, which can contain just about anything, that are not part of the normal text. They are floated at convenient points in the text; the default being the top. Just keep in mind that when I say “table,” I mean a data collection created by elements from the “tabular” environment. Got that? Good. Moving right along….

### 3.3.1. Creating a Table

Now that I’ve clarified that we’ll be using the “tabular” environment things are about to get sticky again. There are actually two different forms of the environment (which are exceptionally similar), but the “tabular” environment takes a set of arguments that actually defines the structure of the table; chances are that if you are going to have trouble, you’re going to have it here.

### 3.3.1.1. The ‘tabular’ Environment

The tabular environment is a little different from a standard environment because it takes fairly non-specific arguments that will determine how your table looks. To create a table using the tabular environment:

 \begin{tabular}[position]{args} . . . \end{tabular} 

Where “args” is a list of mandatory arguments that will determine how your table looks, and “position” is an optional argument that specifies the vertical position of the table (default is centered). The position argument is a little easier, so I’ll get that out of the way first: valid arguments for position can either be “t”, which will align the table with the top row, and “b”, which will align the table with the bottom row of the page. No surprises here; now for the hard part.

The mandatory argument “args” can consist of any combination of column specifiers, and inter-column material. Valid column specifiers are: “l” for a column of left aligned items; “r” for a column of right aligned items; and “c” for a column of center aligned items. Inter-column material specifiers include a “|” (SHIFT-Backslash on most keyboards), which will insert a vertical bar (this is the easiest and most common inter-column material specifier; a “@{}” expression, which will insert what you place between the {} as the inter-column material. Using these combinations, you can create just about any type of table you want. It is absolutely essential that you enter one of the column specifiers for each column in your table, and even though you can do without the inter-column material (LaTeX will simply insert a space), it generally makes you table look better if you include something.

Entries in your table are written as strings of text; with each column in a row terminated by an ampersand (&amp;), and each row terminated by a newline (\\). Here’s an example that I’ve used in role playing games to let players know who the notable characters n town are, and what they do.

 Example H: A Simple Table ========================= \begin{table}[h] \begin{tabular}[t]{|l|l|l|l|l|} \hline \bf Name & \bf Class & \bf Job & \bf Race & \bf Level \\ \hline Jerhyn & Aristocrat & Mayor & Human & 3 \\ \hline Kaden & Warrior & Watch Captain & Human & 5 \\ \hline Zachariah & Cleric & Head Priest of Zeus & Human & 7 \\ \hline Ardra & Adept & Witch/Magic-shop Owner & Human & 4 \\ \hline \end{tabular} \caption{Notable NPCs in hamlet of Westborough} \end{table} ========================= 

There is a basic table. note that I used the macro “\bf” instead of the environment version for bolding because it is simpler. Each cell of the table is essentially, self contained, so it makes more sense to use the macro (as we do not have to terminate it) than the environment. And yes, I cheated a little, I used the a directive that I haven’t introduced yet, as well as the “table” environment. Before I talk about either of these, I want to introduce the alternative for of the “tabular” environment; “tabular*”.

### 3.3.1.2. The ‘tabular*’ Environment

The “tabular*” environment is the same as the “tabular” environment in every way but one; the “tabular*” environment demands a second mandatory argument: the width of the table. The environment declaration looks like:

 \begin{tabular*{width}[position]{args} . . . \end{tabular*} 

Where “position”, and “args” are the same as for the “tabular” environment, and “width” is a measurement (like inches or points) that specifies how wide the table will be. The following example is the one given above, using the “tabular*” environment instead of the “tabular” environment to create the table.

 Example H1 A Simple Table Using the "tabular*" Environment =========================================================== \begin{table}[h] \begin{tabular*}{5.05in}[t]{|l|l|l|l|l|} % NOTE DIFFERENCE \hline \bf Name & \bf Class & \bf Job & \bf Race & \bf Level \\ \hline Jerhyn & Aristocrat & Mayor & Human & 3 \\ \hline Kaden & Warrior & Watch Captain & Human & 5 \\ \hline Zachariah & Cleric & Head Priest of Zeus & Human & 7 \\ \hline Ardra & Adept & Witch/Magic-shop Owner & Human & 4 \\ \hline \end{tabular*} % NOTE DIFFERENCE \caption{Notable NPCs in hamlet of Westborough} \end{table} ========================================================== 

I have included comments to draw your attention to the two lines that are different from Example H; the environments beginning and ending directives.

### 3.3.1.3. Commands Used in Tables

In the above examples dealing with tables, I’ve used a directive \hline. This, as well as other, directives are available for use in the tabular and tabular* environments. The complete list of these commands and their functions are as follows:

### 3.3.2. The ‘table’ Environment

Now that you know how to make a table, let me re-introduce you to the “table” environment. As I said before, table creation is chiefly done using the tabular and tabular* environments, which provide for the logical formatting of data into cells and rows. The “table” environment is useful for inserting something (a table, a graphic, or regular text) into your document that should be offset from the rest of your document. The biggest advantage to using the “table” environment is that it allows you to easily place you table (or graphic or text) at different places in your document. A second advantage is that it allows you to give tables a caption (recall that pictures and graphics can be captioned anyway). As long as you keep the difference between the “table” and “tabular” environments strait in your head, the advantages of placing your tables inside of a “table” environment will prove quite useful in the process of creating your documents. To begin the “table” environment:

 \begin{table}[position] . . . \end{table} 

Where “position is a variable that indicates where the “table” should be placed. Possible values include: “t”, which puts the “table” at the top of the page; “b”, which puts the “table” at the bottom of the page; “p”, which puts the “table” on a separate pages of “floating” items (no text, just tables, graphics, etc.); and “h”, which tried to put that table at the point in the document where you have created it.

The “table” environment will accept a \caption{text}” command, which will create a caption at the bottom of the “table”, with the number of the table, and whatever “text” is passed to the command.

Using these various commands and environments, you should now be able to create just about any sort of table you wish. Just remember that one of the reasons why tables are so useful is because they are simple to read and understand. While you can “jazz up” your tables with features, don’t let those features impair the readability of your tables. The tables given in examples H and H1 will probably suite most of your table creation needs.

### 3.4. Advanced Header and Footer Formatting

In my section on Simple Header and Footer Manipulation, I talked about LaTeX’s native support for manipulating what goes into the headers and footers of your documents. I also mentioned that LaTeX’s native facilities for document head and foot manipulation were rather limited, and promised to deliver a solution that would allow you to format your papers with MLA compliance. I now present to you the fancyhdr package, which will give you precise control of what goes into your document headers and footers, and exactly where in the headers and footers it will go.

The fancyhdr package comes with the standard distribution of LaTeX, but if you don’t have it, you can download the package and the documentation from the Comprehensive TeX Archive Network (CTAN) at http://www.ctan.org/tex-archive/macros/latex/contrib/supported/fancyhdr/

### 3.4.1. Initializing fancyhdr

Like all packages, to use fancyhdr you’ll need to issue a \usepackage{fancyhdr} directive somewhere near the top of your document. However fancyhdr has another requirement. Remember in Simple Header and ooter Manipulation when I mentioned \pagestyle{}? Well fancyhdr, like the other pagestyle types, needs to be declared here as the pagestyle for the document. The proper directive for this is \pagestyle{fancy}. Once these are issued, you’re ready to rock.

### 3.4.2. Fancy Header and Footer Formatting

Before I get into the commands involved here, it is necessary to mention that fancyhdr sees three seperate parts in a page: the head, the body, and the foot. We can safely ignore the body of the document in this discussion, but the head and foot of the document are structured in such a way so that they both have a left side, a center, and a right side; these are the possible targets for your formatting, which should be fine as this safely covers any region of the header or footer that you are likely going to want to put any information in.

Describing what goes into these six seperate regions is quite simple. This is due to the fact that each region is a seperate directive. The different directives and the regions they describe are as followed:

 lhead{text}:Left side of Header chead{text}:Center of Header rhead{text}:Right side of Header lfoot{text}:Left side of Footer cfoot{text}:Center of Footer rfoot{text}:Right side of Footer 

Where “text” can be just about anything you want, i.e. actual text (like your name), or a LaTeX command (like \thepage for the page number). If you want to leave any of these regions blank, you can just leave them out. However, you should be warned that different document classes do have default behavior. For example, the article class will put the page number in the center of the footer whether you’ve specified it there (or elsewhere) or not. To correct such an anomaly, simply issue the directive covering the part of the header/footer you want blanked with no argument. In the case of the article class, to override the page number in the center of the footer, use \cfoot{}. This will take care of the problem, as the fancyhdr directive will take precedence over the default, but only when you tell it to specifically.

 Example I: A Document Using fancyhdr ==================================== \documentclass[10pt, helvetica]{article} \usepackage{fancyhdr} \pagestyle{fancy} \lhead{From: Spacing Guild} \chead{} \rhead{To: Emperor Shaddam IV} \lfoot{Re: Your Plans for Arrakis} \cfoot{} \rfoot{07/03/10056} \begin{document} We want Paul Atreides killed. The spice must flow. \end{document} ==================================== 

If you compile this you’ll see that we’ve gotten everything we asked for exactly where we’ve asked for it.

### 3.4.3. Header and Footer Separators

Okay, so we didn’t get exactly what we asked for in Example I, LaTeX gave us something extra in the form of a vertical bar between the header and the rest of the document. The insertion of this bar is the default behavior for the fancyhdr package, but luckily it’s something that we can control. To change the width of the bar, use: \renewcommand{\headrulewidth}{size} Where “size” is a measurement value that will set the width of the bar, and the greater the size, the greater the thickness of the bar. If you would like the bar to be thicker, set this value to a number like “2pt” or higher. If you would like the bar to go away (as I’m sure you will when doing your papers), set the size to “0pt”.

There is no such separator between the footer and the rest of the document by default, or rather the default size for the separator is “0pt”. If you want a bar between the footer and the rest of the document, use: \renewcommand{\footrulewidth}{size} As above, size is a measurement value, and the greater the value, the bigger the bar.

### 3.4.4. Varying Header and Footer Styles

A standard convention that I have found in many books is that the name of the author or of the chapter appears in the chead{}, the page number in the rhead{}, except on the first page of a chapter, in which nothing appears in the header, and the page number appears in cfoot{}. And chances are that when you do something like create a cover page for your reports, you won’t want any header and footer information to appear on the page. Fortunately there are ways of varying what goes in the head and foot on different pages of your document.

To change the style of an individual page, we’ll use the LaTeX native command \thispagestyle{}, which is a lot like \pagestyle{} except that it only affects the page on which it is issued instead of the entire document. In the simplest of cases, where we want to suppress all header and footer printing on a page, \thispagestyle{plain} works nicely, however if you want a different appearance you’re going to have to do more work. Your first (and most undesirable option) is to simply issue a new set of \lhead{}, \chead{}, etc. commands and put new stuff in them, which is detestable because you’ll have to do this each time you want to switch page styles. While this isn’t so bad if you only need to do it once, if you were writing a book or a lengthy report with sectioning, this could rapidly get annoying. In the spirit of “let the tool do the work,” fancyhdr gives us an easy interface for designing new page styles, which in turn can simply be used with a \thispagestyle{myPageStyle} directive whenever we need to switch.

### 3.4.4.1. Defining Your Own Page Styles

To define your own pagestyle, use the \fancypagestyle{myPageStyle}{ directive, where “myPageStyle” is the name of the page style we’re going to define. Note well that left curly brace that follows the initial declaration. The programmers among you already have an idea as to why we’re doing this, but for the rest of you, we are actually writing a block of LaTeX commands that will be associated with the myPageStyle name. We need to group definitions such as this between curly braces so LaTeX understands that we are defining a set of commands, and just as we open our function block with a curly brace, after we’ve finished we’ll need a right curly brace to close. Example I1 below should clarify all of this if you don’t understand.

The next thing we need to do is clear the header and footer, which is done by issuing a \fancyhf{} command. Following that, we are free to define what goes into out headers and footers, which we will do using the following commands:

 \fancyhead[pos]{text} \fancyfoot[pos]{text} 

Where we use \fancyhead for header definitions and \fancyfoot for footer definitions; where “pos” is either “L” for left, “C” for center, or “R” for right; and where text is any text of LaTeX commands that you want to appear in the position you are specifying. Note that, since we’ve already cleared the header and footer, we don’t need to issue any blank directive to override the document class default. For example; to set the page number to appear in the rhead{} in this page style, we would specify: \fancyhead[R]{\thepage}.



We would then use this page style on a specific page by issuing a \thispagestyle{myPageStyle} directive. Or maybe we even like our custom page style so much that we want to make it the default: \pagestyle{myPageStyle}.

I have previously mentioned that books commonly have the authors name or chapter name in the \chead{} and the page number in the \rhead{}, but the truth is a lot of them get fancy and have the author’s name appear in the \chead{} of even-numbered pages, and the chapter name appear in the \chead{} of odd-numbered pages. While you could just define your own page styles and keep issuing \thispagestyle{} directives, this is rather inefficient, and fortunately we don’t have to result to such drudge work to get the job done. Just as you can define where in the header and footer you want things to go when you define a page style, you can also define whether you want that particular information to go on an odd numbered page, or an even numbered page by specifying “O” for odd numbered pages, or “E” for even numbered pages when you specify the position. Please note that this only worked with the “book” document class.


Just by way of warning, LaTeX reads the document top down, and if it encounters the name of a page style before that page style is actually defined, it will halt and signal an error. I find that it is best to actually define the page style right after you’re done issuing \usepackage{} directives. Just remember that if you start issuing \lhead{}, chead{}, etc. directives, they will override the pagestyle default for the rest of the document (or until hitting another \pagestyle{} or \thispagestyle{} directive), and so if you want to use your custom page style as default, it is actually best to define a second page style to be the exception to the rule instead of issuing \lhead{}, \chead{}, etc. directives. I’m sure you can see why this is quite a powerful tool to have at your disposal.

### 3.5. Creating Equations in LaTeX

One of the reasons why LaTeX is so popular in math and science related fields is that it has robust native support for representing equations. Whether you need Greek letters, super and sub scripts, or are looking for other symbols, chances are that you’ll be able to find a LaTeX command to represent it on the screen. Since most of this involves commands to create symbols, I am primarily going to give you a list of tables that tell you how to represent things (Greek letters, for example), but I will provide more in depth information on some of the commands that go beyond simple representation. I will also use a few examples throughout just to make sure you have a clear picture in your head.

To access these features, you’re going to need to use the “math”, “displaymath”, or “equation” environment, depending on what your precise needs are. Use “math” if your forumlae should appear in the text itself, and “displaymath” if you want your formulae to appear on its own line. The “equation” environment is effectively the same as “displaymath”, except that it also includes an equation number. You can access these environments in the standard way, but shortcuts are also available because these environments are so commonly used, and in many cases you just want to display the formula and get back to writing text. The shortcut for “math” mode is ; where the formula is surrounded by a dollar sign on each side (if you want a dollar sign in the formula, you’ll need to escape it: \$). The shortcut for “displaymath” is , but there is not shortcut for “equation” mode, so you’ll need to declare it in the standard way. I should probably mention that LaTeX wants the environment delimiters on the same line as the formula. To demonstrate, it wants this:$ \lambda^{R} $and not this:  $ \lambda^{R} $ I know this is a bit unusual given that all of our other environments are declared the second way (although nothing says they have to be), but it may help if you think of the “math” and related environments as in-line environments, they tend to appear in-line with the rest of the text, and other environments as “block environments,” as they format a block of text. Of course this isn’t to say that it won’t work if you use the second message, but LaTeX will complain at you, and unless you realize this, you’ll spend hours trying to fix code that is, for all appearances, perfectly accurate. ### 3.5.1. Greek Letters The Greek alphabet is used extensively in formulae, more so even than numbers. To display a Greek letter in LaTeX, simply escape the name of the letter; i.e. \alpha would produce the lower case Greek letter alpha. It is my experience that the English spelling of Greek letters changes with various texts, and the variation between spellings is even greater across disciplines. For that reason, I am including this list of the LaTeX escapes for the letters:  \alpha \beta \gamma \delta \epsilo \zeta \eta \theta \iota \kappa \lambda \mu \nu \xi \pi \rho \sigma \tau \upsilon \phi \chi \psi \omega  This list is for the lower case version of the letters. LaTeX supports a limited amount of uppercase Greek letters:  \Gamma \Delta \Theta \Lambda \Xi \Pi \Sigma \Upsilon \Phi \Psi \Omega  Note that the upper case Greek letter names all use an upper case letter to begin their English spellings.. You may have noticed that the Greek letter “Omicron” is not on the list, this is because Omicron, in both its upper and lower case forms, appears exactly as the English letter “O” in its upper and lower case forms. If you need Omicron, just use a regular “o” or “O”. ### 3.5.2. Super and Sub Scripting Superscripting (i.e. for exponential power values) and subscripting (i.e. for index values) are also supported by LaTeX. To display a superscript, use a caret followed by the expression to be super-scripted between curly braces; i.e. x^{x + 1}. To display a subscript, use an underscore followed by the expression to be sub-scripted; i.e. x_{1}, x_{2}, … x_{n}. Both superscripted and subscripted expressions can be nested within another superscripted expression or subscripted expression, so it is possible to have x^{(x + 1)^{2}}. If you need both super and sub scripts on an single element, just have one follow the other; i.e. x_{1}^{2}. Note the difference between this and a nested expression. ### 3.5.3. Commonly Used Symbols Aside from the Greek alphabet, there are many symbols commonly used in formulae. LaTeX supports many of these, and I will try my very best to describe them below. Please keep in mind this is not meant to be an exhaustive list; I am only including the symbols I am easily able to describe here.  \bigcup:A large "U", like a union. \bigcap:A large, upside down "U", like an intersection. \pm:Plus or minus \bigtriangleup:A triangle, like delta. \in:Is a member of symbol \ni:Is a member of symbol reversed \subset:Is a subset of symbol \supset:Is a superset of symbol \equiv:Equivalency symbol \sim:Similar to symbol \simeq:Similar or equal to symbol \approx:Approximation symbol \neq:Inequality symbol \leftarrow:Single-line arrow pointing left \Leftarrow:Double-line arrow pointing left \rightarrow:Single-line arrow pointing right \Rightarrow:Double-line arrow pointing right \uparrow:Single-line arrow pointing up \Uparrow:Double-line arrow pointing up \downarrow:Single-line arrow pointing down \Downarrow:Double-line arrow pointing down \leftrightarrow:Single-line arrow pointing left and right \Leftrightarrow:Double-line arrow pointing left and right \updownarrow:Single-line arrow pointing up and down \Updownarrow:Double-line arrow pointing up and down \angle:Angle symbol \emptyset:Symbol for the empty set \infty:Infinity symbol \sum:Big sigma, for summation operations. \prod:Big pi, for production operations. \sqrt{item}:Square root symbol, "item" underneath \sqrt[n]{item}:Square root symbol, "n" above, "item" underneath \frac{top}{bot}:Fraction with "top" as numerator and "bot" as denominator  As I have said previously, this is not an exhaustive list, these are the more commonly used elements (in my experience, anyway). Also, I am unable to adequately describe many of the other elements; a picture does indeed say a thousand words. If you are looking for an exhaustive list of math and formula related symbols, check out “LaTeX Math Symbols,” by L. Kocbach at: http://www.fi.uib.no/Fysisk/Teori/KURS/WRK/TeX/latex1.html  Example J: Rendering Equations ============================== \documentclass[10pt, helvetica]{article} \begin{document} The following is a mathematical description of a Kleene Star operation, $X^{*} = \bigcup_{i=0}^{\infty} X^{i}$ which allows us to perform an infinite amount of productions on an element X. Note that I am using the display math'' environment. This is because in standard math mode, the infinity and the i=0'' would appear as standard subscripts, whereas convention holds that they should be above and below (respectively) the$\backslash$bigcup operator. So we can't have these as in-line'' equations, but the nature of the over-sized operator makes that impractical anyway. Formulae without over-sized operators, are, however, easily rendered in-line. For example, the Pythagorean Theorem that we all know and love looks like this:$a^{2} + b^{2} = c^{2}$. Simple, right? But then there are times when we want to number our formulae for ease of reference. For example, the sum $$S_{n} = \sum^{n}_{k=0}a_{k}$$ is equivalent to the recurrence $S_{0} = a_{0};$ $$S_{n} = S_{n - 1} + a_{n}, for \, n > 0$$ Note that I've used two different styles here. the reason is that line breaking is generally non-existent in equation'', and so if you have more than one line, you can use the display math mode for all of the line, except for the last line, which is equation'' mode. Consequently, this example (formulae 1 and 2) are from \it Concrete Mathematics, \rm by Graham, Knuth, and Patashnik (1994 Addison Wesley), page 25. \end{document} =============================================  That should suffice to show you the different ways of rendering an equation in your text, and with some real advice to boot. But note what I did in the end; I cited a source in the text. Since I don’t have a works cited page, I had to give the full citation (it’s the only ethical thing to do). Man, you can’t ask for a better introduction to your next topic than that… ### 3.6. Creating a Works Cited/Referenced Page There are two chief ways to create a work cited or referenced page. The first, and probably most obvious, is to do it by hand. This involves bizare combinations of suppressing and forcing indentations, as well as constant compiling and re-adjustment of your document. By and large, it is an unfavorable option, but also doesn’t take much effort to learn. Since it is a matter of suppressing and forcing indentations in stylized ways, I will not discuss it here. You should know by now how to create and remove whitespace in your documents. Besides, BibTex is a far more favorable option. What’s BibTeX, you ask? BibTex is the LaTeX way of auto-magically formatting your bibliographies and works cited pages. Well, okay, so it’s not that auto-magic, it is actually fairly complicated at first, but once you learn it, you will find that using BibTex requires less time and energy than manual citations and works cited pages will. ### 3.6.1. Making a Bibliography Database The first thing you have to do to use BibTeX is create a bibliography database. That’s no where near as scary as it sounds. A bibliography database is simply a collection of data that describes the material you would put in your bibliography; i.e. the type of material (a book, article, etc.), the author, the publication date, etc. There is actually a rather extensive list of acceptable materials (entry types) and data pertinent thereto (field types). Before I give the complete list, why don’t I show you an example of a bibliography database.  Example K: A Simple Bibliography Database ========================================= @BOOK{faulkner, AUTHOR={William Faulkner}, TITLE={As I Lay Dying}, PUBLISHER={Vintage International}, YEAR={1985}, ADDRESS={New York}, } =========================================  That’s all there is to it; just name the file with a “.bib” extension. Now, let me describe the tricky parts slowly. @BOOK{faulkner, is the line that begins the database entry. “@BOOK” is an entry type that tells BibTeX that this particular collection of data is about a book (no surprises there). This is followed by a curly brace, which tells BibTex that we are now beginning the body of the entry (note the closing curly brace at the end; this tells BibTeX that we are done with this entry). By writing “faulkner” as the first entry, I am telling BibTeX that when I want a citation of this entry in the text, I may refer to it as “faulkner”, as in \cite{faulkner}. The rest of the fields are pretty self-explanatory, but note that the values for the fields are contained between curly braces, and followed by a comma. This is an awfully small bib file, but it serves as a nice example. The extensive list of possible entry types and the fields (required and optional) that they can take follows below. ### 3.6.1.1. Bibliography Database Entry Types and Fields  @ARTICLE: Required: author, title, journal, year Optional: volume, number, month, note, pages, key @BOOK: Required: author OR editor, title, publisher, year Optional: volume, series, address, edition, month, note, key @BOOKLET: Required: title Optional: author, howpublished, address, month, year, note, key @CONFERENCE: Required: author, title, booktitle, year Optional: editor, pages, organization, publisher, address, month, note, key @INBOOK: Required: author OR editor, title, chapter AND/OR pages, publisher, year Optional: volume, series, address, edition, month, note, key @INCOLLECTION: Required: author, title, booktitle, year Optional: editor, pages, organization, publisher, address, month, note, key @INPROCEEDINGS: Required: author, title, booktitle, year Optional: editor, pages, organization, publisher, address, month, note, key @MANUAL: Required: title Optional: author, address, organization, edition, month, note, year, key @MASTERSTHESIS: Required: author, title, school, year Optional: address, month, note, key @MISC: Required: Optional: author, title, howpublished, month, year, note, key @PHDTHESIS: Required: author, title, school, year Optional: address, month, note, key @PROCEEDINGS: Required: title, year Optional: editor, publisher, organization, address, month, note, key @TECHREPORT: Required: author, title, institution, year Optional: type, number, address, month, note, key @UNPUBLISHED: Required: author, title, note Optional: month, year, key.  The description of these entry types tends to be pretty self explanatory, as do the field entries that they ask for. Unless you are working with something extraordinarily specific, you should be able to get by using the @BOOK and @ARTICLE entry types, as they cover some broad ground. ### 3.6.2. Using the Bibliography Database Now that we’ve gone to the trouble of making a bibliography database, it might be a good idea to look at how it can be used in our documents. The first, and most obvious use, is to create our works cited or referenced section. To do this, we need to do two things; first, we tell BibTex what style of bibliography we want (don’t panic, I’ll get to this more in a minute), which we do with the \bibliographystyle{name} directive, where name is the name of the bibliography style we’re going to use. The accepted pre-defined styles include: There are a number of styles that you can download, and it is possible to define your own, which we’ll talk about below. Now that we’ve defined the style of the bibliography (and the citation labels), we need to actually insert the bibliography. We do this by issuing a \bibliography{name} directive, where name is the name of the bibliography file we are using, sans the “.bib” extension (it is presumed). So if the bib file were called “mybib.bib”, we would use “mybib” as the argument to \bibliography. This will create a bibliography wherever we place the \bibliography directive, but there is another command we can use too. Remember the citation keys we created (“faulkner” in the above example)? For those of you who haven’t written a research paper, report, etc., it is considered good form to cite where your information comes from in the text, as well as listing where you got it from at the end. This way, I can quote Faulkner in the text, issue a brief citation, and move on without having to write anything into the text itself. When using BibTex, a citation is created by issuing the \cite[text]{key} directive, where “key” is the citation key given to the specific entry in the bib file, and “text” is any text we want to insert (like the page number), which will appear directly after the citation. It is important, at this point, to note that you need to go through some special compilation procedures to get BibTeX working properly. The reasons for this are rather technical, and if you want to know why this is necessary, I strongly suggest you look in the references section to learn more. Suffice it to say that to compile your LaTeX documents to use BibTeX you have to do the following, where the name of the LaTeX document is myfile.tex, and the name of the bib file is myfile.bib:  latex myfile bibtex myfile latex myfile latex myfile  Once you’ve done this, your documents will be readable, and incorporate the BibTeX references. Of course, this assumes that you are using a command line environment like a Linux shell to process your LaTeX files. If you are using a graphical interface, check with the documentation that came with your program to find out exactly how to do this. Now let’s take a look at an example using BibTeX more fully. I’m going to re-do example J form above, because I used a manual citation there. The first example is the LaTeX document, the second is the bib file.  EXAMPLE K1: Example J redone with BibTeX ======================================== \documentclass[10pt, helvetica]{article} \begin{document} The following is a mathematical description of a Kleene Star operation, $X^{*} = \bigcup_{i=0}^{\infty} X^{i}$ which allows us to perform an infinite amount of productions on an element X. Note that I am using the display math'' environment. This is because in standard math mode, the infinity and the i=0'' would appear as standard subscripts, whereas convention holds that they should be above and below (respectively) the$\backslash$bigcup operator. So we can't have these as in-line'' equations, but the nature of the over-sized operator makes that impractical anyway. Formulae without over-sized operators, are, however, easily rendered in-line. For example, the Pythagorean Theorem that we all know and love looks like this:$a^{2} + b^{2} = c^{2}$. Simple, right? But then there are times when we want to number our formulae for ease of reference. For example, the sum $$S_{n} = \sum^{n}_{k=0}a_{k}$$ is equivalent to the recurrence $S_{0} = a_{0};$ $$S_{n} = S_{n - 1} + a_{n}, for \, n > 0$$\cite[p. 24]{math} Note that I've used two different styles here. the reason is that line breaking is generally non-existent in equation'', and so if you have more than one line, you can use the display math mode for all of the line, except for the last line, which is equation'' mode. \bibliographystyle{alpha} \bibliography{test} \end{document} ===============================================================   EXAMPLE K2: Bibliography database File (bib file) for EXAMPLE K1 ================================================================ @BOOK{math, AUTHOR={Graham, Knuth, Patashnik}, TITLE={Concrete Mathematics}, PUBLISHER={Addison Wesley}, YEAR={1994}, ADDRESS={Reading}, } ================================================================  Hopefully that will clarify things a little, and now perhaps you can see some of the strengths of using BibTeX, but I’m sure that you’ve also noticed an incredible weakness; the citation style, as well as the bibliography style is very specific, and may not be what we’re looking for. Fear not, gentle readers, for there is a way we can change this, and indeed I’ve mentioned edit before. It’s time to discuss the ability to make your own bibliography styles. ### 3.6.3. Custom Bibliography Styles Before I jump right into this, I should mention that to take full advantage of custom bibliography styles, you’re going to need to do some serious LaTeX programming, which is something we’ll get into below. For now, I’ll show you some examples of basic tweaking of bibliography styles to change the general look of the output. Later on, after I’ve discussed such things as writing your own LaTeX macros, I’ll revisit the idea of writing some more serious changes into a bibliography style. For now, if you need a style not provided in the standard LaTeX distribution, I highly recommend you do a search for it at the CTAN archive ( http://www.ctan.org), or browse through the BibTeX archive at the CTAN archive ( http:www.ctan.org/tex-archive/biblio/bibtex/). People have known about the lack of style options for years now, and I can assure you with a reasonable degree of certainty that if you look for it at the archive, you will find what you are looking for. ### 3.6.3.1. Altering A Bibliography Style Writing your own from scratch goes well beyond the scope of what you know at this point, and as I said above, chances are that you will never need to. Thus I will here introduce you to the basic concepts that govern the authoring of a bibliography style file (usually “.bst”), and show you how to tweak it to suite your needs, as this is the extent that most of you will ever have to do. I will be using the “alpha.bst” file, which is located in my system at /usr/share/texmf/bibtex/bst/base/alpha.bst (presuming a Linux LaTeX environment) , as the template for this discussion, but as the file is rather long, I will only refer to sections of it by line number. Please note that these are the line numbers for the original unaltered file, so you might want to keep a clean copy of it handy for reference purposes as you experiment. In fact, before we do anything else, let’s make a copy of “alpha.bst” in our home directory, and call it “myalpha.bst”, then change the style we used in Example J to “myalpha”. It should compile and appear exactly as it did when we were using “alpha” as the style. Buckle up partners, now the fun begins. Those of you who have used MLA citation and bibliography guidelines will no doubt see the myriad of problems with the way the citation, as well as the bibliography entry look. Now, we’re not going to fix all of these problems, especially because there is an mla.bst file available at CTAN, but we are going to play around with a few of the more glaring issues. Before we begin playing around with it, take a look at myalpha.bst and try to get a picture in your mind how and where the styles are being applied to the information in the bib file. Okay, for altering the citation and bibliographic output for items in myalpha.bst, we’re going to want to look at the output.bibitem function, which starts on line 87. The first thing we need to do is get rid of writing the label (this is not MLA), which can be done by commenting out the label write$ line. Try compiling the document now, and notice where there used to be a label there is no empty space. Of course, empty space is not MLA either, so we need to take care of this. That means we will need to change the way that the string is formatted rather than simply the way that it is output. For this, we need to visit the format.names function that begins on line 187. Specifically look at line 193, this contains the format code for the name.

The formatting for a book by one author is pretty simple; we want the last name followed by the first name in the bibliography itself, and we can do this by changing the line to: { s nameptr “{ll}{,~ff}” format.name$‘t := Did you guess how it works??? the {ll} represents the last name as a whole, and the {,~ff} represents a a comma, followed by a space, followed by the first name as a whole. I doubt I’m giving away any secrets here, but the “l” delineates a last name, and the “f” delineates a first name. But wait… what where those other letters, the “v” and the “j” that we got rid of? BibTeX sees a name in four parts; the First Name, a Von (middle name), a Last Name, and a Junior (qualifier). An example of a full name as BibTex would see it would look like “Manfred Von Richthofen Sr.” In formating terms, you must have a last name, but anything else can be blank. Also, if you only want the first initial of the name, you can use one format code instead of two; {ll}{,~f} would format the name to appear as the entire last name, followed by a comma, followed by a space, followed by the first letter of the first name. Play around with this and see what wacky combinations you can come up with. Okay, so now we’ve got that whole name formatting thing taken care of, and out bibliography entry looks nice and MLA. Now what about that annoying label? We want it for purposes of citation, although we are going to have to make some changes, but it has to go from the bibliography. For now, let’s work on changing it for citation purposes. Take a look at line 968 of your “myalpha.bst” file; which is contained in the function format.lab.names. Note the #3 toward the end of the line; this tells BibTeX to push the integer three on to the stack; an integer which determines how many letters of the last name we’re going to include in the citation. Try it out, change the three to a five. However, we’re actually going to want the whole name, not just a portion of it. I’m sure a few of you tried just deleting the “#3″ and compiling it, and then got a bunch of error messages; this is because that number is necessary to actually tell BibTeX how much we want to pop off of the stack when the time comes. Unfortunately we won’t know the size of the name each time, so we’re going to have to do some fancy stack manipulation. After the format.names$ function, use the duplicate$function; the top of the stack should at this point be the author’s last name, and we are going to need two copies of it, one for counting the number of letters, and one for actual printing. After we’ve duplicated the author’s last name, we need to find out it’s size; the text.length$ function will pop the stack, count the size of the string literal, and push the size back on. This is why we needed a duplication of the name, if we only had one copy on the stack, it would no be lost. Finally, we use the text.prefix$function to grab the size of the name (which is on the top of the stack), and then the name itself for formatting. All told, you should change line 968 so it looks like: { pop$ s #1 “{ll}” format.name$duplicate$ text.length$text.prefix$ } Now, if you’re not used to writing for BibTeX, or even worse, if you’re not used to programming in general, this can be a quite confusing process. The key to all of this is keeping track of what’s on the stack, and in what order it is there. BibTeX has a function called stack\$ that can help with this; it immediately pops everything off the stack, and displays it on the screen; just be aware that your BibTeX compilation will terminate in an error when you do this.

The simplest way to get rid of the year markers from the label is to edit lines 1047 and 1050. In both cases, you’ll see a #-1 and #2 in the string; these tell BibTeX (later on) where to start and where to finish in grabbing numbers out of the year field for the label. To change this (since we want to get rid of the year all together) is to just change both of these numbers to #0. Then none of the year will get touched.

Now there’s the matter of getting the label out of the bibliography itself. Unfortunately, this is not possible; “myalpha.bst” uses the \bibitem[label]{key} command to create a bibliography entry, which will write “label” by the citation in the bibliography. If omitted, it writes the number of the item in place of the label. Thus, if our ultimate aim is to achieve perfect MLA style, we cannot succeed unless we change the method with which the citation is written; however doing this would be getting into writing functions and commands, and as I previously stated, that is a bit beyond the scope of this introductory BibTeX tutorial.

By now you should be well aware of the strengths and weaknesses of using BibTeX in your documents. While it is a handy tool to have, if you need to do your paper NOW, it would probably be easier for you to do it by hand, as learning the ins and outs of fully customizing BibTeX will probably take more time than you have.

Top

## 4. Liscence

GNU Free Documentation License Version 1.2, November 2002

Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.

0. PREAMBLE

The purpose of this License is to make a manual, textbook, or other functional and useful document “free” in the sense of freedom: to assure everyone the effective freedom to copy and redistribute it, with or without modifying it, either commercially or noncommercially. Secondarily, this License preserves for the author and publisher a way to get credit for their work, while not being considered responsible for modifications made by others.

This License is a kind of “copyleft”, which means that derivative works of the document must themselves be free in the same sense. It complements the GNU General Public License, which is a copyleft license designed for free software.

We have designed this License in order to use it for manuals for free software, because free software needs free documentation: a free program should come with manuals providing the same freedoms that the software does. But this License is not limited to software manuals; it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference.

1. APPLICABILITY AND DEFINITIONS

This License applies to any manual or other work, in any medium, that contains a notice placed by the copyright holder saying it can be distributed under the terms of this License. Such a notice grants a world-wide, royalty-free license, unlimited in duration, to use that work under the conditions stated herein. The “Document”, below, refers to any such manual or work. Any member of the public is a licensee, and is addressed as “you”. You accept the license if you copy, modify or distribute the work in a way requiring permission under copyright law.

A “Modified Version” of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language.

A “Secondary Section” is a named appendix or a front-matter section of the Document that deals exclusively with the relationship of the publishers or authors of the Document to the Document’s overall subject (or to related matters) and contains nothing that could fall directly within that overall subject. (Thus, if the Document is in part a textbook of mathematics, a Secondary Section may not explain any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them.

The “Invariant Sections” are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice that says that the Document is released under this License. If a section does not fit the above definition of Secondary then it is not allowed to be designated as Invariant. The Document may contain zero Invariant Sections. If the Document does not identify any Invariant Sections then there are none.

The “Cover Texts” are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that the Document is released under this License. A Front-Cover Text may be at most 5 words, and a Back-Cover Text may be at most 25 words.

A “Transparent” copy of the Document means a machine-readable copy, represented in a format whose specification is available to the general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file format whose markup, or absence of markup, has been arranged to thwart or discourage subsequent modification by readers is not Transparent. An image format is not Transparent if used for any substantial amount of text. A copy that is not “Transparent” is called “Opaque”.

Examples of suitable formats for Transparent copies include plain ASCII without markup, Texinfo input format, LaTeX input format, SGML or XML using a publicly available DTD, and standard-conforming simple HTML, PostScript or PDF designed for human modification. Examples of transparent image formats include PNG, XCF and JPG. Opaque formats include proprietary formats that can be read and edited only by proprietary word processors, SGML or XML for which the DTD and/or processing tools are not generally available, and the machine-generated HTML, PostScript or PDF produced by some word processors for output purposes only.

The “Title Page” means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material this License requires to appear in the title page. For works in formats which do not have any title page as such, “Title Page” means the text near the most prominent appearance of the work’s title, preceding the beginning of the body of the text.

A section “Entitled XYZ” means a named subunit of the Document whose title either is precisely XYZ or contains XYZ in parentheses following text that translates XYZ in another language. (Here XYZ stands for a specific section name mentioned below, such as “Acknowledgements”, “Dedications”, “Endorsements”, or “History”.) To “Preserve the Title” of such a section when you modify the Document means that it remains a section “Entitled XYZ” according to this definition.

The Document may include Warranty Disclaimers next to the notice which states that this License applies to the Document. These Warranty Disclaimers are considered to be included by reference in this License, but only as regards disclaiming warranties: any other implication that these Warranty Disclaimers may have is void and has no effect on the meaning of this License.

2. VERBATIM COPYING

You may copy and distribute the Document in any medium, either commercially or noncommercially, provided that this License, the copyright notices, and the license notice saying this License applies to the Document are reproduced in all copies, and that you add no other conditions whatsoever to those of this License. You may not use technical measures to obstruct or control the reading or further copying of the copies you make or distribute. However, you may accept compensation in exchange for copies. If you distribute a large enough number of copies you must also follow the conditions in section 3.

You may also lend copies, under the same conditions stated above, and you may publicly display copies.

3. COPYING IN QUANTITY

If you publish printed copies (or copies in media that commonly have printed covers) of the Document, numbering more than 100, and the Document’s license notice requires Cover Texts, you must enclose the copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present the full title with all words of the title equally prominent and visible. You may add other material on the covers in addition. Copying with changes limited to the covers, as long as they preserve the title of the Document and satisfy these conditions, can be treated as verbatim copying in other respects.

If the required texts for either cover are too voluminous to fit legibly, you should put the first ones listed (as many as fit reasonably) on the actual cover, and continue the rest onto adjacent pages.

If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy a computer-network location from which the general network-using public has access to download using public-standard network protocols a complete Transparent copy of the Document, free of added material. If you use the latter option, you must take reasonably prudent steps, when you begin distribution of Opaque copies in quantity, to ensure that this Transparent copy will remain thus accessible at the stated location until at least one year after the last time you distribute an Opaque copy (directly or through your agents or retailers) of that edition to the public.

It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document.

4. MODIFICATIONS

You may copy and distribute a Modified Version of the Document under the conditions of sections 2 and 3 above, provided that you release the Modified Version under precisely this License, with the Modified Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version:

1. Use in the Title Page (and on the covers, if any) a title distinct from that of the Document, and from those of previous versions (which should, if there were any, be listed in the History section of the Document). You may use the same title as a previous version if the original publisher of that version gives permission.
2. List on the Title Page, as authors, one or more persons or entities responsible for authorship of the modifications in the Modified Version, together with at least five of the principal authors of the Document (all of its principal authors, if it has fewer than five), unless they release you from this requirement.
3. State on the Title page the name of the publisher of the Modified Version, as the publisher.
4. Preserve all the copyright notices of the Document.
5. Add an appropriate copyright notice for your modifications adjacent to the other copyright notices.
6. Include, immediately after the copyright notices, a license notice giving the public permission to use the Modified Version under the terms of this License, in the form shown in the Addendum below.
7. Preserve in that license notice the full lists of Invariant Sections and required Cover Texts given in the Document’s license notice.
8. Include an unaltered copy of this License.
9. Preserve the section Entitled “History”, Preserve its Title, and add to it an item stating at least the title, year, new authors, and publisher of the Modified Version as given on the Title Page. If there is no section Entitled “History” in the Document, create one stating the title, year, authors, and publisher of the Document as given on its Title Page, then add an item describing the Modified Version as stated in the previous sentence.
10. Preserve the network location, if any, given in the Document for public access to a Transparent copy of the Document, and likewise the network locations given in the Document for previous versions it was based on. These may be placed in the “History” section. You may omit a network location for a work that was published at least four years before the Document itself, or if the original publisher of the version it refers to gives permission.
11. For any section Entitled “Acknowledgements” or “Dedications”, Preserve the Title of the section, and preserve in the section all the substance and tone of each of the contributor acknowledgements and/or dedications given therein.
12. Preserve all the Invariant Sections of the Document, unaltered in their text and in their titles. Section numbers or the equivalent are not considered part of the section titles.
13. Delete any section Entitled “Endorsements”. Such a section may not be included in the Modified Version.
14. Do not retitle any existing section to be Entitled “Endorsements” or to conflict in title with any Invariant Section.
15. Preserve any Warranty Disclaimers.

If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version’s license notice. These titles must be distinct from any other section titles.

You may add a section Entitled “Endorsements”, provided it contains nothing but endorsements of your Modified Version by various parties–for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard.

You may add a passage of up to five words as a Front-Cover Text, and a passage of up to 25 words as a Back-Cover Text, to the end of the list of Cover Texts in the Modified Version. Only one passage of Front-Cover Text and one of Back-Cover Text may be added by (or through arrangements made by) any one entity. If the Document already includes a cover text for the same cover, previously added by you or by arrangement made by the same entity you are acting on behalf of, you may not add another; but you may replace the old one, on explicit permission from the previous publisher that added the old one.

The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version.

5. COMBINING DOCUMENTS

You may combine the Document with other documents released under this License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its license notice, and that you preserve all their Warranty Disclaimers.

The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single copy. If there are multiple Invariant Sections with the same name but different contents, make the title of each such section unique by adding at the end of it, in parentheses, the name of the original author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work.

In the combination, you must combine any sections Entitled “History” in the various original documents, forming one section Entitled “History”; likewise combine any sections Entitled “Acknowledgements”, and any sections Entitled “Dedications”. You must delete all sections Entitled “Endorsements”.

6. COLLECTIONS OF DOCUMENTS

You may make a collection consisting of the Document and other documents released under this License, and replace the individual copies of this License in the various documents with a single copy that is included in the collection, provided that you follow the rules of this License for verbatim copying of each of the documents in all other respects.

You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document.

7. AGGREGATION WITH INDEPENDENT WORKS

A compilation of the Document or its derivatives with other separate and inde pendent documents or works, in or on a volume of a storage or distribution medium, is called an “aggregate” if the copyright resulting from the compilation is not used to limit the legal rights of the compilation’s users beyond what the individual works permit. When the Document is included in an aggregate, this License does not apply to the other works in the aggregate which are not themselves derivative works of the Document.

If the Cover Text requirement of section 3 is applicable to these copies of the Document, then if the Document is less than one half of the entire aggregate, the Document’s Cover Texts may be placed on covers that bracket the Document within the aggregate, or the electronic equivalent of covers if the Document is in electronic form. Otherwise they must appear on printed covers that bracket the whole aggregate.

8. TRANSLATION

Translation is considered a kind of modification, so you may distribute translations of the Document under the terms of section 4. Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a translation of this License, and all the license notices in the Document, and any Warranty Disclaimers, provided that you also include the original English version of this License and the original versions of those notices and disclaimers. In case of a disagreement between the translation and the original version of this License or a notice or disclaimer, the original version will prevail.

If a section in the Document is Entitled “Acknowledgements”, “Dedications”, or “History”, the requirement (section 4) to Preserve its Title (section 1) will typically require changing the actual title.

9. TERMINATION

You may not copy, modify, sublicense, or distribute the Document except as expressly provided for under this License. Any other attempt to copy, modify, sublicense or distribute the Document is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance.

10. FUTURE REVISIONS OF THIS LICENSE

The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See http://www.gnu.org/copyleft.

Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this License “or any later version” applies to it, you have the option of following the terms and conditions either of that specified version or of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation.

ADDENDUM: How to use this License for your documents

To use this License in a document you have written, include a copy of the License in the document and put the following copyright and license notices just after the title page:

Copyright (c) YEAR YOUR NAME. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled “GNU Free Documentation License”.

If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, replace the “with…Texts.” line with this:

with the Invariant Sections being LIST THEIR TITLES, with the Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.

If you have Invariant Sections without Cover Texts, or some other combination of the three, merge those two alternatives to suit the situation.

If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software.

Top

## 5. References

No, I wasn’t born endowed with some mystical knowledge of LaTeX, I did a lot of research when I was first learning how to use it, and quite a bit more to help me compile this document. There are books on LaTeX out there that you can buy, but I never saw the need. The following are freely available online (or even on your system!!!), just like this tutorial. Among the various places online that talk about LaTeX are:

1. LaTeX 2e Online Help This is *THE* guide for LaTeX. It contains thorough descriptions of every command that LaTeX supports natively. If you’re on a *NIX system, you can just type “info latex” at the command prompt to view the specific documentation for the version installed on your system. You can also find it on the web in HTML (and I’m sure other) formats. An older version (1.4, current is 1.6) of the LaTeX 2e Online Help in HTML format can be found at: http://www.math.upenn.edu/latex/latex2e.html
2. “Getting Started with LaTeX,” by David R. Wilkins. Another excellent tutorial on LaTeX document preparation. Available at: http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/
3. “Graphics and Colour with LaTeX,” by Patrick W. Daly. This was, of course, a great source of information for describing the use of the graphicx package. Available at: http://www.linmpi.mpg.de/~daly/latex/grf.htm
4. “Page Layout in LaTeX,” by Piet van Oostrum. This is my primary source of information on the fancyhdr package, and is written by the author of said package. Since fancyhdr is itself not part of the core LaTeX distribution (it is a standard package that accompanies most distributions, however), the “LaTeX2e Online Help” will be of little use to you, and I highly recommend reading through this excellent piece of documentation if you want to learn more about fancyhdr. It is available in both TeX and DVI formats from the CTAN archive for fancyhdr: http://www.ctan.org/tex-archive/macros/latex/contrib/supported/fancyhdr
5. “LaTeX Math Symbols,” by L. Kocbach. This is a (to my knowledge) complete list of all LaTeX math and formula symbols available. Best of all, he’s go pictures of the actual symbol to go along with the LaTeX code. I highly recommend you download this page and its associated images, and save it locally somewhere on your computer if you are going to be doing a lot with formulae. Get it at: http://www.fi.uib.no/Fysisk/Teori/KURS/WRK/TeX/latex1.html
6. “Designing BibTeX Styles,” by Oren Patashnik. This is the most complete document I’ve been able to find online detailing BibTeX style alteration. It is available at: http://www.eeng.dcu.ie/local-docs/btxdocs/btxhak/btxhak.html

Top

## 6. Errata

This is the first “complete” version of this tutorial. By “complete,” I mostly mean “pared down and edited,” as there is still a bit more to include. A preview version was published as a text file at The Axis of Time in July of 2002. Version 1.0 was first publised at The Axis of Time in. December of 2003.

Posted on : August 22, 2014
Tags:

You might also likeclose
• Friday, 22/08/2014 7:10 AM