\documentclass[12pt]{article}

% The following is a tutorial of learning to program in LaTeX.  
% Included in this tutorial are some examples of defining your own LaTeX 
% commands.  Note that anything after a percent sign (%) is considered a 
% comment in LaTeX.

\newcommand{\sigline}{\rule[-0.8mm]{60mm}{0.2mm}}
\newcommand{\scoreline}{\rule[-0.8mm]{15mm}{0.2mm}}
\newcommand{\mybox}{\fbox{\parbox[c][3mm]{4mm}{\ \ }}\ \ }
\newcommand{\ret}{$<$\tectsf{return}$>$}
\newcommand{\ctrl}{$<$\textsf{Ctrl}$>$}
\newcommand{\ie}{\textit{i.e.},\ }
\newcommand{\eg}{\textit{e.g.},\ }
\newcommand{\ea}{\textit{et~al.}\ }
\newcommand{\teff}{T_{\mbox{{\small eff}}}}
\newcommand{\lappxe}{\ ^{<}_{\sim}\ }
\newcommand{\gappxe}{\ ^{>}_{\sim}\ }
\newcommand{\apj}{ApJ}
\newcommand{\apjs}{ApJS}
\newcommand{\aj}{AJ}
\newcommand{\ana}{A\&A}

% The following sets the margin limits and other page characteristics for 
% the printed PDF document.

\setlength{\topmargin}{-0.5in}
\setlength{\oddsidemargin}{0.0in}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{9.0in}
\setlength{\parskip}{20pt}  % How much space to include between paragraphs.
\setlength{\parindent}{0pt}  % Do not indent the first line of paragraphs.
\pagestyle{plain}  % Use this for starters.  It puts the page number at the bottom of a page.
%
\begin{document}

\begin{center}
\large
\textbf{PHYS-4007/5007: Computational Physics}\\*[4mm]
\textbf{\LaTeX\ Tutorial}\\*[2mm]
\textbf{Learning the \LaTeX\ Mark-up Language} 
\end{center}

\thispagestyle{empty}  % Do not include a page number on this first page.

\vspace*{-6mm}  % How to shrink vertical space.

