Vous êtes sur la page 1sur 68

KLBarcamp 2010

LATEX typesetting

Muhammad Najmi bin Ahmad Zabidi

Department of Computer Science


Kulliyyah of Information & Communication Technology
International Islamic University Malaysia

25th April 2010

najmi.zabidi@gmail.com
KLBarcamp 2010

Agenda I
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
KLBarcamp 2010

Agenda II
7 Writing book
Book cover

8 Tools to generate LATEX codes


kdissert
OpenOffice

9 BibTeX

10 Reference
KLBarcamp 2010
Intro to LATEX

What is LATEX?

A typesetting program
KLBarcamp 2010
Intro to LATEX

Why we need LATEX?

Depends on your purpose


For me,it helps me when I need to writing articles which
contains cross-referencing to article
Fortunately, it is not only limited to that ...(comes obsession!)
KLBarcamp 2010
Intro to LATEX

What LATEX can do ?

For students
Writing research articles, assignments
Final year project report, theses/dissertations
It’s your call

For professionals
Writing technical reports, codes documentations
Resume :-)
Business cards, books
The rest up to you . . .
KLBarcamp 2010
Intro to LATEX

LATEX vs Word learning curve . . .

Figure: Learning curve differences [Brunton, 2010]


KLBarcamp 2010
Intro to LATEX
Platform
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Intro to LATEX
Platform

Platform for LATEX

Almost every major operating systems i.e Linux, Windows and Mac
OS have LATEX applications.
Windows for example, using MikTeX
Mac OS using MacTeX
Linux uses TexLive
KLBarcamp 2010
Intro to LATEX
Platform

How we can actually write in LATEX?

Using normal text editors (notepad, gvim/vim, emacs)


If you’re running Windows, you can get a copy of WinEdt and
LEd(also, check on TeXworks)
If you plan to write on notepad, go ahead, but you need to
compile it later on
KLBarcamp 2010
Intro to LATEX
Platform

What do you mean by . . .

compile?
KLBarcamp 2010
Intro to LATEX
Platform

LATEX flow diagram . . . , the whole picture

Figure: The diagram [Wikibooks, 2010a]


KLBarcamp 2010
Intro to LATEX
Platform

The simplest idea is . . .


.tex − −− > (compilewithpdflatex) − −− > PDF
KLBarcamp 2010
Editors
Kile
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Editors
Kile
KLBarcamp 2010
Editors
Texworks
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Editors
Texworks
KLBarcamp 2010
Editors
Vim
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Editors
Vim
KLBarcamp 2010
Simple example

Using article class


%f i r s t , d e t e r m i n e t h e document c l a s s , we h a v e a r t i c l e ,
%r e p o r t and book ( b a s i c c l a s s e s )
\documentclass [ a4 paper , 1 0 pt ]{ a r t i c l e }

%n e x t , t e l l w h i c h p a c k a g e t h a t you want t o l o a d . . i t can be a l o t !


\usepackage{ c o l o r }
\ u s e p a c k a g e { l i p s u m } %t h e i n f a m o u s l o r e m ipsum s t u f f s , a s f i l l e r
%o p e n i n g
\ t i t l e {Simple t e s t }
\author{Encik Simple}
\ d a t e {23 A p r i l 2010} % empty b r a c k e t s=t o d a y ’ s d a t e

%now you may b e g i n . . \ b e g i n s o m e t h i n g l i k e HTML <body> t a g s


%and l a t e r you w i l l c l o s e w i t h \end

\ b e g i n {document}
\maketitle
%d e c l a r e , t h i s i s t h e tile

\begin{abstract}
S i m p l e i s j u s t s i m p l e , n o t h i n g e l s e . {\ l i p s u m [ 1 ] }

\end{ a b s t r a c t }

%now c l o s i n g , t h i s s h o u l d be a t t h e v e r y end . . .
\end{document}
KLBarcamp 2010
Simple example
KLBarcamp 2010
Inserting codes

Code inclusion and syntax highlighting

Perhaps you’re working on computer programming codes


. . . and you want to differentiate system words with user’s
input
There are two choices:
verbatim
listing package
KLBarcamp 2010
Inserting codes
verbatim
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Inserting codes
verbatim

Verbatim

\ begin { verbatim }

\ end { v e r b a t i m }

#i n c l u d e <s t d i o . h>
u s i n g namespace s t d ;
i n t main ( ) {
cout <<”H e l l o !”<< e n d l ;
return 0;}
KLBarcamp 2010
Inserting codes
verbatim

Result of verbatim

