sttp/latex/examples/final.tex
changeset 0 27e1f5bd2774
equal deleted inserted replaced
-1:000000000000 0:27e1f5bd2774
       
     1 %hello.tex - First LaTeX document
       
     2 \documentclass[11pt,a4paper,twoside]{article}
       
     3 
       
     4 \usepackage{graphicx}
       
     5 \usepackage{listings}
       
     6 \usepackage{amsmath}
       
     7 
       
     8 \lstset{language=Python, showstringspaces=false}
       
     9 \bibliographystyle{plain}
       
    10 
       
    11 \title{LaTeX - A Two Hour Introduction}
       
    12 \author{The FOSSEE Team}
       
    13 \date{August 2009}
       
    14 
       
    15 
       
    16 \begin{document}
       
    17 \maketitle
       
    18 \tableofcontents
       
    19 \listoftables
       
    20 \listoffigures
       
    21 \begin{abstract}
       
    22 This is a sample document to be used in the STTP course for a quick introduction to \LaTeX
       
    23 \end{abstract}
       
    24 \section{Introduction}
       
    25 LaTeX is a typesetting program used to produce excellently typeset documents. It is extensively used for producing high quality scientific and mathematical documents. It may also be used for producing other kinds of documents, ranging from simple one page articles or letters 
       
    26 \section{Structural Elements}
       
    27 Let us now look at giving a better structure to our document. 
       
    28 \subsection{documentclass}
       
    29 The \verb+documentclass+ variable tells \LaTeX, the type of document we wish to prepare. 
       
    30 
       
    31 \subsection{Sections, Chapters and Parts}
       
    32 We shall first look at how to divide the document into Sections, Chapters and Parts. 
       
    33 
       
    34 \subsubsection{Appendices}
       
    35 I can't tell you how to add an appendix, in the main document. Refer Appendix \ref{append} to see how to do it. 
       
    36 
       
    37 \section{Text Typesetting}
       
    38 \begin{itemize}
       
    39 \item Now we move onto some elementary \emph{Text Typesetting}.
       
    40 
       
    41 \item How do we get \emph{emphasized or italic text}?
       
    42 
       
    43 \item \emph{Did you wonder what happens when we try \emph{emphasizing text} within \emph{emphasized text}}?
       
    44 
       
    45 \item ``Beautiful is better than ugly.''
       
    46 
       
    47 \item `In the face of ambiguity, refuse the temptation to guess.'
       
    48 
       
    49 \item LaTeX has 4 different types of dashes. The names of these dashes are: `-' hyphen, `--' en-dash, `---' em-dash and `$-$' minus sign. \footnote{We shall look at how to do math in a later section}
       
    50 
       
    51 \item \LaTeX has \verb+enumerate+, \verb+itemize+ and \verb+description+ commands to generate lists. 
       
    52 
       
    53 \end{itemize}
       
    54 
       
    55 \begin{flushleft}This is left flushed text. \LaTeX normally produces text with no white space at the end of the line. But, this text isn't so, if you can see.\end{flushleft}
       
    56 \begin{flushright}Similarly, Right-aligned Text here\end{flushright}
       
    57 \begin{center} and centered text here.\end{center}
       
    58 
       
    59 \begin{description}
       
    60   \item[Description] This list is a description list. 
       
    61   \item[Enumerate] Numbered lists are often useful.
       
    62     \begin{enumerate}
       
    63     \item First
       
    64     \item Second
       
    65     \item Third
       
    66     \item \ldots
       
    67     \end{enumerate}
       
    68   \item[Itemize] The list above this description list is an itemize list.
       
    69 \end{description}
       
    70 
       
    71 \subsection{Quotes \& Verbatim Text}
       
    72 Since the \emph{Zen of Python} instructs that, 
       
    73 \begin{quote}
       
    74 Readability counts.
       
    75 \end{quote}
       
    76 we use the \verb+quote+ environment to include quotes. 
       
    77 
       
    78 \begin{verbatim}
       
    79 def signum( r ):
       
    80     """returns 0 if r is zero
       
    81     -1 if r is negative
       
    82     +1 if r is positive"""
       
    83     if r < 0:
       
    84         return -1
       
    85     elif r > 0:
       
    86         return 1
       
    87     else:
       
    88         return 0
       
    89 \end{verbatim}
       
    90 
       
    91 \section{Tables \& Figures}
       
    92 
       
    93 \begin{table}[h]
       
    94 \caption{A simple table, on making tables}
       
    95 \centering
       
    96 \begin{tabular}{|c|c|}
       
    97   \hline
       
    98   \verb+l+ & left justified column content\\ 
       
    99   \hline
       
   100   \verb+r+ & right justified column content\\ 
       
   101   \hline
       
   102   \verb+c+ & centered column content\\ 
       
   103   \hline
       
   104   \verb+*{n}{col}+ & produces \verb+n+ columns with the\\
       
   105                    & \verb+col+ type of formatting\\
       
   106   \cline{2-2}
       
   107                    &\verb+*{3}{c}+ is the same as \verb+{c c c}+ \\
       
   108   \hline
       
   109   \verb+|+ & produces a vertical line\\ 
       
   110   \hline
       
   111 \end{tabular}
       
   112 \end{table}
       
   113 
       
   114 \begin{figure}
       
   115 \centering
       
   116 \caption[CTAN Lion]{CTAN lion drawing by Duane Bibby; thanks to www.ctan.org}
       
   117 \label{fig:lion}
       
   118 \includegraphics[scale=0.8, angle=30]{lion_orig.png}
       
   119 \end{figure}
       
   120 
       
   121 List of Tables and List of figures can be autogenerated suigng the \verb+\listoftables+ and \verb+\listoffigures+ commands. Let's insert them after the table of contents. 
       
   122 
       
   123 Cross referencing is one of the best features of \LaTeX. The CTAN lion has the figure number \ref{fig:lion} and is on page number \pageref{fig:lion}
       
   124 
       
   125 It was drawn by Duane Bibby, a well-known commercial artist. He used this lion in the illustrations for Donald Knuth's original TeXbook\cite{Knuth84}, for Leslie Lamport's LaTeX book\cite{Lamport94}, and for other books having to do with TeX, so his work is familiar to everyone in the community. 
       
   126 
       
   127 %% \begin{thebibliography}{99}
       
   128 %%   \bibitem{Knuth84} Donald E. Knuth (1984). \emph{The TeXbook} (Computers and Typesetting, Volume A). Reading, Massachusetts: Addison-Wesley. ISBN 0-201-13448-9.
       
   129   
       
   130 %%   \bibitem{Lamport94} Lamport, Leslie (1994). \emph{LaTeX: A document preparation system: User's guide and reference}.
       
   131 %%      illustrations by Duane Bibby (2nd ed.). Reading, Mass: Addison-Wesley Professional. 
       
   132 %% \end{thebibliography}
       
   133 
       
   134 \section{Typesetting Math}
       
   135 The equation $F=m \cdot a$ is an equation, that has been set inline. 
       
   136 Equation \eqref{force} is the same equation typeset in the display style. Note, that it is also numbered. 
       
   137 \begin{equation}
       
   138 \label{force}
       
   139 F=m\cdot a
       
   140 %%\tag{Fore-acceleration}
       
   141 \end{equation}
       
   142 More equations --- vertically aligned. 
       
   143 
       
   144 \begin{align}
       
   145 \alpha^2 + \beta^2 &= \gamma^2 \\
       
   146 \sum_{i=1}^ni &= \frac{n(n+1)}{2}\\
       
   147 \sqrt{-1} &= \pm1 \nonumber \\
       
   148 y &= \frac{r_1^2-r_3^2-x^2+(x-i)^2+j^2}{2j} \nonumber \\
       
   149   &= \frac{r_1^2-r_3^2+i^2+j^2}{2j}-\frac{i}{j}x \\
       
   150 \end{align}
       
   151 
       
   152 \begin{equation*}
       
   153 s(t) = \left\{
       
   154  \begin{array}{rl}
       
   155    0 & \text{if } t \le 0\\
       
   156    1 & \text{if } t > 0
       
   157  \end{array} \right.
       
   158 \end{equation*}
       
   159 
       
   160 \begin{equation*}
       
   161 \mathbf{X} = \left(
       
   162  \begin{array}{ccc}
       
   163  a_1 & a_2 & \ldots \\
       
   164  b_1 & b_2 & \ldots \\
       
   165  \vdots & \vdots & \ddots
       
   166  \end{array} \right)
       
   167 \end{equation*}
       
   168 
       
   169 \begin{equation}
       
   170   \begin{matrix}
       
   171   1 & 2 \\
       
   172   3 & 4
       
   173   \end{matrix} \qquad \& \qquad 
       
   174   \begin{bmatrix}
       
   175   1 & 2 & 3 \\
       
   176   4 & 5 & 6 \\
       
   177   7 & 8 & 9
       
   178   \end{bmatrix}
       
   179 \end{equation}
       
   180 
       
   181 \section{Miscellaneous}
       
   182 \subsection{Presentations}
       
   183 \subsection{Including Code}
       
   184 \begin{lstlisting}
       
   185 string="Hello, World! "
       
   186 for i in range(10):
       
   187     print string*i
       
   188 \end{lstlisting} 
       
   189 \subsection{Including files}
       
   190 \input{final-include}
       
   191 
       
   192 \bibliography{final}
       
   193 
       
   194 \appendix
       
   195 \section{Appendices - How to}
       
   196 \label{append}
       
   197 Every Part, Chapter or Section that follows the \verb+\appendix+ command is included in the appendix. Appendices have auto numbering too. The numbering begins freshly in the appendices. 
       
   198 
       
   199 \end{document}