Log into your \textsf{Linux} account, open a terminal window, and change 
directory to your `tex' subdirectory.  Now open the web browser and go to 
the \textsf{Samples of \LaTeX\ Files Web Page} on the course web page: \\

\vspace{-8mm}
\textsf{http://faculty.etsu.edu/lutter/courses/phys4007/texfiles/texfiles.htm}

\vspace{-4mm}

and download the `latextutorial.tex' file to this directory.  Following this, 
open this file in the \textsf{emacs} editor with \\*[2mm]
\hspace*{6mm} \textsf{$>$ emacs latextutorial.tex \&} \\*[2mm]
where the `\textsf{$>$}' symbol represents the \textsf{Linux} prompt (remember, 
don't type this symbol, it's only included above to indicate that this is a 
\textsf{Linux} command).  Note that the ampersand symbol (\&) puts the process in 
``background'' mode so that you will get back the \textsf{Linux} command prompt 
to carry out additional commands.

Now go back to the terminal window and issue the command: \\*[2mm]
\hspace*{6mm} \textsf{$>$ latex latextutorial} \\*[2mm]
-- do not include the filename suffix ``\textsf{.tex}'' in this command.  
You will see a variety of output printed to the screen indicating any issues 
that the \LaTeX\ compiler may have found.  Following this, issue the 
\textsf{Linux} command: \\*[2mm]
\hspace*{6mm} \textsf{$>$ xdvi latextutorial \&} \\*[2mm]
and again, don't include the ``\textsf{.dvi}'' filename suffix.  Click on the 
\textsf{xdvi} GUI and examine the document that was created.


\vspace*{-5mm}

% The section command puts the enclosed text into a section label environment.  
% Since it inserts a large amount of vertical space before and after the label, 
% I have forced LaTeX to shrink this space.

\section{Tables and Lists}

\vspace*{-5mm}

This shows how one uses the \textsf{$\backslash$section} command to make new 
sections.  The following is an example of a scientific proposal cover page 
using the \textsf{tabbing} environment in \LaTeX.  Note the use of the 
\textsf{$\backslash$newpage} command to force this table to appear on the 
following page.

\newpage

\begin{tabbing}
XXXXXXXXXXXXXXXXXXXXXXXXXXXX \=    \kill
                             \>        \\
                             \>        \\
PRINCIPAL INVESTIGATOR:      \>  \sigline \\
                             \>  Type your name here \\
                             \>                                 \\
NAME AND ADDRESS OF THE      \>  East Tennessee State University \\
ORGANIZATION:                \>  Department of Physics and Astronomy \\	
                             \>  Johnson City, TN 37614 \\
                             \>                                 \\
SUBMISSION DATE:             \>  19 September 2017 \\
                             \>                                 \\
CLASS STATUS AND MAJOR:      \>  Senior in Physics  \\
                             \>                                 \\
MACHINE ARCHITECTURE:        \>  Intel Core 2, 64-bit CPU  \\
                             \>  \\
OPERATING SYSTEM:            \>  Ubuntu Linux \\
                             \>  \\
PROGRAMMING LANGUAGE:        \>  Fortran 77 and Python \\
                             \>    \\
                             \>    \\
                             \>    \\
GRANT OFFICIAL SIGNATURE:    \>  \sigline \\
                             \>  Dr.\ Donald G. Luttermoser \\
                             \>  East Tennessee State University \\
                             \>    
\end{tabbing}

The \textsf{tabbing} environment shouldn't be confused with the \textsf{tabular} 
environment.  The following is an example of using the \textsf{tabular} 
environment.

\begin{tabular}{rccl}
\hline
\textbf{Decimal} & \textbf{Binary} &  & \textbf{Name} \\
\textbf{Value\ \ } & \textbf{Value}  & \textbf{Symbol} & \textbf{Description} \\
\hline
  0\hspace*{6mm} & 00000000 & NUL & Null character \\
  1\hspace*{6mm} & 00000001 & SOH & Start of Heading \\
  2\hspace*{6mm} & 00000010 & STX & Start of Text \\
\end{tabular}

The \LaTeX\ tutorial will discuss how to change the appearance of a table using 
this \textsf{tabular} environment a bit later.

One often needs to display lists.  The following shows the use of the 
\textsf{itemize} environment (printed on the next page).

\newpage

\begin{itemize}

\item High-dispersion spectra of the Mg II $h$ and $k$ resonance lines are
a very sensitive diagnostic of temperature reversals in the atmospheres
of stars due to their high opacity in relatively low-temperature regimes
($\sim$5000~\AA ).
   
\item The Fe~II multiplets are a major source of cooling in these types of
stellar atmospheres (Judge \& Neff 1990).
 
\item The line strengths of the C~II] UV0.01 multiplet are sensitive to
the electron density of the emitting region (Stencel \ea 1981; Lennon \ea 
1985).
 
\end{itemize}
  
At this point in this \LaTeX\ tutorial, change this itemized lists from a 
``bulleted'' list to a numeric list.  To do this, change the word 
``\textsf{itemize}'' in the \textsf{$\backslash$begin\{itemize\}} and 
\textsf{$\backslash$end\{itemize\}} commands to ``\textsf{enumerate}'' so 
that these commands read: \textsf{$\backslash$begin\{enumerate\}} and \\
\textsf{$\backslash$end\{enumerate\}}.  Recompile your \LaTeX\ document to 
see how this itemized list changes in appearance.

\vspace*{-5mm}

\section{Equations}

\vspace*{-5mm}

One of the things that makes \LaTeX\ so useful to physicists, astronomers, and 
mathematicians is its ability to create equations and formulae in papers in a 
relatively easy way.  There are a variety of ways to display mathematics in 
papers which we will work on here.  If you need to include an equation in the 
main body of a paragraph, then use the dollar sign as delimiters around the 
equation, $F = m a$.  However, let's say that we want a little more space 
between the `$m$' and the `$a$' in this equation.  We would then insert a small 
space with the $\backslash$, marker, $F = m\, a$.

To make a numbered, center-justified equations, one uses the \textsf{equation} 
environment:

\begin{equation}
F_{\mbox{{\scriptsize tot}}} = \sum_{i=1}^{N} F \left[ t, r(t),
v(t) \right] = m a = m \frac{dv(t)}{dt} =  m  \frac{d^{2}
r(t)}{dt^{2}}\ .
\end{equation}

If instead, we wanted an unnumbered center-justified equation, we would use the 
\textsf{displaymath} environment:

