Introduction to LaTeX - SKKUlab.icc.skku.ac.kr/~navrati/LaTeX_presentation.pdf · A revolution in...
Transcript of Introduction to LaTeX - SKKUlab.icc.skku.ac.kr/~navrati/LaTeX_presentation.pdf · A revolution in...
Introduction to LaTeX
Instructor
Prof. Navrati Saxena
Associate Professor
Sungkyunkwan University
TA
Mamta Agiwal
Ph.D Research Scholar
Sungkyunkwan Univesity
Introducing LaTeX
What is TeX & LaTeX
Why use LaTeX
Options other than LaTeX
S/w required to setup LaTeX for windows
Official help/tutorials (online & offline)
Installation steps
Hands on LaTeX
Process to create a document using TeX
How to use LaTeX to create documents
Basic structure of a LaTeX document
Templates
Packages
Paper body
Lets create our own paper
Conclusion
References
What is TeX and LaTeX?
TeX is essentially a Markup Language (like
HTML, XML and RTF)
TeX written by Donald Knuth in 70´s
A revolution in typesetting
Latex is an extension of TeX
Macro packages to make TeX easier to use
What is TeX and LaTeX?
LaTeX is a typesetting systems suitable for producing scientific and mathematical documents.
—LaTeX enables authors to typeset and print their work at the highest typographical quality.
—LaTeX uses TeX formatter as its typesetting engine.
—TeX is popular in academia, especially for writing research papers.
Unique Advantages of LaTeX
Professional typesetting
Best output
It is the standard for scientific documents
Processing Mathematical (& other) symbols
Meaning based structuring (rather than appearance)
Knowledgeable and helpful user group
Its FREE!
Platform independent
Disadvantages of using LaTeX
“Hard to write disorganized documents”*
Learning Curve
Customizing is tedious.
* Taken verbatim from Not so short introduction to LaTeX
Latex vs. Word Processors
High typeset quality
Easy to include math formulas
Source file format is not bounded to a particular OS or platform
Latex implementations exists for all platforms (DOS, Windows, Unices,..)
Latex is free
Latex vs. Word Processors
De facto standard for scientific publishing
Very few bugs
Good for large documents
Can run even on 386 PC
High quality
Easy to use, especially for typing mathematical formulas
Portability (Windows, Unix, Mac)
Stability and interchangeability (Office 97 Office 2000)
Most scientific journals have their LaTeX styles (justdownload and use them).
Control: LaTeX is much more clever in positioning ourimages, text and tables with a lot of common sense.
Why Use LaTeX?
J[x(×),u(×)] = F(x(t),u(t),t)dtt0
¥
ò Word
LaTeX
Points to Ponder
In a LATEX environment, LATEX takes the role of the book designer and uses TEX as its typesetter.
But LATEX is “only” a program and therefore needs more guidance.
The author has to provide additional information to the text as “LATEX commands.”
Parts of a LaTeX Document: \documentclass
• First line of all LaTeX documents
• Specifies the type of the document
• Eg: \documentclass[journal]{IEEEtran}
\documentclass{article}
{report}
{book}
{letter}
Basic Classes
Packages
\begin{document}
\end{document}
\usepackage{algorithmic}
\usepackage{array}
\usepackage{fixltx2e}
\usepackage{amsmath,amsfonts,amssymb}
\usepackage{epsfig}
\usepackage{graphicx}
\usepackage{psfrag}
\usepackage{epstopdf}
\usepackage[utf8]{inputenc}
\usepackage{multicol}
\usepackage{multirow}
\usepackage{cite}
\usepackage{refstyle}
Special Characters
The following symbols are reserved characters that either have a special
# $ % ^ & _ { } ~ \
meaning under LATEX or are not available in all the fonts.
If you enter them directly in your text, they will normally not print, but rather coerce LATEX to do things you did not intend.
These characters can be used in documents all the same by using a prefix backslash:
\# \$ \% \^\{ \& \_ \{ \} \~{}
# $ % ˆ & _ { } ˜ \
The backslash character \can not be entered by adding another backslash in front of it (\\); this sequence is used for line breaking. Use the \textbackslash command instead.
Special Characters
Latex File Structure
•Document Class Predefined Formats (article, report, book,..).
•Packages usedAdded Functionality (graphics, reference style,...).
•Main BodyText and Bibliography References.
Parts of a LaTeX Document: Environment
Start with \begin{. . .}
End with \end{. . .}
\begin{document}
\begin{equation}
…
\end{equation}
\end{document}
Example of Latex document
\documentclass{article}
\title{Simple Example}
\author{Mamta Agiwal}
\date{March 2000}
\begin{document}
\maketitle
Hello world!
\end{document}
Options other than LaTeX
• Adobe claims to be implementing technical publishing functionality
in InDesign.
• Lout A markup language with a completely different underlying architecture
to TeX.
• Troff/Groff. Originally designed for technical documentation within AT&T
during the 1970s (actually a spinoff of the UNIX R&D work), it's still quite
widely used for this today. For quite a long time most if not all O'Reilly
books were typeset using it.
• DocBook. This is an XML tag based format for structure documentation,
and tends to work by rendering through foreign engines.
• Wordperfect. This is a venerable word processing system that is
considerably better at documentation-in-the-large than MS-Word.
• Microsoft Word. Not recommended for serious technical publication tasks
due to its instability on complex documents.
Softwares required to Setup LaTeX for Windows
• Download and install MikTeX
http://www.miktex.org/
• Install Ghostscript and Gsview http://pages.cs.wisc.edu/~ghost/
• Install Acrobat Reader
• Install Editor
— WinEdt
http://www.winedt.com/
— TexnicCenter
http://www.texniccenter.org/
— Texmaker
http://www.xm1math.net/texmaker/
LaTeX package
PS device driver …
TeXShop
iTexMac
Texmaker
…
For MAC Users
Official help/tutorials (online & offline)
• Learn as you go
— “The not so short introduction to LaTeX2e”
http://tobi.oetiker.ch/lshort/lshort.pdf
— Comprehensive TeX archive network
http://www.ctan.org/
— Beginning LaTeX
http://www.cs.cornell.edu/Info/Misc/LaTeX-Tutorial/LaTeX-Home.html
— Online help by Texmaker
http://www.xm1math.net/texmaker/doc.html
Installation steps
Step by step easy installation guide can be downloaded from
our lab website i.e. MUSIC lab website.
Following is the download link:
http://lab.icc.skku.ac.kr/~navrati/latex.html
Process to Create a Document Using TeX
TeX input file
file.tex
DVI file
file.dvi
Out input file
file.ps or file.pdf
Run LaTeX
program
Run Device
Driver
Your source LaTeX
document
Device independent
output
> latex file.tex
> xdiv file.dvi
> dvips file.dvi
> pdflatex file.tex
Unix Commands
runs latex
previewer
creates .ps
creates .pdf directly
How to Use LaTeX to Create Documents?
• Start with a skeleton document.
• Fill stuff (text, formula, figure, table …) into your skeleton
document
• Run LaTeX to generate output and make modifications
The above steps have been shown in the installation guide.
Basic Structure of LaTeX Document
\documentclass [12pt]{article}
\usepackage {color}
\usepackage {graphicx}
\begin{document}
\end{document}
Define the types of the document
(article, book, thesis …)
Preamble. Incorporate packages or
define macros here
Main body, stuff to be printed, title,
authors, abstract, sections,
references, ….
In the Preamble
•You specify your document class.•Document classes: letter, article, report, book, slides(beamer, prosper)• \documentclass[12pt]{article}
• Backslash – at the beginning of text markup command
•Packages: numerous packages are available• \usepackage[margin=1in]{geometry}
• \usepackage{setspace}
• \usepackage{harvard}
Templates
Suppose you want to write a paper for IEEE journals
•Download LaTeX template from IEEE website
http://www.ieee.org/publications_standards/publications/authors/author_templates.html(Template should be used for all Transactions, except for the IEEE Transactions on Magnetics, IEEE Magnetics Letters, IEEE Photonics Journal, and IEEE Transactions on Dielectrics and Electrical Insulation. (quoted from IEEE website mentioned above) )
•Open example LaTeX file (bare_jrnl.tex) and modify it
•No need to worry about things like margin, font, … bare_jrnl.tex
click to open it in Texmaker
Paper body
\begin{document}
\section{Introduction}
\subsection{Subsection Heading Here}
\end{document}
In the Body
To begin a new section
\section{}Similarly, \subsection{}, \subsubsection{}, \subsubsubsection{}
LaTeX does automatic numbering. If you don’t like it, use section*{}
\emph{}, \textbf{}
\singlespacing, \doublespacing, \onehalfspacing
\centering or \begin{centering} & \end{centering}
Lets Write our own paper!
Content for writing paper will be referred from the following reference (just for demonstration):Reis, S.R.N.; Reis, AI, "How to write your first scientific paper," Interdisciplinary Engineering Design Education Conference (IEDEC), 3rd , 4-5 March 2013
Author section
\author{\IEEEauthorblockN{Simone Rosa Nunes Reis}
\IEEEauthorblockA{Instituto de Informática\\
UFRGS\\
Porto Alegre, Brasil\\
Email: [email protected]}
\and
\IEEEauthorblockN{André Inácio Reis}
\IEEEauthorblockA{Instituto de Informática\\
UFRGS\\
Porto Alegre, Brasil\\
Email: [email protected]} }
Abstract\begin{abstract}
This paper presents a method to instruct students on how to write their first scientific paper.
The method adopts a holistic approach that discusses several different aspects of paper writing.
Covered issues include the choice of the paper subject, hypothesis formulation and the design of
experiments to test it, the collection and analysis of data, and the planning and writing of the final
text. The method has been successfully used to teach graduate and undergraduate students to
write their first articles.
\end{abstract}
Keywords
\begin{IEEEkeywords} \textit{\textbf{Writing; Paper Writing; Scientific Method \\}} \end{IEEEkeywords}
Writing sections and subsections
\section{Introduction} Engineers normally do not receive formal training in writing skills,
at least not extensively. This is possibly the reason why the second chapter of Carl Selinger’s
book (Stuff You Don't Learn in Engineering School [1]) is about writing. It is true that communication
skills, especially written communication skills, may affect the professional success of engineers.
\subsection{Dealing with New Knowledge} Article writing is about new knowledge, as a paper is
supposed to advance the scientific knowledge. This means that imagination plays an important
role in scientific discovery. The ability to imagine new things relies on divergent thinking [2],
which implies in being able to associate ideas that normally would not be associated.
This is difficult to admit for people starting in science, as normally students are educated in such
a way that they study a book chapter; and then they are tested to check if they have learnt the
contents of the chapter. This is done normally with a set of exercises that test if the student
understood what was taught and if (s)he is able to use the knowledge from the chapter, which
is a well established knowledge. This kind of thinking is called convergent thinking [2].
Fig. 1 illustrates the concept that new knowledge has to be imagined outside the sum of all
human knowledge; this is the case of new idea ni2, in Fig. 1. Notice that in the more frequent cases,
a person imagines something that is new for the person, but it is not new to humankind; this is the
case of new idea ni1 in Fig. 1.
Inserting an image
\begin{figure}
\centering
\includegraphics[width=0.5\textwidth]{knowledgeimag.JPG}
\caption{New knowledge has to be imagined first}
\label{fig:flow}
\end{figure}
Creating a Table•Add numbered table• \begin{table} \caption{}
•Simple tables can be produced by
• \begin{tabular}[pos]{tablespec}
• Within the {tablespec} section, one details the number of columns, the alignment, and the number of vertical lines of the table.• {lrc}, {|l|r|c}
• Then type in from left to right, the values for each cell with & in between.
• Put “\\” at the end of each row, then input another row of values if needed.
• \hline
Inserting a table
\begin{table}[ht]
\caption{Type of knowledge and their examples}
\label{knowledgetable}
\centering
\begin{tabular}{|c|c|c|}
\hline
\bf{Knowledge Form}\hspace{.5em} & \bf{Definition}\hspace{.5em} & \bf{Examples}\hspace{.5em} \\
\hline
Concept & generalized idea about something & the mole \\
\hline
Rule & set of facts & units \\
\hline
Process & a sequence of steps & equation \\
\hline
\end{tabular}
\end{table}
Writing mathematical equations
\begin{equation}
\label{eq:lambda}
\lambda &= \frac{P_i}{\sum_{i=1}^{N}{P_i}}+Zipf(\theta)^i
\end{equation}
One estimate puts the count at 1.8 million articles published each year, in about 28,000 journals.
As many as $50\%$ of papers are never read by anyone other than their authors, referees and
journal editors. $90\%$ percent of papers published are never cited.
\begin{align}
E_0 &= mc^2 \\ E &= \frac{mc^2}{\sqrt{1-\frac{v^2}{c^2}}}
\end{align}
Reference
\begin{thebibliography}{1}
\bibitem{IEEEhowto:kopka}
H.~Kopka and P.~W. Daly, \emph{A Guide to \LaTeX}, 3rd~ed.\hskip 1em plus 0.5em minus
0.4em\relax Harlow, England: Addison-Wesley, 1999.
\end{thebibliography}
You can also use bibTeX package to generate reference list
http://www.hep.manchester.ac.uk/u/jenny/jcwdocs/latex/bib
texbasics.html
Citations
\cite{bibtexkey}, citeyear{bibtexkey}
It is more convenient to create a bibliography file, called bibtex file(.bib) and use it as needed.
WinEdt is capable of creating a bib file, but there are more convenient tools out there.
JabRef (http://jabref.sourceforge.net/)
Standard Environments
\begin{env_name}
stuff
\end{enc_name}
\begin{itemize}
\item The first item
\item The second item
\end{itemize}
\begin{enumerate}
\item The first item
\item The second item
\end{enumerate}
Environment name (env_name) can be
document, itemize, enumerate, tabular, etc.
Cross Referencing
LaTeX generates numbers for Theorem, Equation, Section,
Figure and other environments automatically. You can access
them with \label and \ref
\section{Introduction} \label{sec:intro}
….
In Section \ref{sec:intro}, we ….
Adding footnote
The footnote facility is easy to use.
The command you need is: \footnote{text}.
LaTeX will obviously take care of typesetting the footnote
at the bottom of the page.
Each footnote is numbered sequentially
NOTE: Do not leave a space between the command and the
word where you wish the footnote marker to appear,
otherwise LaTeX will process that space and will leave the
output not looking as intended.
Writing an algorithm
LaTeX has several packages for
typesetting algorithms in form of
"pseudocode".
One of the simple and beautiful ways to
insert algorithms or procedures into a
LaTeX document is using the
algorithmicx package.
Simple example is given in the next slide:
Online Latex: Share Latex
Share with one person only (not sure)
Susceptible to corruption ( Take Backup)
Security issues
Alternatives (writelatex)
CDC, 2007
Writing an algorithm
% Add the packages
\usepackage{algorithm}
\usepackage{algpseudocode}
% Insert the algorithm
\begin{algorithm}
\caption{Compute sum of integers in array}
\label{array-sum}
\begin{algorithmic}[1]
\Procedure{ArraySum}{$A$}
\State $sum = 0$
\For {each integer $i$ in $A$}
\State $sum = sum + i$
\EndFor
\State Return $sum$
\EndProcedure
\end{algorithmic}
\end{algorithm}
OUTPUT:
Conclusion
In the first session we saw the brief introduction to LaTeX
LaTeX is a document preparation system and document
markup language.
It is widely used for the communication and publication of
scientific documents in many fields, including
mathematics, physics, computer science, economics, and
political science.
We saw the installation softwares and guide to install
LaTeX.
In the second session we learnt how to create our own
research paper.
Trouble Shooting
Often times, you make a mistake when creating a
document. You will notice the log file reporting a
problem.
There are some common mistakes:
“end” doesn’t follow “begin”
$ doesn’t follow $
Using commands from packages lot defined in the preamble
Don’t forget “\”s.
References
Reis, S.R.N.; Reis, AI, "How to write your first scientific
paper," Interdisciplinary Engineering Design Education Conference
Introduction to LaTeX, PRISM Brownbag Series,Byungwon Woo
Introduction to LaTeX, Arun K. Subramaniyan, PurdueUniversity
The Not So Short Introduction to LATEX2, Tobias Oetiker, Hubert
Partl, Irene Hyna and Elisabeth Schlegl
Website Links:
http://en.wikipedia.org/wiki/LaTeX
http://www.smithsonianmag.com/smart-news/half-academic-
studies-are-never-read-more-three-people-180950222/?no-ist