PHYS408W : LATEX Guide

next up previous
Next: 4 The PHYS408W Paper Up: PHYS408W : LATEX Guide Previous: 2 Installing LATEX, TeXnicCenter,

Subsections



3 Using LATEX with TeXnicCenter


3.1 LATEX Source Code : .tex Files

A LATEX document begins with a \documentclass statement, sometimes followed by other initialization and customization commands, followed by the document contents sandwiched between \begin{document} and \end{document} statements. Here is the source code for a very short document.

\documentclass[12 pt]{article}

\begin{document}

\noindent
Hello, world! \LaTeX\ can typeset equations like
\begin{equation}
\int^{2 \pi}_0 \sin^2 \theta d\theta = \frac{1}{2}
\end{equation}
very nicely!

\end{document}
Run TeXnicCenter, and open an empty document (File -> New...). Type or paste the above lines into your document, and save it (File -> Save As...) as hello.tex.

Before you add very much code to your source file, you ought to run it through the LATEX program to locate possible errors and view the output, which brings us to the next topic ...


3.2 Viewing and Printing Typeset Documents : .dvi Files

Once you have the source code for your document in a .tex file, you can ``compile'' it using LATEX into a graphics file for viewing and printing. Click on Build -> Current File -> Build, and a string of messages from LATEX will appear in the TeXnicCenter output frame. The output should look very much like:

--------------------Output Profile: LaTeX => DVI--------------------
This is pdfTeX, Version 3.1415926-1.40.11 (MiKTeX 2.9)
entering extended mode
("hello.tex"
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, afrikaans, ancientgreek, ar
abic, armenian, assamese, basque, bengali, bokmal, bulgarian, catalan, coptic, 
croatian, czech, danish, dutch, esperanto, estonian, farsi, finnish, french, ga
lician, german, german-x-2009-06-19, greek, gujarati, hindi, hungarian, iceland
ic, indonesian, interlingua, irish, italian, kannada, kurmanji, lao, latin, lat
vian, lithuanian, malayalam, marathi, mongolian, mongolianlmc, monogreek, ngerm
an, ngerman-x-2009-06-19, nynorsk, oriya, panjabi, pinyin, polish, portuguese, 
romanian, russian, sanskrit, serbian, slovak, slovenian, spanish, swedish, swis
sgerman, tamil, telugu, turkish, turkmen, ukenglish, ukrainian, uppersorbian, u
senglishmax, welsh, loaded.
("D:\Program Files\MiKTeX 2.9\tex\latex\base\article.cls"
Document Class: article 2007/10/19 v1.4h Standard LaTeX document class
("D:\Program Files\MiKTeX 2.9\tex\latex\base\size12.clo"
("hello.aux") [1]
("hello.aux") )
Output written on hello.dvi (1 page, 764 bytes).
Transcript written on hello.log.

LaTex-Result: 0 Error(s), 0 Warning(s), 0 Bad Box(es), 1 Page(s)
If not, check the syntax of your source file. Warnings and error messages are rather cryptic, but usually refer to a line number. TeXnicCenter shows the line number and column number of the cursor in the status bar at the bottom of the window.

For example, if I leave the ``t'' off of the \noindent statement in hello.tex, I get the following error message in addition to the other messages shown above.

\scalebox{0.7}{
\includegraphics{errorinden.eps}
}
(The l.5 tells me the problem is near line 5.)

If you are following along with your own hello.tex file, you will find that LATEX has produced the additional files hello.aux, hello.log, and hello.dvi in the directory in which you saved your hello.tex file. The .dvi file contains the typeset document in a graphics format (device independent format) that we can view using Build -> View Output. This runs a dvi file viewing program called Yap (Yet another previewer). Your Yap window should show you a digital representation of your typeset document, similar to that shown in Figure 1.

Figure 1: The interesting portion of the .dvi output from LATEX shown by Yap. The rest of the (mostly blank) page and the page number have been omitted.
\begin{figure}\fbox{
\parbox{6.3 in}{
\vspace{6 pt}
Hello, world! \LaTeX\ can ty...
...(u) du = \frac{1}{2}
\end{equation}very nicely!
\vspace{4 pt}
}
}
\end{figure}

3.3 TeXnicCenter Tips

next up previous
Next: 4 The PHYS408W Paper Up: PHYS408W : LATEX Guide Previous: 2 Installing LATEX, TeXnicCenter,

Copyright © 2006-2011, Lewis A. Riley Updated Thu Jan 13 11:59:10 2011