latex intro

Post on 18-Nov-2014

846 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

LaTeX typesetting talk slides, presented during KLBarcamp 2010 in Segi College, USJ, Malaysia, 25th April 2010

TRANSCRIPT

KLBarcamp 2010

LATEX typesetting

Muhammad Najmi bin Ahmad Zabidi

Department of Computer ScienceKulliyyah of Information & Communication Technology

International Islamic University Malaysia

25th April 2010

najmi.zabidi@gmail.com

KLBarcamp 2010

Agenda I

1 Intro to LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example

4 Inserting codesverbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters

6 Mathematics

KLBarcamp 2010

Agenda II

7 Writing bookBook cover

8 Tools to generate LATEX codeskdissertOpenOffice

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 whichcontains 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 LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

KLBarcamp 2010

Intro to LATEX

Platform

Platform for LATEX

Almost every major operating systems i.e Linux, Windows and MacOS 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 andLEd(also, check on TeXworks)

If you plan to write on notepad, go ahead, but you need tocompile it later on

KLBarcamp 2010

Intro to LATEX

Platform

What do you mean by . . .

c o m p i l e ?

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 LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

KLBarcamp 2010

Editors

Kile

KLBarcamp 2010

Editors

Texworks

1 Intro to LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

KLBarcamp 2010

Editors

Texworks

KLBarcamp 2010

Editors

Vim

1 Intro to LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

KLBarcamp 2010

Editors

Vim

KLBarcamp 2010

Simple example

Using article class

%f i r s t , d e t e rm ine the document c l a s s , we have 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 )\documentc l a s s [ a4 paper , 10 pt ]{ a r t i c l e }

%next , t e l l which package tha t you want to l oad . . i t can be a l o t !\usepackage{ c o l o r}\usepackage{ l i p sum} %the in famous lorem ipsum s t u f f s , as f i l l e r%open ing\ t i t l e {Simple t e s t}\autho r{Enc ik S imple}\date{23 A p r i l 2010} % empty b r a c k e t s=today ’ s date

%now you may beg in . . \beg in someth ing l i k e HTML <body> t ag s%and l a t e r you w i l l c l o s e w i th \end

\beg in{document}\mak e t i t l e%dec l a r e , t h i s i s the t i l e

\beg in{ a b s t r a c t}Simple i s j u s t s imp le , no th i ng e l s e . {\ l i p sum [1 ]}

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

%now c l o s i n g , t h i s shou l d be at the 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’sinput

There are two choices:

verbatimlisting package

KLBarcamp 2010

Inserting codes

verbatim

1 Intro to LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

KLBarcamp 2010

Inserting codes

verbatim

Verbatim

\ beg in { ve rba t im }

\end{ ve rba t im }

#inc l ud e <s t d i o . h>u s i n g namespace s td ;i n t main ( ){cout<<”He l l o !”<< end l ;r e t u r n 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 LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

KLBarcamp 2010

Inserting codes

listing

listing package I

To use listing, first we have to include the package, this can bedone by putting

\include{listings}

at the header of the LATEX main file.Later;

\ beg in { 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

\ beg in { l s t l i s t i n g } [ l anguage=C++]%put the op t i on o f l anguage i n [ ]#inc l ud e <s t d i o . h>u s i n g namespace s td ;i n t main ( ){cout<<”He l l o !”<< end l ;r e t u r n 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:

#inc l ud e <s t d i o . h>us ing namespace s t d ;i n t main ( ){cout<<” He l l o ! ”<<end l ;r e t u r n 0 ;}

KLBarcamp 2010

Inserting codes

listing

listing’s output (with line numbers)

Given you want to put line numbers:

1 #inc lude <s t d i o . h>2 us ing namespace s t d ;3 i n t main ( )4 {5 cout<<” He l l o ! ”<<end l ;6 r e t u r n 0 ;7 }

\lstset{framexleftmargin=5mm}

\begin{lstlisting}[language=C++,numbers=left]

#include<stdio.h>

using namespace std;

int main()

{

cout<<"Hello!"<<endl;

return 0;

}

\end{lstlisting}

KLBarcamp 2010

Inserting codes

pygmentize

1 Intro to LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

KLBarcamp 2010

Inserting codes

pygmentize

pygmentize I

pygmentize is not in the LATEX package, however it is able togenerate .tex code for your inclusion. Later, we include theintended 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 reimport sysimport GeoIPGEOIP_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 LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

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 then2: return nombor ganjil3: else4: 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 then2: I might resting back home3: else4: 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 whichprovides support to LATEX

I only comfortable with arabtex package, and alqalam if youneed

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}cUbA tUlIs\end{RLtext}

\setarab\vocalize\begin{RLtext}hal ‘indakum al-su’al?\end{RLtext}

Jawi

��Ëñ�K AK. ñk�

Arabic

? �

ñ�

�Ë@ Õ�»

�Y

J«� É

�ë

KLBarcamp 2010

Arabic and Jawi characters

List of Arabic/Jawi characters[Brouwer, ]

@ H.�

H�

H h. h p XX 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 yNon 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

ø

ðAg.àA��Ëñ

�K ÕË @X ArabTEX Blocks

ÐA�KQ

�¯ hñ

�JJk�

ø

ðAg.àA��Ëñ

�K A¿ñ� ø

A�

@ðY» hñ�JJk�

ø

ðAg.àA��Ëñ

�K A¿ñ�

�I

�«A� ø

A�

