# [OS X TeX] How to Insert Graphics Using TeXShop?

Ross Moore ross at ics.mq.edu.au
Mon Mar 11 02:50:00 EST 2002



Hello Zachary,

You are asking a lot of questions which are answered in many, many
places; e.g. any decent book on LaTeX,
and in help files that can be found with minimal searching on the web.

For example, there is an excellent set of LaTeX tutorials produced by
the TUGIndia user-group. They were mentioned in an email that was posted
on this list less than 24 hours ago.

Since you are clearly very keen, I'll field some of your questions,
and also some that you have not yet asked, which relate to aspects
of what is good LaTeX style which is not properly discussed in
common references.

> I have been able to successfully center the .eps files in my document,
> but a couple more questions have arisen.  First, the figures in my
> document don't seem to be integrated into the text of the document.  The

Figures "float" to where they best fit within your document,
so as not to leave gaping holes within the text-flow.
You can influence the floating, to some extent,
but you cannot suppress it altogether and still retain all of
the automatic numbering aspects of figures.
Tables (using \begin{table} ... \end{table}) also "float".

> figures seem to be placed at the end of the document, which is
> undesired.  Secondly, with the \caption{} command I get a label Figure
> 1: plus whatever I put within the braces {}.  My first question in
> regards to this would be is there a way to decrease the vertical spacing
> between the actual figure and the Figure caption itself?  Secondly, is
> there a way to have the numbering so that I can have Figure 2.1, rather
> than Figure 1?

Yes there is; look in documentation for constructions like:

\renewcommand{\thefigure}{\arabic{section}.\arabic{figure}}

and

\numberwithin{figure}{section}

(which actually requires a very useful package:  \usepackage{amsmath} ).

>
> Thanks,
>

> > out earlier, you don't need the .eps at the end of the filename.
> >
> > To center the figure, I generally use:
> >
> > generated from computation:
\begin{figure}[ht]
^^^^--- prefer "h"ere or the "t"op of the next page.
> > \begin{center}
> > \includegraphics{pulley-kinematics}
> > \end{center}

> > \caption{\label{Figure 2.1} Here is my figure.}

Putting the \label inside the caption works, sort-of.
It's better conceptually to put it afterwards, since the \label
is not actually a part of the caption itself:

\caption{Here is my figure.}\label{pulleykin}

Also, it's better to *not* use numbering within label identifiers.
You may later choose to re-order the sections/chapters of your document,
or to add new figures  within existing sections,
which would then require you to change all the labels
and any \ref commands pointing to those \label s.

It is *much* better to choose a descriptor that is
associated with the contents of the figure.
That way you can refer to it easily:
in LaTeX:  \ref{pulleykin}

> > \end{figure}
> > \end{document}
> >
> > *inside* the caption to avoid potential problems with references.

What problems do you refer to, Gary ?
Certainly the \label must come *after* the \caption ,
for numbering and hyperlinking to work.
Putting it *inside* the \caption's argument is still after the \caption,
but this means that it will be written into the .toc file,
and be expanded when the Table-Of-Contents is constructed.
(This is redundant, and risks errors with badly written macros.)

> >> \begin{document}
> >> \centerline{\small University of Texas at Arlington}
> >
> > [lots deleted]
> >
> >> Am I using the includegraphics command correctly?  Your help is
> >> invaluable.

\includegraphics was OK, but you are doing a lot of other things badly.

Accordingly, I've rewritten the code from a previous message,
to show you how I'd expect to see it, paying proper respect
to the logical nature of the document structure and contents.
This is how my students are taught.

See the revised file below; but also here are a few general comments:

Firstly, ...
you are not marking-up the mathematics correctly, even though you
may be getting output that looks OK at first glance.
(A closer look may reveal poor spacing around mathematical elements.)

You should put $...$ around each *mathematical statement*.
The purpose is to indicate that what comes within the $...$ is symbolic,
and not to be interpreted as English prose (or any other language).
Do *not* put $..$ simply to get the appearance that you think you want.
The $...$ are to mark-up the logical interpretation of their contents
as being mathematics. TeX's internal rules then take over
to produce a desirable visual presentation.

Conversely, do not fail to mark-up as mathematics something that is indeed
a mathematical symbol; e.g., a lone $x$ or $y$ or $n$ in your text.

Of course using $$...$$ instead of $...$ is OK too.

Secondly, ...
so that when you come back to it weeks/months later,
you can readily understand precisely what you were trying to express.
I find it very helpful to use short lines,
capturing just a few complete concepts per line.
In particular,
starting a fresh line with each new sentence and major clause,
makes it very easy to play with different ways to structure
the ideas within a paragraph.

(This email message has been written in this way. :-)

As a general rule, keep mark-up and content on separate lines of the source-code.
This makes it much easier to copy information from one place to another
--- e.g. to other LaTeX documents, or to windows used with other applications ---
ensuring that you extract exactly what you want,
unencumbered by irrelevant macro usages, etc.

Thirdly, ...
do *not* use vertical spacing commands such as \smallskip, \medskip,
\bigskip, etc. between ordinary paragraphs and LaTeX environments,
unless you know that you really do need it.
LaTeX already has rules to handle the vertical spacing.
Such commands can just get in the way. You can end up with weird results,
and no way to understand why things came out that way.

Fourthly, ...
also related to readability and reuse,
is to use macros for specialised concepts
--- especially when you need non-trivial macros anyway,
to get the presentation looking right.
e.g.,
look at how the units K (for Kelvin) and atm (for atmospheres)
are handled below.

