\documentclass{article} \usepackage{graphicx} \usepackage{subfigure} \usepackage{url} \usepackage{float} \usepackage{multirow} \usepackage{array} \usepackage{hyperref} % number the paragraph and subparagraph \setcounter{secnumdepth}{5} \setcounter{tocdepth}{5} % you can put a figure caption inside a table environment % by command \figcaption. % you can put a table caption inside a figure environment % by command \tabcaption. \makeatletter \newcommand\figcaption{\def\@captype{figure}\caption} \newcommand\tabcaption{\def\@captype{table}\caption} \makeatother \setlength{\topmargin}{-0.75in} \setlength{\textheight}{9in} \setlength{\textwidth}{6.5in} \setlength{\oddsidemargin}{0in} \setlength{\evensidemargin}{0in} \begin{document} \title{An Example of \LaTeX\ Documentation} \author{Yanping Zhao \thanks{This presentation is sponsored by Prof. Rick Bunt} \\Department of Computer Science \\ University of Saskatchewan} \maketitle \begin{abstract} This short article contains some commonly used commands of \LaTeX. This is produced when Mr.\ Wenguang Wang and Mrs.\ Yanping Zhao learned \LaTeX. Commands presented in this article include fonts, tabular, tabbing, figure and table, math mode, and bibliography. \end{abstract} \section{Introduction} Most of the materials are adopted from \cite{introlatex}. Some pictures are from the 890 paper of Wenguang Wang and Yanping Zhao. \LaTeX\ is an excellent typesetting system. Donald E.\ Knuth developed the TeX system \cite{tex} which is the foundation of \LaTeX. Thanks D. E. Knuth. He is a retired professor of Stanford University. He retired because he wants to finish his book ``The arts of computer programming''. \LaTeX\ was developed by Leslie Lamport. \section{Paragraph and Fonts} You just type what you want in the text editor. An empty line creates a new paragraph. The article is seperated by sections, subsections, and subsubsections. For further levels, you can use paragraph and subparagraph. Here are the list of these levels. If you want to number them, the following commands should be set in the preamble. \begin{verbatim} \setcounter{secnumdepth}{5} \setcounter{tocdepth}{5} \end{verbatim} \subsection{test subsection} \subsubsection{test subsubsection} \paragraph{test paragraph} \subparagraph{test subparagraph} \subsection{test subsection again} Different fonts can be used. Two common fonts are {\bf bold} and {\it italic}. Other fonts can be used like the following example. \begin{tabular}{lcl} \verb|\texttt{This is typewrite}| & $\Longrightarrow$ &\textsf{This is typewriter}\\ \verb|\textrm{This is roman}| & $\Longrightarrow$ &\textrm{This is roman}\\ \verb|\textsc{This is small caps}| & $\Longrightarrow$ &\textsc{This is small caps}\\ \verb|\textsf{This is sans serif}| & $\Longrightarrow$ &\textsf{This is sans serif} \end{tabular} \section{Lists} There are {\bf three} intrinsic list environments, distinguished by what appears at the beginning of each item: description (i.e.\ {\em Description List Environment}), bullet (i.e.\ {\em Itemize List Environment}), or number (i.e.\ {\em Enumerate List Environment}) \subsection{Description List Environment} \begin{description} \item [Document Preparation.] Knowing how to setup ... \item [Making Tables.] \LaTeX~ provides a means ... \item [Bibliography.] Knowing how to create a bibliography ... \item [Mathematics.] This is the power of \LaTeX~ and one ... \item [Graphics.] This has progressed a great deal in the ... \item [Other.] There are a great many things to learn ... \end{description} \subsection{Itemize List Environment} \begin{itemize} \item This is item 1 \item This is item 2. A blank line within an item does create a new paragraph, using the indentation of the itemize environment. \begin{itemize} \item A nested itemized list changes the bullet and indents another level. \end{itemize} \end{itemize} \subsection{Enumerate List Environment} \begin{enumerate} \item This is item 1 \item This is item 2 \begin{enumerate} \item This is item 2.1 \item This is item 2.2 \begin{enumerate} \item One again! \item Two again! \end{enumerate} \end{enumerate} \end{enumerate} \subsection{Lists with small seperation} \begin{enumerate} \item This list has a normal separation \item The second line \item The third line \item The last line \end{enumerate} The variable \verb|\itemsep| control the space between items. You can set it to 0 to reduce the space between items. This is the sample. \begin{enumerate} \setlength{\itemsep}{-\parsep} \item This list has a small seperation \item The second line \item The third line \item The last line \end{enumerate} \section{Tables} A table is made with the {\bf tabular} environment. Table \ref{tab:comtable} is an example of complex table. \begin{table}[hbt] \begin{center} \begin{tabular}{|r|c|c|c|c|} \hline & \multicolumn{2}{|c|}{First Half} & \multicolumn{2}{|c|}{Second Half}\\\hline & 1st Qtr&2nd Qtr&3rd Qtr&4th Qtr \\ \hline East& 20.4& 27.4& 90& 20.4 \\ \cline{1-1} West& 30.6& 38.6& 34.6& 31.6 \\ \cline{1-1} North& 45.9& 46.9& 45& 43.9\\ \hline \end{tabular} \caption{An Example of Complex Table}\label{tab:comtable} \end{center} \end{table} Table~\ref{tab:nesttab} is an example of nested table. \begin{table}[hbt] \begin{center} \caption{An Example of Nested Table}\label{tab:nesttab} \begin{tabular}{cp{1in}l} \\ \underline{Table 1} && Table 2 \\ \cline{3-3} \\ \begin{tabular}{|lc|} \hline Object & Symbols used \\ \hline variable & lowercase \textrm{Roman} \\ parameter& \textit{Greek} \\ constant & \textsc{Upper Case} \textrm{Roman} \\ \hline \end{tabular} && % Begin Table 2 \begin{tabular}{|rcc|} \hline * & 1 & 2 \\ \cline{2-2} & 3 & 4 \\ \cline{1-1}\cline{3-3} \hline \end{tabular} \end{tabular} \end{center} \end{table} Table~\ref{tab:factor} is an example using the multirow and array packages for complex tables. The m option from the array package can center the text vertically. \begin{table}[htb] \caption{Experiment Factors} \label{tab:factor} \begin{center} { %\footnotesize \begin{tabular}[c]{|c|m{0.8in}|c|c|c|c|c|}\hline \multicolumn{2}{|c|}{Network Topology} & \# of nodes & \multicolumn{3}{|c|}{\# of clients} & Server \\\hline GT-ITM & Waxman Transit-Stub & 600 & \multirow{2}{2em}{2\%}& \multirow{2}{2em}{10\%}& \multirow{2}{2em}{50\%}& \multirow{2}{1.2in}{Max. Connectivity}\\\cline{1-3} \multicolumn{2}{|c|}{Inet-2.1} & 6000 & & & &\\\hline %\multirow{2}{1in}{abc} & def & ghi \\\cline{2-3} % & jkl & mno \\\hline \end{tabular} } \end{center} \end{table} \section{Tabbing} The {\bf tabbing} environment provides an alternative to the {\bf tabular} environment by letting you set your own column tabs. Figure \ref{fig:tabbing} is an example of the use of {\bf tabbing}. You don't have to put tabbing inside a figure. Here is another short example: \begin{tabbing} grapefruit \= variables \= derivative\kill apples\>integral\>derivative\\ grapefruit\>sum\>difference\\ \>variables\>constants \end{tabbing} \begin{figure}[hbt] \begin{center} \framebox[.7\textwidth][c]{ \begin{minipage}{.7\textwidth} \begin{tabbing} 123456\=12\=12\=12\=12\=12\=12\=12\=12\=12 \kill \>PROCEDURE Minimum\_smoothing($d(t)$, $RATE$)\\ 1.\>\>$excess = 0$\\ 2.\>\>FOR $i = n$ TO $0$ \\ 3.\>\>\>IF $d(i) > RATE$ THEN \\ 4.\>\>\>\>$excess = excess + (d(i) - RATE)$\\ 5.\>\>\>\>$a(i) = RATE$\\ 6.\>\>\>ELSE\\ 7.\>\>\>\>IF $excess > (RATE - d(i))$ THEN\\ 8.\>\>\>\>\>$a(i) = RATE$\\ 9.\>\>\>\>\>$excess = excess - (RATE - d(i))$\\ 10.\>\>\>\>ELSE\\ 11.\>\>\>\>\>$a(i) = d(i) + excess$\\ 12.\>\>\>\>\>$excess = 0$\\ 13.\>\>\>\>ENDIF\\ 14.\>\>\>ENDIF\\ 15.\>\>ENDFOR\\ \>ENDPROCEDURE \end{tabbing} \end{minipage} } \end{center} \caption{An Example of the Use of {\bf Tabbing} Environment}\label{fig:tabbing} \end{figure} \section{Math} A simple math equation can be put between two \$ signs: $E=mc^2$, $\frac{x^{a+b}_{c-d}+\int_a^b f(x)\,dx}{y_i+\sum_{i=1}^{n}z_i}$. Figure \ref{fig:mathequ} gives an example of complex mathematical equation: Figure \ref{fig:eqnarray} is an example of the use of {\bf eqnarray} Environment where you could enumerate your expression. \begin{figure}[hbt] \begin{center} \[ \sqrt{\frac{\displaystyle \prod_{n=1}^N \left( \sum_{i\in I_n} x_x^n \right) } {\sqrt[3]{\displaystyle \sum_{i\in I_\infty} x_i}} } \] \caption{An Example of Mathematical Equation} \label{fig:mathequ} \end{center} \end{figure} \begin{figure}[hbt] \begin{center} \begin{eqnarray} x &\mbox{is equal to}& y \\ y & \preceq & \frac{a+b+c+d}{\Psi} + \frac{e+f+g+h}{\Phi} + \nonumber \\ & & I+K+J+L \end{eqnarray} \caption{An Example of the Use of {\bf Eqnarray} Environment} \label{fig:eqnarray} \end{center} \end{figure} \section{Float (table and figure)} \subsection{Importing an EPS picture into \LaTeX} Two environments {\bf table} and {\bf figure} can be used for a float object. You can put any thing less than a page inside a table or a figure. Figure~\ref{fig:eqnarray} is a sample. The way to import a picture into \LaTeX is to convert it to {\bf encapsulated postscript} (i.e.\ eps). Other formats like gif, jpeg are also supported. But eps is the recommended format. On UNIX, {\bf xfig} is an excellent system to draw figures, and export options include the eps file format. A basic plotting system , for both UNIX and WINDOWS, is {\bf gnuplot}, which could produces eps files as well. Another way to obtain an eps file is with conversion. {\bf xv} on UNIX can do this for a large variety of graphic file formats, including bitmap (xbm), gif and jpeg files. {\bf gv} (on UNIX) or {\bf gsview} (on WINDOWS) can do the same job, especially converting a ps file to eps file. Once the file is in eps format, you can import it using the commands provided by the {\bf graphicx} package \cite{graphics}. If two figures are very small, you can put them in one line with two captions and two labels by minipage, see Figure~\ref{fig:sim_db_tpm} and Figure~\ref{fig:sim_dirty_dist}. You can put more than two figures together in this way. \begin{figure}[H] \begin{minipage}[c]{0.47\textwidth} \includegraphics[width=\textwidth,height=!]{sim_db2_tpm} %scar: e:\wwg\doc4research\4research.plt \caption{Simulation vs.\ Measurement} \label{fig:sim_db_tpm} \end{minipage}% \begin{minipage}[c]{.47\textwidth} \includegraphics[width=\textwidth,height=!]{sim_tpm} %scar: e:\wwg\doc4research\4research.plt \caption{Effect of different parameters} \label{fig:sim_dirty_dist} \end{minipage} \end{figure} You can also use the {\it subfigure} package, and create many subfigures like Figure~\ref{fig:ioactivity}. Each subfigure has a caption and a label. MikTeX does not include the package subfigure, you need download it from CTAN and install it. \begin{figure}[H] \centering \subfigure[MaxAio=40]{ \includegraphics[width=0.47\textwidth, height=!]{ioactivity40} %scar: e:\wwg\sim\graph\graph.plt \label{fig:aio40} } \subfigure[MaxAio=97]{ \includegraphics[width=0.47\textwidth, height=!]{ioactivity97} % scar: e:\wwg\sim\bigtrace\big.plt \label{fig:aio97} } \caption{I/O activities of the buffer pool} \label{fig:ioactivity} \end{figure} If you want to put a table and a figure together, you can define two commands in the preamble: \begin{verbatim} \makeatletter \newcommand\figcaption{\def\@captype{figure}\caption} \newcommand\tabcaption{\def\@captype{table}\caption} \makeatother \end{verbatim} \begin{figure}[H] \begin{minipage}[c]{.5\textwidth} \begin{center} %\setlength{\tabcolsep}{0pt} \begin{tabular}{|c|c|c|} \hline &\multicolumn{2}{|c|}{Dirty page percentage}\\\cline{2-3} Threshold&Simulation&Measurement\\\hline 1 & 85.1\% & 89.5\% \\\hline 30 & 85.2\% & 89.5\% \\\hline 60 & 84.8\% & 89.2\% \\\hline 80 & 84.8\% & 89.0\% \\\hline 99 & 84.8\% & 89.6\% \\\hline \end{tabular} \tabcaption{Dirty page percentage under various thresholds} \label{tbl:sim_db2_thres} \end{center} \end{minipage}% \begin{minipage}[c]{.5\textwidth} \begin{center} \includegraphics[width=\textwidth,height=!]{pagedistribution} % scar: e:\wwg\doc4research\4research.plt \caption{Pages in the buffer pool}\label{fig:page_dist} \end{center} \end{minipage} \end{figure} \subsection{Importing a MS Word Picture into \LaTeX} For people who are used to drawing pictures in MS Word, there is a way to import them into \LaTeX: \begin{enumerate} \setlength{\itemsep}{0in} \item Install {\bf Adobe$^@$ Postscript Printer Driver} into your WINDOWS system (This can be downloaded from \url{http://www.adobe.com/support/downloads/main.html}) \item Install and config the printer driver. Configuration for NT: \begin{enumerate} \setlength{\itemsep}{0in} \item Click right button on the printer icon, select ``Document Defaults...'', and open a window. \item From the ``PostScript'' tab, select output to ``Encapsulated Postscript'' \end{enumerate} \item Configuration for Windows 98 \begin{enumerate} \item Click right button on the printer icon, select ``Properties...'', and open a window. \item From the ``PostScript'' tab, select output to ``Encapsulated Postscript'' \item From the ``Font'' tab, select ``Always use TrueType fonts''. \end{enumerate} \item Draw a picture in MS Word \item Select ``Print -- Print to file'', and name it as a ps file (not eps!) \item Open this file in {\bf gsview}, select ``File -- PS to EPS'' to convert this file into a eps file \item import the eps file into your \LaTeX document \item On Windows NT, you can draw picture with PowerPoint or Word. On Windows 98, you can only use Word. \end{enumerate} Figure \ref{fig:word} is an example of imported MS Word Picture. \begin{figure}[H] \begin{center} \includegraphics[width = .5\textwidth, height = !]{buffer} \caption{An Example of Imported MS Word Picture}\label{fig:word} \end{center} \end{figure} \section{Bibliography} You can reference a bibliography item by \texttt{$\backslash$cite} command. A seperate bibliography database file should be maintained. \bibliography{example} \bibliographystyle{plain} \end{document}