#include<stdio.h>
using namespace std;
int main()
{
cout<<"Hello!"<<endl;
return 0;
}
KLBarcamp 2010
Inserting codes
listing
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Inserting codes
listing

listing package I

To use listing, first we have to include the package, this can be


done by putting
\include{listings}
at the header of the LATEX main file.
Later;
\ begin { l s t l i s t i n g }

\ end { l s t l i s t i n g }
KLBarcamp 2010
Inserting codes
listing

listing package II

\ b e g i n { l s t l i s t i n g } [ l a n g u a g e=C++]
%p u t t h e o p t i o n o f l a n g u a g e i n [ ]
#i n c l u d e <s t d i o . h>
u s i n g namespace s t d ;
i n t main ( ) {
cout <<”H e l l o !”<< e n d l ;
return 0;}
\ end { l s t l i s t i n g }
KLBarcamp 2010
Inserting codes
listing

listing’s output

Finally, this is what it is looks like:


#i n c l u d e <s t d i o . h>
u s i n g namespace s t d ;
i n t main ( ) {
cout <<” H e l l o ! ”<<e n d l ;
return 0;}
KLBarcamp 2010
Inserting codes
listing

listing’s output (with line numbers)

Given you want to put line numbers:


1 #i n c l u d e <s t d i o . h> \lstset{framexleftmargin=5mm}
2 u s i n g namespace s t d ; \begin{lstlisting}[language=C++,numbers=left]
#include<stdio.h>
3 i n t main ( ) using namespace std;
4 { int main()
{
5 cout <<” H e l l o ! ”<<e n d l ; cout<<"Hello!"<<endl;
6 return 0; return 0;
}
7 } \end{lstlisting}
KLBarcamp 2010
Inserting codes
pygmentize
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Inserting codes
pygmentize

pygmentize I

pygmentize is not in the LATEX package, however it is able to


generate .tex code for your inclusion. Later, we include the
intended code within Verbatim (it’s capital V).
The syntax is :
pygmentize -l python -f latex -O full -o pycode.tex pycode.py
KLBarcamp 2010
Inserting codes
pygmentize

pygmentize output for Python’s code

import re
import sys
import GeoIP
GEOIP_DATABASE=’/usr/share/GeoIP/GeoIP.dat’
geoip=GeoIP.open(GEOIP_DATABASE,GeoIP.GEOIP_STANDARD)
for line in open("chcountry.txt"):
columns = line.split(’,’)
negara=geoip.country_name_by_addr(columns[0])
x=columns[1].strip("\n")
print columns[0],(’,’),negara,(’,’),x
KLBarcamp 2010
Inserting codes
pygmentize

pygmentize output for C++’s code

#include<stdio.h>
using namespace std;
int main(){
cout<<"Hello!"<<endl;
return 0;}
KLBarcamp 2010
Inserting codes
Pseudocode
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Inserting codes
Pseudocode

Displaying algorithms I

Algorithm 1 Modulus(n)
Require: Nilai integer n > 0 atau n < 0.
Ensure: Nilai n 6= 0.
1: if n dibahagi dengan 2 6= 0 then
2: return nombor ganjil
3: else
4: return nombor genap·
5: end if
KLBarcamp 2010
Inserting codes
Pseudocode

Displaying algorithms II

\algsetup{indent=2em}
\begin{algorithm}[H]
\caption{$Modulus(n)$}\label{alg:mod}
\begin{algorithmic}[1]
\REQUIRE Nilai integer $n>0$ atau $n<0$.
\ENSURE Nilai $n \neq 0$.
\medskip
\IF {$n$ dibahagi dengan 2 $\neq 0$}
\RETURN $nombor$ $ganjil$
\ELSE
\RETURN $nombor$ $genap \cdot $
\ENDIF
\end{algorithmic}
\end{algorithm}
KLBarcamp 2010
Inserting codes
Pseudocode

Displaying algorithms I

Algorithm 2 Logic(n)

1: if I am not here today then


2: I might resting back home
3: else
4: I rebel for free food!
5: end if
KLBarcamp 2010
Inserting codes
Pseudocode

Displaying algorithms II

\begin{algorithm}[H]
\caption{$Logic(n)$}\label{alg:mod2}
\begin{algorithmic}[1]
\medskip
\IF {I am not here today}
\STATE I might resting back home
\ELSE
\STATE I rebel for free food!
\ENDIF
\end{algorithmic}
\end{algorithm}
KLBarcamp 2010
Arabic and Jawi characters

Writing Arabic texts/Jawi