\begin{displaymath}
F_{\mbox{{\scriptsize tot}}} = \sum_{i=1}^{N} F \left[ t, r(t),
v(t) \right] = m a = m \frac{dv(t)}{dt} =  m  \frac{d^{2}
r(t)}{dt^{2}}\ .
\end{displaymath}

If we need to display a set of equations that are numbered, we use the 
\textsf{eqnarray} environment:

\begin{eqnarray}
v & = & \frac{dr(t)}{dt} = \dot{r} \hspace*{10mm} (\mbox{for velocity}) \\ 
a & = & \frac{dv(t)}{dt} = \frac{d^{2}r(t)}{dt^{2}} = \ddot{r} \hspace*{10mm}
         (\mbox{for acceleration}),
\end{eqnarray}

or if we would rather not have numbers associated with these equations, we would 
use the `\textsf{eqnarray$\ast$}' environment:

\begin{eqnarray*}
v & = & \frac{dr(t)}{dt} = \dot{r} \hspace*{10mm} (\mbox{for velocity}) \\ 
a & = & \frac{dv(t)}{dt} = \frac{d^{2}r(t)}{dt^{2}} = \ddot{r} \hspace*{10mm}
         (\mbox{for acceleration}),
\end{eqnarray*}

Please note the use of the ampersand symbol (\&) in the equation array 
environment to separate the left-hand side of the equation (typically with only 
one variable present), the center column containing the equal sign, and the 
right-hand side of the equation.  \LaTeX\ will make sure the center column 
with the equal signs line up in the same vertical column on the page.

\newpage

\section{Including Figures}

\vspace*{-5mm}

Figures can be included in the \LaTeX\ mark-up language as well.  We can either 
have a figure by itself or in a \textsf{figure} environment with a figure number 
and a caption.  \LaTeX\ in Unix is designed to have figure files as encapsulated 
postscript files.  As such, we will focus on using these types of figure files.

First, go to the following page on the course web page,

\textsf{http://faculty.etsu.edu/lutter/courses/phys4007/texfiles/texfiles.htm}

and download the file \textsf{temptex.eps} to the directory that you are currently 
working in.  Note that we need to make some blank space in the document before 
inserting the figure, typically anywhere between 2.5 inches to 3.5 inches.  
Note that if you chose a size bigger than this, \LaTeX\ will put the figure 
on its own page if it is in a \textsf{figure} environment.  Let's first insert 
this figure into this document on its own, we do this by using the 
\textsf{$\backslash$special} command in our \LaTeX\ file as shown below in the 
\LaTeX\ file.

\vspace*{2.8in}
\special{psfile=temptex.eps hoffset=0 voffset=0 hscale=100 vscale=100}

We see that this figure is a little too big and that it is not centered in the 
space that we have allowed for it.  To correct this, let's first scale the 
figure down to 80\% of its current size by setting \textsf{hscale} and 
\textsf{vscale} from 100 to 80.  We see that it is still too big for the area 
we set.  We could increase our vertical space allowed for the figure, or shrink 
the figure down to 70\%.  Go ahead and shrink this figure now in both the 
vertical and horizontal directions.

Now we will reposition this figure so that it is centered in the space that we 
made for it.  First we need to shift it downward --- as such, change 
\textsf{voffset} from 0 to -30 (where these numbers have units of `points,' note 
that there are 72 points per inch on the document).  This picture is now 
vertically centered, now we must center it horizontally.  As can be seen, we 
need to shift this picture a bit to the right --- as such, change \textsf{hoffset} 
from 0 to 30.  At this point, the figure is well placed for the space we have 
allowed for it.

