| Art of Problem Solving's Intermediate Algebra starts on June 18. Learn about systems of equations, sequences and series, symmetric sums, classical inequalities, and functional equations. Click here to enroll today! |
General
Information
AMS Math packages
xypic
fancyhdr
Finding Other Packages
Making Your Own
General Information
In the Commands pages, we discussed building your own commands. Fortunately, many, many people have built their own commands already and made them available to LaTeX users in packages. Packages allow us to use extra commands without having to include tons and tons of code in the preamble of a document. Instead, we just add the line
\usepackage{package name}
and we have access to all the commands, symbols, environments, etc., that are in the package.
The American Mathematical Society has produced several packages for use with LaTeX. These packages allow much of the mathematical formatting we have introduced on these pages, as well as much, much more. The packages are included with the installation of MiKTeX. In order to be able to use the commands and symbols in these packages, they must be included in each document in which you require them. To include the packages, include the following in the preamble of your document:
Most of the basic parts of these packages which will be useful to you are covered somewhere on these pages. If you'd like to read about more options these packages provide, read the documentation for them at the following links:
Note that including these packages can slow down the compilation of your document, so you may not want to include them unless you really need them.The xypic package allows you to make tricky diagrams such as ones which include various items connected by arrows or lines. Take a look at the xypic home page to see what xypic can do. The package comes with MiKTeX. To use it, include the following in your preamble:
The fancyhdr package provides an easy way to place text on the top and/or bottom of every page. The fancyhdr package does not come with MiKTeX, but assuming that you installed MiKTeX using our recommendations, it should prompt you to install it the first time you try to use it. You include it in your source file in the usual way:
The fancyhdr user's guide has detailed instructions on how to use the package. Here's an example that illustrates most of the basics you'll need:
\pagestyle{fancy} tells LaTeX that you'll be using the fancy style which allows you to use the header and footer commands.
The \headheight command makes space at the top of the page for the header. Try compiling without it and look through the errors to see what happens.
The \rhead, \chead, \lhead, \rfoot, \cfoot, and \lfoot commands create headers and footers in the obvious places (you'll see them in the output when you create the example).
The \pagebreak forces new pages so you can see how the headers and footers appear on every page.
If introducing headers and footers makes you want to resize the dimensions of the text portion of your page, click here for more information how to do so. Note that if you do resize the dimension of the text portion of your page, you should execute those commands before executing the header and footer commands.
Many, many packages have been created for LaTeX. If there's something unusual that you want to do, there's a good chance that there's already a package out there that does it.
The TeX Catalogue Online has a very comprehensive list of all the LaTeX packages out there.
Making your own high-powered, fancy package like the ones created by the AMS requires a great deal of work and detailed knowledge about LaTeX. However, making your own set of commands or a basic preamble that you can include in any of your LaTeX documents is simple. Just follow these steps:
We recommend that you use different .sty files for all your new commands and for your layout. You may end up having many different layouts, but you'll probably want your custom commands available to all your documents. Separating the commands from the layout preamble makes it easy to include those commands with many different layouts. Do note that every time you create a new .sty, you must go through the steps above to use it (i.e. if you install it with MiKTeX, you have to put it in the folder mentioned above, then use MiKTeX Options as described above to complete the installation). You don't have to reinstall every time you add a command to an existing installed .sty file.
Here's a quick example. In mylay.sty, include the following:
In the file mycommands.sty, put the following:
Install these two files using either method from above.
In a LaTeX source file, put the following:
Notice that we only have to include mylay with \usepackage; mycommands is included in the file mylay.sty (look at the mylay.sty file contents and you'll see the line \usepackage{mycommands}).
If you installed everything properly, your source file should compile just fine now.