By respecting the logical structure of your documents, and following
and easier to adapt or reuse in other contexts.

%%%%%%  coding copied and revised from an earlier message  %%%%%

\documentclass{article}
\usepackage{graphicx}
\setlength{\evensidemargin}{-0.5in}
\setlength{\oddsidemargin}{-0.5in}
\setlength{\textheight}{9.5in}
\setlength{\topmargin}{-0.5in}

%% These are special function names and unitsi
%% used in the mathematics to follow.
%%
\newcommand{\vol}{\mathop{\mathrm{vol}}}
\newcommand{\atmos}{\,\mathord{\mathrm{atm}}}
\newcommand{\Kelvin}{\,\mathord{\mathrm{K}}}
\newcommand{\CFL}{\mathord{\mathrm{CFL}}}

%% this \tfrac is defined already in  amsmath.sty
%%
\newcommand{\tfrac}[2]{{\textstyle\frac{#1}{#2}}}

\begin{document}

\begin{center}\small
University of Texas at Arlington\\Aerospace Engineering Program
\end{center}
\begin{center}\Large
AE 5327 Computational Aerodynamics
\end{center}
\begin{center}\Large \bfseries
Two-Dimensional Euler Equations for Flow\\Through a Supersonic Duct
\end{center}

\begin{center}
by\\\MakeUppercase{%
Zachary S. Davis
}
\end{center}

\bigskip

\section{Introduction}
In this assignment we are asked to write a computer program utilizing
the MacCormack scheme to solve the two-dimensional Euler equations for
flow through a supersonic duct.  The problem defines the cross-sectional
area distribution as:

%%  using \pi  instead of  3.14159  ?
$$A(x) = \frac{H_0}{L} \times (2 - \sin \pi x) \quad \mbox{for} \quad 0<x<1\,.$$

Both subsonic and supersonic inlet conditions were investigated,
and for both studies several mesh resolutions $N_x \times N_y$ were utilized,
where $N_x$ and $N_y$ are the number of intervals
in the $X$ and $Y$ directions, respectively.
The computations were initialized using the solution to
Additionally, the vertical velocity could either be initialized
by taking into account the $y$-variation,
or by setting it to zero.
Choosing either method to initialize the vertical velocity
was a non-issue for the computations.
To compare the two-dimensional converged solution to the quasi-1D solution,
an average of the desired result was taken as follows:

%%%
%%% \vol was defined in the preamble above
%%%
$$\bar{U}^y_{i} = \frac {\sum \limits^{N_y+1}_{j=1} u(i,j) \vol(i,j)} {\sum \limits^{N_y+1}_{j=1} \vol(i,j)}\,.$$

\noindent
In order to investigate the convergence of the solution, the quantity
$$\frac{dU}{dt} = \tfrac{1}{2} \bigl( R^n + R^{n+\frac{1}{2}} \bigr)\,,$$
where $R$ represents the balance of fluxes (RHS).

%%%
%%% \CFL, \atmos, \Kelvin  are defined in the preamble
%%%
section{Subsonic Case}
For the subsonic case,
the upstream conditions $p = 1.0\atmos$, $T = 288\Kelvin$, and $M = 0.1$
and the downstream condition $p = 1.0\atmos$, were chosen.
%%
%%  inline vertical-style fractions in text look bad, except for simple
%%  numerical ones; e.g. 1/2, 1/3, 3/4  others should use a slash
%%  If that doesn't do justice to the expression, then display it.
%%
The duct aspect ratio ${H_0}/{L}$ was taken to be 0.10,
and a mesh consisting of $N_x = 50$, $N_y = 16$, and $\CFL = 0.9$
were also used for the investigation of this case.
The following is the convergence plot generated from computation:

\begin{figure}[ht]
\includegraphics{pict1.eps}
\caption{This is my figure.}
\label{fig-pict1}
\end{figure}

\end{document}

%%%%%%  end of coding revised from an earlier message  %%%%%

> >
> > It works fine here.
> >
> > -- Gary
> >
> >
> > -----------------------------------------------------------------
> > To UNSUBSCRIBE, send email to <info at email.esm.psu.edu> with
> > "unsubscribe macosx-tex" (no quotes) in the body.
> > For additional HELP, send email to <info at email.esm.psu.edu> with
> > "help" (no quotes) in the body.
> > -----------------------------------------------------------------
> >
> >
> ========================================================
> Zachary S. Davis
> Department of Aerospace Engineering
> University of Texas at Arlington
> P.O. Box 19032
> Arlington, TX 76019
>
> Home:    (817) 272-6418            zsd3711 at gamma2.uta.edu
> Office:    (817) 272-5269
>
>           _Genius, that power that dazzles mortal eyes,
> 	  is oft but perseverance in disguise."
>
> 			--Henry Willard Austin
> ========================================================
>
>
> -----------------------------------------------------------------
> To UNSUBSCRIBE, send email to <info at email.esm.psu.edu> with
> "unsubscribe macosx-tex" (no quotes) in the body.
> For additional HELP, send email to <info at email.esm.psu.edu> with
> "help" (no quotes) in the body.
> -----------------------------------------------------------------

-----------------------------------------------------------------
To UNSUBSCRIBE, send email to <info at email.esm.psu.edu> with
"unsubscribe macosx-tex" (no quotes) in the body.
For additional HELP, send email to <info at email.esm.psu.edu> with
"help" (no quotes) in the body.
-----------------------------------------------------------------