LaTeX Lesson 7 --Graphics in LaTeX

Goals to accomplish during class

  1. Increase your fluency with LaTeX
  2. Build a basic World-Wide Web home page
  3. Make a LaTeX page with included graphics

LaTeX tips

A LaTeX exercise

Recall that in the LaTeX graphics assignment from last class, you worked with an Encapsulated PostScript File (file-type EPSF) called golfer.ps. We used the LaTeX graphics package epsf, which was designed to work with the dvips driver. Since you may want to do similar work on another system, which may use a different driver for converting dvi files, we will also look at the package called graphicx and at the package called epsfig. Open a terminal window and a text editor, and then use your mouse to copy the following LaTeX source code into your editor.


\documentclass[12pt,dvips]{article}  
\usepackage{graphicx}
\title{\LaTeX{} Exercise: Graphicx Package}
\author{}
\date{\today}
\begin{document}
\maketitle

This is a test of the graphicx postscript graphics package.

Some people have a \rotatebox{25}{slanted view} of the world.

\reflectbox{Is this secret writing or what??} 
 
We can both rotate and adjust the dimensions of the included graphics
by commands in the graphicx package.  Here is an example.
Can you tell whether the width was adjusted before or after the
rotation?    

\begin{figure}
\begin{center}
\includegraphics[angle=30,width=4in]{golfer.ps}
\end{center}
\end{figure}      

\end{document}


Save the file as graphicx-test.tex. Make sure that the file golfer.ps is in the same directory as graphicx-test.tex. Then run latex graphicx-test and use dvips to convert the resulting dvi file to graphicx-test.ps. Print this file and turn in hard copy by the end of class.

Remark. To conserve disk space, you should remove the final PostScript file, and you may want to remove the other files produced by LaTeX as well, saving only the source file.


Homework for after class

Of course, you may start on the homework during class if you have time.

An exercise on the epsfig package

Copy the following text into a text editor, and choose one of the the PostScript files that you worked with last time to replace the filename in the various graphics commands. Then save the modified file as epsfig-test.tex. Before you run latex on the new file, make sure that the PostScript files that you want to use have been moved to the same directory.

View your file by using dvips epsfig-test -o epsfig-test.ps and then use your PostScript viewer to look at the typeset file. For exaple, if you are on clam server use the command ghostview epsfig-test.ps. On a PC you should be able to view PostScript by using YAP (Yet Another Previewer).


\documentclass[12pt,dvips]{article}  
\usepackage{epsfig}
\title{\LaTeX{} Exercise:  epsfig package}
\author{}
\date{\today}
\begin{document}
\maketitle

This is a test of the epsfig postscript graphics package.

Here is an example of an included graphic floated as a 
centered box with a height of $y$ inches and a width 
of $x$ inches.

%You should choose suitable numbers as values to substitute for <x> and
%<y> here and in the commands below.  See the example further down.
%(In particular, there should be no angle brackets in the argument to \epsfig.)

\begin{figure}
\begin{center}
\epsfig{file=<your-filename1.ps>, height=<y>in, width=<x>in}
\end{center}
\end{figure} 

We can both rotate and adjust the dimensions of the included graphics
by commands in the epsfig package.  Here is an example.
Can you tell whether the width was adjusted before or after the
rotation?       

\epsfig{file=<your-filename2.ps>, height=4in, width=3in, angle=45}
\end{document}

After viewing the results of your first run, see what the effects are when you change the height or width or angle. What happens if you take out either of the keyvalues height=<something> or width=<something>?

When you have things working to your satisfaction, write up a LaTeX document that displays the effects that you can get with epsfig. You should have at least three included figures. I suggest that you keep the dimensions of the figures modest to avoid creating a huge PostScript file. Please hand in the typeset version of your document at the beginning of our next class meeting.

Reading

Please go ahead and read at least the first two chapters of the textbook "HTML and XHTML, the Definitive Guide" by Musciano and Kennedy

Finished?

If you have done all the in-class activities suggested above, and there is still time left, here are some other activities you can do.


/ Contents /


karel@camden.rutgers.edu
email for Martin L. Karel

Validate this URL

Valid HTML 3.2!