A

¾J�J» hñ

�JJk�

ø

ðAg. ��Ëñ�K AKA�

KLBarcamp 2010

Arabic and Jawi characters

ø

ðAg.àA��Ëñ

�K ÕË @X ArabTEX Blocks

ÐA�KQ

�¯ hñ

�JJk�

ø

ðAg.àA��Ëñ

�K A¿ñ� ø

A�

@ðY» hñ�JJk�

ø

ðAg.àA��Ëñ

�K A¿ñ�

�I

�«A� ø

A�

A

¾J�J» hñ

�JJk�

ø

ðAg. ��Ëñ�K AKA�

KLBarcamp 2010

Arabic and Jawi characters

ø

ðAg.àA��Ëñ

�K ÕË @X ArabTEX Blocks

ÐA�KQ

�¯ hñ

�JJk�

ø

ðAg.àA��Ëñ

�K A¿ñ� ø

A�

@ðY» hñ�JJk�

ø

ðAg.àA��Ëñ

�K A¿ñ�

�I

�«A� ø

A�

A

¾J�J» hñ

�JJk�

ø

ðAg. ��Ëñ�K AKA�

KLBarcamp 2010

Mathematics

What’s up with Math?

Among the most frequent users (or must use) or LATEX aremath scholars/students

We, the IT people may rarely use this package unless you’redoing math analysis of say, certain algorithm, or for socialscience 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]

Am,n =

a1,1 a1,2 · · · a1,n

a2,1 a2,2 · · · a2,n...

.... . .

...am,1 am,2 · · · am,n

can be done by:

\ [A {m, n} =\beg in{pmat r i x}

a {1 ,1} & a {1 ,2} & \cdo t s & a {1 ,n} \\a {2 ,1} & a {2 ,2} & \cdo t s & a {2 ,n} \\\vdo t s & \vdo t s & \ddots & \vdo t s \\a {m,1} & a {m,2} & \cdo t s & a {m, n}\end{pmat r i x}\ ]

KLBarcamp 2010

Mathematics

Matrices examples, from [Wikibooks, 2010b]

Am,n =

a1,1 a1,2 · · · a1,n

a2,1 a2,2 · · · a2,n...

.... . .

...am,1 am,2 · · · am,n

can be done by:

\ [A {m, n} =\beg in{pmat r i x}

a {1 ,1} & a {1 ,2} & \cdo t s & a {1 ,n} \\a {2 ,1} & a {2 ,2} & \cdo t s & a {2 ,n} \\\vdo t s & \vdo t s & \ddots & \vdo t s \\a {m,1} & a {m,2} & \cdo t s & a {m, n}\end{pmat r i x}\ ]

KLBarcamp 2010

Mathematics

Equation

(x + y)2 = x2 + 2xy + y2 (1)

(x − y)2 = x2 − 2xy + y2 (2)

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

\beg in{ eqna r r a y}( x + y )ˆ2 &=& xˆ2 + 2xy + yˆ2\\( x − y )ˆ2 &=& xˆ2 − 2xy + yˆ2\\

&=& ( x + y )ˆ2 − 4xy\end{ eqna r r a y}

KLBarcamp 2010

Mathematics

Final example, from [Wikibooks, 2010b]

\ [\ sum { i =1}ˆ{10} t i\ ]

10∑i=1

ti

KLBarcamp 2010

Writing book

Book class

Instead of putting

\ documentc l a s s [ a r t i c l e ]

we put

\ documentc l a s s [ book ]

in the preamble.

It really helps when the numbering of chapters, sections,subsections, figures and tables being done automaticallyIn addition to that, the table of contents and table of figuresas wellNot only that, you are also able to simply create indexes andglossariesCheck 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 LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

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 LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

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 documentgenerating to say,OpenOffice,DocBook andLaTeX

The codes genearated arequite OK, if you’re on therush.

KLBarcamp 2010

Tools to generate LATEX codes

OpenOffice

1 Intro to LATEXPlatform

2 EditorsKileTexworksVim

3 Simple example4 Inserting codes

verbatimlistingpygmentizePseudocode

5 Arabic and Jawi characters6 Mathematics7 Writing book

Book cover8 Tools to generate LATEX codes

kdissertOpenOffice

9 BibTeX10 Reference

KLBarcamp 2010

Tools to generate LATEX codes

OpenOffice

writer2latex

By issuing the following command in Ubuntu Linux 9.10:

sudo apt−get 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 readsacademic papersHelps in term of cross-referencing and sorting citation(especially IEEE style)If you look at Springerlink/ACM/IEEE online databases, youwill aware of such formatExport to RIS/BibTeX formatTools 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 ,au tho r = ” Michae l Dav i s and Sean Bodmer and Aaron LeMasters ” ,t i t l e = ”HACKING EXPOSED MALWARE AND ROOTKITS” ,y ea 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 dd r e s s = ”New York , NY, USA”}

@A r t i c l e{ b a r f o r d 2 0 0 6 i n s i d e ,t i t l e = ”{An i n s i d e l ook at bo tn e t s }” ,au tho r = ”P . Ba r f o rd and V. Yegneswaran ” ,j o u r n a l = ”Malware Detec t i on , s e r . Advances i n I n f o rma t i o n S e c u r i t y . Sp r i nge r−Ver l ag ” ,pages = ”171−−191”,y ea 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.comhttp://latex-my.blogspot.com/

http://code.google.com/p/latex-my-docs/

top related