General Disarray: Latex + Visio
General Disarray: Latex + Visio
General Disarray: Latex + Visio
General Disarray
Abject miscellany
Blog
About
Ads by Google
LaTeX + Visio
Professional-looking math in your technical drawings.
elevatorlady.ca
This post introduces the LaTeX typesetting system. After digesting the information below, you’ll be able
to:
These topics cover the majority of tasks that most people need to do when writing a document. However,
please note that while the LaTeX system makes it very easy to create professional-looking documents, it is
both comprehensive and extensible. There are many topics that are not covered by this basic tutorial.
Fortunately, LaTeX is very well documented. If you come across something that you can’t figure out how
to do, ask your old friend Google for help.
What is LaTeX?
At its core, LaTeX is a typesetting system that allows authors to create highly polished documents without
having to worry about formatting, page breaks, object positioning, or any other style concerns that distract
authors from focusing on writing. LaTeX is pronounced “lay-tech,” as it is an extension of TeX (”tech”),
the original typesetting system. You can read all about the history of TeX and LaTeX on Wikipedia.
LaTeX is used widely in a variety of professions. Mathematicians, physicists, economists, statisticians and
other academics and professionals that regularly use mathematical notation in their documents often use
LaTeX because of the ease with which it handles such notation. Many publishers use TeX-based systems
http://generaldisarray.wordpress.co… 1/13
26/10/2008 LaTeX: from beginner to TeXPert « …
for typesetting documents.
1. Generally, LaTeX documents are written using the easy-to-learn LaTeX markup language, rather
than by using a graphical interface to apply styles[1].
2. LaTeX works with your document after you have entered your text. So unlike word processors, it
can use information about the total length of your document, number of tables, etc. to find the
optimal places for tables, figures, page breaks, etc.
\documentclass{article}
\author{Your Name}
\title{Test Document}
\begin{document}
\maketitle
This is a test document
\end{document}
With any LaTeX distribution, saving the above text as a .tex file and running LaTeX on that file would
produce the following:
LaTeX is designed to create the same output on any system. So if you distributed the above text to
anyone with a working LaTeX distribution, regardless of their particular system, they would get the exact
same result. LaTeX outputs files in several formats, but the most popular is PDF.
Getting LaTeX
All you technically need to create LaTeX documents is a LaTeX engine — the binary files and libraries
that will convert plain text tex files to polished pdf files. LaTeX can be run from the command line, so *nix
and DOS aficionados will feel right at home. However, using a frontend for LaTeX can make things much
easier. Most frontends are essentially text editors with functions to
In this document, I assume that you’ll need both a LaTeX engine and a frontend. There are many engines
and frontends to choose from on every operating system. I’m going to describe how to install the most
popular (and easy to install) open-source tools for OS X and Windows. The only difference between
http://generaldisarray.wordpress.co… 2/13
26/10/2008 LaTeX: from beginner to TeXPert « …
using the distributions that I describe and others is configuration and practical difference between
applications, so feel free to try out other distributions.
On Mac OS X
Engine. gwTeX is a free and open-source LaTeX distribution for OS X that comes with a graphical
installer. To install, you download the i-Installer application, select a mirror, then select the TeX package.
Additional installation instructions are available on the download page. Once installation is complete, all
you need is a frontend.
Frontend. TeXShop is a very popular LaTeX frontend for OS X. Installation requires a simple drag and
drop to the /Applications folder. TeXShop is automatically configured to work with gwTeX, so if that’s
the engine that you’re using, you’re set.
To test out your distribution, try saving the sample document above as a .tex file and running LaTeX on
your document by pressing command-t. If everything is configured properly, a window will appear similar
to the example output above, and a new PDF file (as well as a log file) will appear in the directory where
your file is saved.
On Windows
Engine. MikTeX is a popular open-source distribution. To install, visit this page, download the
executable, and follow the dialog. Additional installation instructions are on the download page.
Frontend. TeXnic Center is an open-source frontend with many helpful features. Installation is standard,
just download and open the executable, which opens a wizard.
TeXnic center is automatically configured to work with MikTeX. To test out your setup, save the sample
document above as a .tex file using TeXnic Center and select Build > Current file. If everything is set up
properly, a new PDF file (along with a log file) will be created in the directory where your document is
saved.
On Linux
Linux systems have their own application management utilities (apt-get or rpm, for example), and
installation will depend on your particular Linux distribution. Ubuntu users can use the Synaptic Package
Manager. Kile is a popular and easy-to-use frontend that works with both KDE and Gnome.
LaTeX can make several types of output files, including PDF and DVI (device independent) files. The
type of output depends on whether PDFLaTeX is used to process the file, or another program. The
default for the frontends defined above is to create PDF files, but be aware that changing these settings
might affect the type of output created.
LaTeX basics
LaTeX commands
http://generaldisarray.wordpress.co… 3/13
26/10/2008 LaTeX: from beginner to TeXPert « …
LaTeX commands generally begin with a backslash and take the form \command[options]{argument}.
For example,
\section{Introduction}
would define a new section, named “Introduction.” The “%” character defines a comment, and everything
from that character to the end of the line is commented out and will be ignored by LaTeX. To insert the
“%” character into a document, escape it with a backslash: \%.
Quotes work a bit differently in LaTeX. To insert quote marks, use the form “text”. That is, the ` character
(top left of the keyboard) twice, followed by the single quote character, ‘, twice.
The preamble
Everything before the line “\begin{document}” is part of the preamble. A typical preamble might look like
this:
\documentclass{article}
\usepackage{graphicx}
\title{Test}
\author{Test}
\date{}
\documentclass{article} tells LaTeX that the document is an article. Other classes include book,
letter and slides
\usepackage{graphicx} tells LaTeX to use the graphicx package, which allows users to include
many types of graphics in their documents. Packages are covered later on
\title{} and \author{} obviously define the title and author
\date{} tells LaTeX to leave the date blank. \date{April 2006} would print “April 2006″ as the
date. Leaving the \date{} line out would cause LaTeX to use today’s date.
Everything after the preamble and between \begin{document} and \end{document} is part of the
document body. Most of a LaTeX document is simply plain text. To start a new paragraph, insert two
carriage returns (blank lines). LaTeX will ignore one blank line. To force a line break, use \\.
Document structure
http://generaldisarray.wordpress.co… 4/13
26/10/2008 LaTeX: from beginner to TeXPert « …
A document’s structure is defined using \section{} commands. LaTeX is strongly based on well-structured
documents. The structure tags include:
\section{Name}
\subsection{Name}
\subsubsection{Name}
\paragraph{Name}
To insert an unnumbered section, use the command \section*{Name}. The section numbering will
continue as normal with the next section, subsection, etc.
The \paragraph{} command doesn’t need to be included unless you want to insert a heading for a
paragraph. The image below shows the different structure commands in use:
Environments
Environments are special blocks of text. For example, the itemize and enumerate environments create
bulleted and numbered lists, respectively. The following markup:
\begin{itemize}
\item First thing
\item Second thing
\item Third thing
\end{itemize}
\begin{enumerate}
\item First numbered thing
\item Second numbered thing
\end{enumerate}
Note that environments always begin with \begin{environmentname} and end with
\end{environmentname}. They can be nested, so one item of a bulleted list might contain another bulleted
http://generaldisarray.wordpress.co… 5/13
26/10/2008 LaTeX: from beginner to TeXPert « …
list, or a numbered list, etc.
The basic idea behind LaTeX is to absolve the author of formatting duties. Nevertheless, it’s still
occasionally necessary to manually format certain text styles.
Packages
Packages extend LaTeX’s functionality. Package installation essentially consists of two steps:
However, there are exceptions. The filetypes .sty and .cls stand for style and class, respectively. If a
package does not come as a .ins file, but rather a sty or cls file, it does not need to be processed with
LaTeX, and you can skip directly to step two. Also, running LaTeX on a .ins file usually produces a .dtx
file. This file can be processed with LaTeX to create a manual for the package.
Note: To process a package file (ins or dtx) with LaTeX, just open that file with your frontend and
process it like you would a normal tex file.
OS X. To install a new package on your Mac using gwTeX, process the files as described above, and
move the sty, cls and other files to ~/Library/texmf. If this directory does not exist, create it.
Windows. The easiest way to install a package on a PC using MikTeX is to use the MikTeX package
manager, which is available through the Start Menu. Just open the package manager, select a mirror, and
navigate to the package that you want to install. MikTeX will take care of the rest. Another nice feature of
MikTeX is that if you are processing a .tex file that requires a package that isn’t installed on your machine,
it will prompt you to download it.
Next, I discuss two popular packages: graphicx and geometry. These packages are already installed with
gwTeX and MikTeX, so there is no need to download and install them.
http://generaldisarray.wordpress.co… 6/13
26/10/2008 LaTeX: from beginner to TeXPert « …
The graphicx package
The graphicx package allows you to insert images into a LaTeX document. To use it, first use the
command \usepackage{graphicx} in your document preamble. Then, to insert a graphic, use the
command:
\includegraphics[options]{filename.png}
graphicx supports many filetypes, including PDF, PNG and JPG. The options include:
width=Xin
height=Xin
scale=X (where x is between 0 and 1)
While formatting documents using LaTeX is easy, changing those default formats can be fairly difficult. The
geometry package can make changing certain aspects of your document, including the margins, much
easier. To change the margins to 1″ all around, for example, use
\usepackage[margin=1in]{geometry}
Other packages
For just about every modification that you might want to make to a standard LaTeX document, there is a
premade package to help you do so. To learn more about the packages described, or to download new
packages, visit the Comprehensive TeX Archive Network (CTAN).
Figures and tables are LaTeX environments, however they have special attributes, such as the \caption{}
command, which gives tables and figures names. They are called float elements, because their position in
the final compiled document depends on LaTeX’s style algorithm.
Figures
\begin{figure}[hbtp]
\caption{Figure name}
\begin{center}
\includegraphics{filename.pdf}
\end{center}
\label{your-reference-key}
\end{figure}
Tables
A floated table in LaTeX consists of two environments: table, the actual floated entity in the text, and
tabular, the data contained in the table. For example,
\begin{table}[hbtp]
\caption{This table is an example}
\begin{center}
\begin{tabular}{c|cc}
First row, first column & First row second column & First row, third column \\ \hline
Second row, first column & Second row, second column & Second row, third column \\
Third row, first column & Third row, second column & Third row, third column \\
\multicolumn{3}{c}{…}
\end{tabular}
\end{center}
\label{exampletable}
\end{table}
would produce
Everything except the code between \begin{tabular} … \end{tabular} is the same as the figure
environment described above. Here’ s how the
tabular environment works:
\begin{tabular}{c|cc} tells LaTeX to start a new tabular environment with three centered columns.
The bar (”|”) after the first “c”, tells LaTeX that the first column has a vertical border. Using {lcrr}
would create for columns, the first left aligned, the second centered, and the third and fourth right
aligned
http://generaldisarray.wordpress.co… 8/13
26/10/2008 LaTeX: from beginner to TeXPert « …
Table cells are separated by “&” and table rows are separated by “\\”
\hline creates a horizontal line
\multicolumn{3}{c}{Text here} creates a row that spans all three columns, is centered, and
contains the text “Text here”
There are more complicated options for creating and inserting tables, but the rules above cover about
90% of all table needs.[2]
Annotations
LaTeX is capable of automatically creating important annotations, such as footnotes, cross references,
tables of contents and bibliographies. Note that, since the following commands require LaTeX to
automatically number text elements, LaTeX must be run on your document twice for proper display.
Footnotes
To insert a footnote, simply type \footnote{Footnote text here}. LaTeX will automatically insert the
footnote number and text.[3]
Cross references
Table of contents
To insert a table of contents, simply put \tableofcontents at the beginning of your document. (You must run
LaTeX twice to get the table of contents and references to work correctly.)
Bibliography
To create a bibliography, insert a list of the citations at the end of your document, using the form:
\begin{thebibliography}{99}
….
\bibitem{key1} Disarray, General. 2006. “\LaTeX{}: from beginner to \TeX pert.”
\emph{General Disarray Blog}. Available online at
\textt{http://generaldisarray.wordpress.com}. ….
\end{thebibliography}
You must manually type the bibliography entries. To refer to an item within the text, use \cite{key}. The
{99} tells LaTeX that there a maximum of 99 entries in the bibliography. LaTeX needs to know this so it
can correctly justify the bibliography entries with their numbering on the left.
A more efficient way to create bibliographies is to use BibTeX, which allows you to maintain a database
of citations and call them as needed in your bibliography. There are also graphical tools for managing your
reference databases, so you don’t have to hard code the citations, and can easily change them to different
formats. However, BibTeX is too complicated to explain in this document. For an introduction, see this
page.
http://generaldisarray.wordpress.co… 9/13
26/10/2008 LaTeX: from beginner to TeXPert « …
Inserting mathematics
There are several ways to include mathematical notation in LaTeX documents. The most common are
inline notation and the displaymath environment.
Inline
To include some mathematical notation within a paragraph, without offsetting from the rest of the text,
enclose the notation between dollar signs. For example, $a^2+b^2=c^2$ is our favorite theorem.
Display math
The displaymath environment lets you offset some mathematical notation from the rest of the document.
The code
\[
a^2+b^2=c^2
\]
would create a paragraph break and center the equation on the page.
Equation
The equation environment can be used to place numbered equations in the text. For example,
\begin{equation}
a^2+b^2=c^2
\label{pythag}
\end{equation}
would offset the equation just like the displaymath version did, but it would have a number in parenthesis
on the right, and you would by able to call it in the text by typing, for example, “as we see in equation
\ref{pythag}…”
Equation array
The eqnarray environment allows you to align parts of equations at the equal sign. For example,
\begin{eqnarray}
a&=&b+c\\
d&=&e+f
\end{eqnarray}
would produce
http://generaldisarray.wordpress.co… 10/13
26/10/2008 LaTeX: from beginner to TeXPert « …
Mathematical notation
There are many commands for inserting specific mathematical operators and symbols into equations. They
can all be found online, and as always, use Google if you can’t figure out a specific command. The
following are some common operators and commands:
Greek letters: Generally, just use the spelled-out letter. For example, \beta, \gamma and \epsilon. For
upper case, use \Gamma.
Misc symbols: \leftarrow (use \Leftarrow for a double arrow), \rightarrow, etc., \leftrightarrow (<==>, if
and only if), <, >, \leq (less than or equal to), \geq (greater than or equal to)
Indexing and exponents: Subscripts are denoted using the underscore (x_i) and superscripts use the “^”
key (a^2). To type “i sub j comma k” you need to write “i_{j,k}” to tell LaTeX that the “j,k” comprises
the entire subscript. The bracket characters are generic grouping operators in LaTeX, and they won’t
appear in your document.
Some operators: \sum{1/x} or \sum_{i=1}^{\infty}{x_i}, \prod (the product), \coprod (the coproduct),
\sin, \log, \max, etc.
Brackets: For brackets use “(”, “[" or \lbrace and \rbrace for "{" and "}". However, if the notation that
your typing is not inline, use \left( <math here> \right) or \left\lbrace <math here> \right\rbrace.
Matrices: To insert a matrix in either the display math or equation environments, use
\left[ \begin{array}{ccc}
a & b & c \\
d&e&f
\end{array}\right]
Note that the array environment is similar to the tabular environment described above. The code shown
above would produce:
For help with other symbols and operators, see this page.
The instructions above cover many of the basic functions of LaTeX, but there are many more. A good,
thorough introduction is The Not-So-Short Introduction to LaTeX (pdf).
http://generaldisarray.wordpress.co… 11/13
26/10/2008 LaTeX: from beginner to TeXPert « …
Download
Notes
[1] Although commercial implementations of LaTeX, such as Scientific Word, do offer a graphical
interface, and LyX is an open-source, LaTeX-based what-you-see-is-what-you-mean typesetting system
that essentially uses a graphical interface to apply LaTeX markup to text.
[2] OpenOffice users can use Calc2LaTeX to convert between Calc spreadsheets and LaTeX tables. MS
Office users can try Excel2LaTeX, which does the same thing, using Excel spreadsheets. Both utilities are
cross-platform.
[3] To create an “attribution” footnote, where the first footnote is marked by an asterisk, use the
\thanks{text here} command.
Ads by Google
LaTeX + Visio
Professional-looking math in your technical drawings.
elevatorlady.ca
Chikrii Softlab
MS Word to LaTeX with Word2TeX and TeX/LaTeX to MS Word with TeX2Word
www.chikrii.com
TeX Word
True WYSIWYG LaTeX Editor Complete LaTeX publishing system
www.bakoma-tex.com
Type TeX into MS Word
Type or paste TeX equations into Word docs. Free trial
www.Dessci.com/MathType
No Comment
Comments are closed.
Also
Blogroll
Bookmarks
Favorite apps
Feeds I read
My starred Odeo
Subscribe (RSS)
http://generaldisarray.wordpress.co… 12/13
26/10/2008 LaTeX: from beginner to TeXPert « …
a
Select Category
Archives
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
Search
http://generaldisarray.wordpress.co… 13/13