Mapping characters
As far as I know, there are several Arabic package which
provides support to LATEX
I only comfortable with arabtex package, and alqalam if you
need
arabtex provides support to Arabic characters, including Jawi
(Malay version)
alqalam if you want to print Quran verses
KLBarcamp 2010
Arabic and Jawi characters

The character map I

\setmalay
\novocalize
\begin{RLtext} Jawi
cUbA tUlIs 
ËñK AK. ñk
\end{RLtext}

\setarab
Arabic
\vocalize

\begin{RLtext} ? È ñ ‚Ë@ Õ»YJ« Éë
hal ‘indakum al-su’al?
\end{RLtext}
KLBarcamp 2010
Arabic and Jawi characters

List of Arabic/Jawi characters[Brouwer, ]

@ H. H H h. h p X X P P € € 
A b t _t j .h _h d _d r z s ^s .s
     ¨ ¨ ¬ † ¼ È Ð à è ð ø

.d .t .z ‘ .g f q k l m n h w y
Non pure Arabic characters, including Jawi:

H ¬ h h P À h ¼ È P
p v ^c ,c ^z g c ^n ^l .r
KLBarcamp 2010
Arabic and Jawi characters


ËñK ÕË@X
ø
ðAg. àA‚ ArabTEX Blocks

ÐAKQ¯ hñJJk


ËñK A¿ñƒ ø Aƒ
ø
ðAg. àA‚

KLBarcamp 2010
Arabic and Jawi characters


ËñK ÕË@X
ø
ðAg. àA‚ ArabTEX Blocks

ÐAKQ¯ hñJJk


ËñK A¿ñƒ ø Aƒ
ø
ðAg. àA‚

@ð Y» hñJJk

 ø Aƒ

ËñK A¿ñƒ I «Aƒ
ø
ðAg. àA‚

KLBarcamp 2010
Arabic and Jawi characters


ËñK ÕË@X
ø
ðAg. àA‚ ArabTEX Blocks

ÐAKQ¯ hñJJk


ËñK A¿ñƒ ø Aƒ
ø
ðAg. àA‚

@ð Y» hñJJk

 ø Aƒ

ËñK A¿ñƒ I «Aƒ
ø
ðAg. àA‚


A¾J
J» hñJJk

ø
ðAg. 
ËñK AK

KLBarcamp 2010
Mathematics

What’s up with Math?

Among the most frequent users (or must use) or LATEX are
math scholars/students
We, the IT people may rarely use this package unless you’re
doing math analysis of say, certain algorithm, or for social
science when you want to include your statistical formulas.
Math package provided by American Mathematical Society
(AMS).
KLBarcamp 2010
Mathematics

Simple math example I


3
8=2

was procuded by;


$\sqrt[3]{8} = 2$

and,
√4
16 = 2

with
$\sqrt[4]{16} = 2$
KLBarcamp 2010
Mathematics

Matrices examples, from [Wikibooks, 2010b]

 
a1,1 a1,2 ··· a1,n
 a2,1 a2,2 ··· a2,n 
Am,n = .
 
.. .. .. 
 .. . . . 
am,1 am,2 · · · am,n
KLBarcamp 2010
Mathematics

Matrices examples, from [Wikibooks, 2010b]

 
a1,1 a1,2 ··· a1,n
 a2,1 a2,2 ··· a2,n 
Am,n = .
 
.. .. .. 
 .. . . . 
am,1 am,2 · · · am,n
can be done by:
\[
A {m, n} =
\begin{pmatrix}
a {1 ,1} & a {1 ,2} & \cdots & a {1 , n} \\
a {2 ,1} & a {2 ,2} & \cdots & a {2 , n} \\
\vdots & \vdots & \ddots & \ v d o t s \\
a {m, 1 } & a {m, 2 } & \cdots & a {m, n}
\end{ p m a t r i x }
\]
KLBarcamp 2010
Mathematics

Equation

(x + y )2 = x 2 + 2xy + y 2 (1)
2 2 2
(x − y ) = x − 2xy + y (2)
2
= (x + y ) − 4xy (3)

\begin{eqnarray}
( x + y ) ˆ 2 &=& x ˆ2 + 2 xy + y ˆ2\\
( x − y ) ˆ 2 &=& x ˆ2 − 2 xy + y ˆ2\\
&=& ( x + y ) ˆ 2 − 4 xy
\end{ e q n a r r a y }
KLBarcamp 2010
Mathematics

Final example, from [Wikibooks, 2010b]

\[ 10
X
\ sum { i =1}ˆ{10} t i ti
\]
i=1
KLBarcamp 2010
Writing book