Next, we will place this figure in a \textsf{figure} environment.  At first, we 
will use the same settings as we did for the figure on the previous page.  The 
first thing we note is that \LaTeX\ has placed this figure at the top of this page.  
Note that we prefer to have this figure show up after this paragraph.  We can 
force \LaTeX\ to place it at this location by issuing a `[h]' keyword after the 
$\backslash$begin$\{$figure$\}$ command.

\begin{figure}  % [h]
\vspace*{2.8in}
\caption{A sample encapsulated postscript figure.}
\special{psfile=temptex.eps hoffset=30 voffset=-30 hscale=70 vscale=70}
\end{figure}

At this point we see that the $x$-axis label falls below the figure caption.  
Since we have enough room to move the figure up using the voffset keyword, go 
ahead and change -30 to 0 and recompile your \LaTeX\ file.  We now see that 
the $x$-axis label is above the figure caption, however we don't have quite 
enough space between the last paragraph and the top of the figure.  As such, 
we will increase the size of the vertical space from 2.8 inches to 3.0 inches 
in the \textsf{figure} environment.  At this point, I think we are satisfied 
with the placement of this figure in the floating \textsf{figure} environment.

\newpage

\section{The Table Environment}

\vspace*{-5mm}

We will next work with the \textsf{table} environment.  Let's use the table we 
printed on page 2 and insert it in the \textsf{table} environment as shown below.

\begin{tabular}{rccl}
\hline
\textbf{Decimal} & \textbf{Binary} &  & \textbf{Name} \\
\textbf{Value\ \ } & \textbf{Value}  & \textbf{Symbol} & \textbf{Description} \\
\hline
  0\hspace*{6mm} & 00000000 & NUL & Null character \\
  1\hspace*{6mm} & 00000001 & SOH & Start of Heading \\
  2\hspace*{6mm} & 00000010 & STX & Start of Text \\
\end{tabular}

Now before the \textsf{$\backslash$begin\{tabular\}\{rccl\}} line, insert the 
line \textsf{$\backslash$begin\{table\}}, and after the 
\textsf{$\backslash$end\{tabular\}}, insert the line 
\textsf{$\backslash$end\{table\}} and recompile your code.

We now see that this table has move to the top of this page.  Since we don't 
want the table to appear before the position of where it is at in the \LaTeX\ 
file, insert `[h]' keyword after the \textsf{$\backslash$begin\{table\}} command.

At this point, we want to center this table on the page.  To center this table, 
insert the line \textsf{$\backslash$begin\{center\}} after the 
\textsf{$\backslash$begin\{table\}[h]} line and enter 
\textsf{$\backslash$end\{center\}} after the \textsf{$\backslash$end\{tabular\}} 
line (and before the \textsf{$\backslash$end\{table\}} line) and recompile the 
code using the `\textsf{latex latextutorial}' command at the Linux prompt.  Click 
on the \textsf{xdvi} GUI to see how this has changed your document.

We next want to add some vertical lines in this table to separate each column with 
a line and completely enclose the table in a box.  To do this, input the `$|$' 
character in the \textsf{$\backslash$begin\{tabular\}} line so that it reads:\\

\vspace*{-5mm}

\textsf{$\backslash$begin\{tabular\}\{$|$r$|$c$|$c$|$l$|$\}}

then insert an \textsf{$\backslash$hline} command just before the 
\textsf{$\backslash$end\{tabular\}} line.  Recompile and look at the output in the 
\textsf{xdvi} GUI.

Finally, let's include a caption for this table.  In scientific journals, table 
captions typically come at the top of a table.  After the 
\textsf{$\backslash$begin\{center\}} line, insert the following line:

\vspace*{-3mm}

\textsf{$\backslash$caption\{Portion of the ASCII Set of Symbols\}}

\vspace*{-3mm}

Recompile and examine the resulting \textsf{dvi} file.  When all is said and done, 
the data table should appear as follows:

\begin{table}[h]  %
\begin{center}  %
\caption{Portion of the ASCII Set of Symbols}
\begin{tabular}{|r|c|c|l|}
\hline
\textbf{Decimal} & \textbf{Binary} &  & \textbf{Name} \\
\textbf{Value\ \ } & \textbf{Value}  & \textbf{Symbol} & \textbf{Description} \\
\hline
  0\hspace*{6mm} & 00000000 & NUL & Null character \\
  1\hspace*{6mm} & 00000001 & SOH & Start of Heading \\
  2\hspace*{6mm} & 00000010 & STX & Start of Text \\
\hline
\end{tabular}
\end{center}  %
\end{table}  %



\vspace*{-5mm}

\section{Special Fonts}

\vspace*{-5mm}

At this point, go ahead and try different things with this \LaTeX\ program, 
for instance, making some of the text boldface with the 
$\backslash$textbf$\{$\ $\}$ environment or italics with the $\backslash$textit$\{$\ $\}$ 
environment.  Note that there is also a sans-serif font.  The command for this is 
$\backslash$textsf$\{$\ $\}$.  Go through this \LaTeX\ document and change some of the 
phrases and/or sentences to each of these 3 fonts.

\end{document}