Book class
Instead of putting
\ documentclass [ a r t i c l e ]

we put
\ d o c u m e n t c l a s s [ book ]

in the preamble.
It really helps when the numbering of chapters, sections,
subsections, figures and tables being done automatically
In addition to that, the table of contents and table of figures
as well
Not only that, you are also able to simply create indexes and
glossaries
Check my free LATEX book in Bahasa at http:
//latex-my-docs.googlecode.com/files/book.pdf
KLBarcamp 2010
Writing book
Book cover
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Writing book
Book cover
KLBarcamp 2010
Writing book
Book cover
KLBarcamp 2010
Tools to generate LATEX codes

You don’t always necessary to write the LATEX codes all time
There’s tools to help you
Something like MS Frontpage for web design
But you know. . . , automated stuffs :-)
KLBarcamp 2010
Tools to generate LATEX codes
kdissert
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Tools to generate LATEX codes
kdissert

kdissert
KLBarcamp 2010
Tools to generate LATEX codes
kdissert

kdissert

kdissert is a mindmap tool


It supports document
generating to say,
OpenOffice,DocBook and
LaTeX
The codes genearated are
quite OK, if you’re on the
rush.
KLBarcamp 2010
Tools to generate LATEX codes
OpenOffice
1 Intro to LATEX
Platform
2 Editors
Kile
Texworks
Vim
3 Simple example
4 Inserting codes
verbatim
listing
pygmentize
Pseudocode
5 Arabic and Jawi characters
6 Mathematics
7 Writing book
Book cover
8 Tools to generate LATEX codes
kdissert
KLBarcamp 2010
Tools to generate LATEX codes
OpenOffice

writer2latex

By issuing the following command in Ubuntu Linux 9.10:


sudo apt−g e t i n s t a l l o p e n o f f i c e . org−w r i t e r 2 l a t e x

you should be able to get the converter installed.


KLBarcamp 2010
Tools to generate LATEX codes
OpenOffice
KLBarcamp 2010
Tools to generate LATEX codes
OpenOffice

Say I just want to include


Saya sangat gembira

It shouldn’t be long
KLBarcamp 2010
Tools to generate LATEX codes
OpenOffice
KLBarcamp 2010
BibTeX

BibTEX

Usually being used by research students, or people who reads


academic papers
Helps in term of cross-referencing and sorting citation
(especially IEEE style)
If you look at Springerlink/ACM/IEEE online databases, you
will aware of such format
Export to RIS/BibTeX format
Tools to handle BibTeX files ; Jabref, KbibTeX etc.
Support citation style for example Chicago, Harvard, IEEE,
APA
KLBarcamp 2010
BibTeX

Sample BibTEX file

@Book{ he−r o o t k i t ,
a u t h o r = ” M i c h a e l D a v i s and Sean Bodmer and Aaron L e M a s t e r s ” ,
t i t l e = ”HACKING EXPOSED MALWARE AND ROOTKITS” ,
y e a r = ”2010” ,
i s b n = ”0071591184 , 9780071591188” ,
p u b l i s h e r = ”McGraw−H i l l , I n c . ” ,
a d d r e s s = ”New York , NY, USA”
}

@Article{ barford2006inside ,
t i t l e = ”{An i n s i d e l o o k a t b o t n e t s }” ,
a u t h o r = ”P . B a r f o r d and V . Y e g n e s w a r a n ” ,
j o u r n a l = ” Malware D e t e c t i o n , s e r . A d v a n c e s i n I n f o r m a t i o n S e c u r i t y . S p r i n g e r −V e r l a g ” ,
p a g e s = ”171−−191”,
y e a r = ”2006”
}
KLBarcamp 2010
Reference

Bibliography

Brouwer, A. E.
http://www.win.tue.nl/~aeb/natlang/arabic/arabtex-verb-doc.html.
[Online; accessed 25-April-2010].

Brunton, K. (2010).
Why latex?
https://www.wiki.ed.ac.uk/pages/viewpage.action?pageId=11042821.
[Online; accessed 23-April-2010].

Wikibooks (2010a).
Latex.
http://en.wikibooks.org/wiki/LaTeX/Print_version.
[Online; accessed 23-April-2010].

Wikibooks (2010b).
Latex:mathematics.
http://en.wikibooks.org/wiki/LaTeX/Mathematics.
[Online; accessed 24-April-2010].
KLBarcamp 2010
Close

najmi.zabidi@gmail.com
http://latex-my.blogspot.com/
http://code.google.com/p/latex-my-docs/

Vous aimerez peut-être aussi