by saeid abolfazli faculty of computer science and it, university malaya malaysia. email:...
TRANSCRIPT
By
Saeid Abolfazli
Faculty of Computer Science and IT, University Malaya
Malaysia. Email: [email protected]
Website: www.mobilecloudfamily.com
LaTeX Blog: http://www.mobilecloudfamily.com/blog
Preparing scholarly text using TexStudio
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli2
Outline
Introduction to TexStudio
Customizing TexStudio environment
Structure of a tex file
Compiling a tex file
Title
Authors name and affiliations
Abstract
Keywords
Sections
Table
Figure
References
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli4
Change Menu Language, Font and SizeOptions-> Configure TeXstudio -> “General"
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli5
Change typing font and size
Options-> Configure TeXstudio -> "Editor"
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli6
Change editors colors
Options-> Configure TeXstudio -> "Editor"
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli7
2- Structure of a tex file
\documentclass{document type/or class name}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli8
2- Structure of a tex file
\documentclass{document type/or class name}
For instance
\documentclass{article} or
\documentclass{ieeetran}
9
2- Structure of a tex file
\documentclass{article}
\begin{document} Hello world!
\section{Section 1}
Your text appears here
\subsection{Subsection 1}
Your text appears here
Figures
Tables
References
Bibliography and biography\end{document}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli
Can be anywhere in text
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli10
Structure of a tex file Con’t
Commonly used document types are:
- Article
- Book
- Special class name like IEEEtran
Allowed hierarchies
• Article: \part{}, \section{}, \subsection{}, \subsubsection{}, \paragraph{}, \subparagraph{}.
• Book: \part{}, \chapter{}, \section{}, \subsection{}, \subsubsection{}, \paragraph{}, \subparagraph{}.
• I will get back to this topic later in this workshop
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli11
Make a New Tex file
You can make a new file from one of the following options:
1- Wizard->quick start
2- Menu Bar File-> New from Template->
3-Scripting
Tips: 1- LaTeX is case sensitive
2- All tags in LaTeX are lower case
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli12
Customize a tex document
[options] will be used to manipulate a command.
\documentclass[options]{article}
\begin{document} Hello world!\end{document}
If you want to alter the document like paper size, font size , etc you should customize the \documentclass command
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli13
The most common options for the standard document classes are listed in the following table:
10pt,12pt Sets the size of the main font in the document. If no option is specified, 10pt is assumed.
a4paper, letterpaper,...
Defines the paper size. The default size is letterpaper. A5paper, B5paper, executivepaper, and legalpaper can be specified.
onecolumn, twocolumn
Instructs LaTeX to typeset the document in one column or two columns.
twoside, oneside
Specifies whether double or single sided output should be generated. The classes article and report are single sided and the book class is double sided by default. Note that this option concerns the style of the document only. The option twoside does not tell the printer you use that it should actually make a two-sided printout.
draft
makes LaTeX indicate hyphenation and justification problems with a small square in the right-hand margin of the problem line so they can be located quickly by a human. It also suppresses the inclusion of images and shows only a frame where they would normally occur.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli14
Hands-on Practice 1
Create a simple tex file
Make two sections:
1- Introduction
Write one paragraph text
2- Background
Write one paragraph text
Under background create another subsection called Literature Review
Write one paragraph text
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli15
Compiling the Tex file
1. Press F1 to build and View
2. F11 To run the BibTex command (if you have
references in your file)
3. F6 for Compile
>>>> Lets compile our file
Tip:
If you just changed your database file,
it is recommended to remove the old .bib file of your manuscript before you continue.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli
.tex LaTeX or TeX input file. It can be compiled with latex.
.aux Usually stores information associated with cross-references.
.bbl Bibliography file output by BiBTeX and used by LaTeX
.bib Bibliography database file
.dvi Device Independent File. This is the main result of a LaTeX compile run with latex.
.tocStores all your section headers. It gets read in for the next compiler run and is used to produce the table of contents.
.lof This is like .toc but for the list of figures.
.lot And again the same for the list of tables.
.sty LaTeX Macro package. This is a file you can load into your LaTeX document using the \usepackage command.
.bst BiBTeX style file.
.cls Class files define what your document looks like.
16
LATEX Common File Formats
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli17
Latex Commands
\commandname[option1,option2,...]{argument}
Example:
\includegraphics[height=2in]{image1.eps}
18
Document class Options
Font size (10pt, 11pt, 12pt)
Paper size and format (a4paper, letterpaper, etc.)
Draft mode (draft)
Multiple columns (onecolumn, twocolumn)
More information available at http://texblog.org/2013/02/13/latex-documentclass-options-illustrated/
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli19
Example
\documentclass{article}
\documentclass{ieeetran}
\documentclass[onecolumn]{ieeetran}
\documentclass[draft]{ieeetran}
\documentclass[12pt,a4paper,oneside,draft]{report}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli20
Hands-on Practice 2
Make your article twocolumn
Change the font to 12pt
Change the paper to draft mode
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli21
Define the Title
\begin{document}
\title{Latex Tutorial}
By using this command, you will not be able to see the title. You have to ask Latex to build and show the title to you. But usually title includes some data about authors, name, affiliation, address, email and so on.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli22
Write the Authors Name
\author{Saeid Abolfazli}
Authors with Affiliation and address? \author{Saeid Abolfazli \\
University of Malaya} Run Latex
Still we cannot see the title. Right?
What is the next step?
Generating the title with all relevant informations
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli24
Define Abstract
\begin{abstract}
This is the paper's abstract (If any)
\end{abstract}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli25
Italic and Bold Fonts
If you wanna change the text to italic and bold, use
\textit{Italic}
\textbf{Bold}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli26
Defining Keywords
There is No tag for keywords,
we use Italic font
\textit{Keywords:} Latex Tutorial, Introduction to Latex, BibTex, University of Malaya
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli28
Sectioning of the tex file
Note: Latex is case Sensitive (meaning that do not use capslock)
\part
\chapter (report style only)
\section
\subsection
\subsubsection
\subsubparagraph (milstd and book-form styles only)
\subsubsubparagraph (milstd and book-form styles only)
Tip: using * makes the title to appear without numbering
\section{Section 1} 1. Section 1
\section*{Section 1} Section 1
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli29
Example
\section{Introduction}
\subsection{Motivation}
\subsubsection{Challenges in this section}
Help: If you forgot the sectioning order, you can use the menu bar
Latex-> …
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli31
Feed back
Do you think Latex is difficult?
If you use to it, you will love it.
Do practice from now please….
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli32
Bullet Lists in Latex
If you are interested to have bullet Items, you can use itemize environment.
\begin{itemize}
\item First Item
\item Second Item
\end{itemize}
Note: \item creates a default amount of indent.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli34
Numbered Lists in Latex
If you are interested to have bullet Items, you can use itemize environment.
\begin{enumerate}
\item First Item
\item Second Item
\end{enumerate}
Note: \item creates a default amount of indent.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli36
REST
Take a deep breath and rest for 5 minutes
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli37
Packages in LATEX
While writing your document, you will probably find that there are some areas where basic LaTeX cannot solve your problem. E.g., if you want to include graphics, colored text or source code from a file into your document, you need to enhance the capabilities of LaTeX. Such enhancements are called packages.
Packages are activated with the following command.
\usepackage[options]{package name}
For instance, \usepackage{graphicx} help you add images to your file. Without including this package, we can not insert pictures.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli38
Including jpg, png, pdf Graphics
You should use pdflatex compiler to insert these files
and include it in your text using graphicx package.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli39
1- Copy your file in your working directory where you have .tex file.
If not, you should provide full address while inserting figure
2- Use \usepackage{graphicx} before \begin{document} command.
3- Create a graphical environment by
\begin{figures}
commands
\end{figures}4-
Steps to include a graphic file
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli40
4-Use the following commands to insert your file
\includegraphics[options]{name}
Steps to include a graphic file
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli41
Use
\caption{This is an optional Text for Caption} for optional caption
Caption for Figures
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli42
Hands on Practice 6
Insert image 3 into your file
Put “My First Figure” as caption
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli43
Options for including graphics
\includegraphics[options]{name}
Example:\includegraphics{image1}\includegraphics[width=4in,height=3in]{image1}\includegraphics[scale=0.5, angle=90]{image1}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli44
Practice 7
Change height and width of figure to
height=0.09in,
width=0.9in
Change its scale to 0.7
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli45
A problem in Figures
Do you have this problem?
Placing figures where we want to appear
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli46
Placement Specifiers
We need to tell LaTex where to put our graphics. TO do so, the specifiers are used
You can mix few of these specifiers to make a better one.
I will explain more on 3rd day
Top of the page t
Button of the page b
Here h approximately at the same point it occurs in the source text , but not exactly at the point
Exactly here H Requires the float package, \usepackage{float}.
Override default parameters
! Override internal parameters LaTeX uses for determining "good" float positions
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli47
Placement Specifiers
Where to put specifiers?
\begin{figure} [placement specifier]
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli48
Hands-on Practice 8Insert a file named image1.jpg into your latex file. Command LaTex to keep your file in top section where there is space. Override internal parameters.
\begin{figure}[!ht]
\caption{This is my first Image}
\includegraphics{image1}
\end{figure}
Rotate image 90 degree
Resize image to half
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli49
Justifying a figure in the text
\centering
\begin{center} \end{center}
\begin{flushleft} \end{flushleft}
\begin{flushright} \end{flushright}
\begin{figure}[h!]
\centering
\includegraphics[width=0.5\textwidth]{image1}
\caption{A picture ….}
\end{figure}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli50
Hands-on Practice 9Create a document with following detail:
1- two-coloumn article
2- title: Hands-on Practice 9
3- Author: Your Name, My Name
4- Address and Affiliation: Your address and affiliation in 2 lines.
5- Abstract: Write 2 lines text as you wish
6- Define 5 keywords: Latex, Tutorial, Latex Workshop, Mobile Cloud Computing Research Group
7- Create the introduction section including 5 lines.
8- Define a figure environment
9- Extend the figure environment to two columns
10- Put your image on highest available space.
11- Define a caption: This is a good and complex practice
12- insert image1.eps into your tex file.
13- the files size should be 4*3 inches .
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli51
Including an eps File
- The best format of figures in LaTeX is eps which is a vector format.
- .eps (encapsulated post script) does not work with pdflatex
- You should change your compiling method
For .eps files to be successfully built, you have many solutions,
A) should use Latex interpreter as following (it is a default mode)
Go to Options Configure TexStudio Quick Build
Change the option to Latex+DviPS+Ps2PDF+pdf viewer
B)You can also use epstopdf package to use pdflatex
C) Use XeLaTex
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli52
Useful Tips
1- If you want to extend the image to two columns, you should use * while defining the figure environment.
\begin{figure*}
\caption{your diagram caption}
\end{figure*}
2- Use \listoffigures to add a list of the figures in the beginning of the document.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli53
REST and Practice for 15 minutes
Please do revise some of the topics we just learnt.
You can make the following practice
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli54
OpenOffice
Drawing layered architectures, diagram, and flowcharts are essential in majority of papers and thesis.
Apache OpenOffice is essential tool for designing such figures.
See how can we draw a flowchart
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli55
Draw This one using OpenOffice
This figure appeared in a paper accepted for publication in journal of IEEE Communication surveys and tutorials and follows copyright laws.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli56
Draw This one using OpenOffice
This figure appeared in a paper accepted for publication in journal of IEEE Communication surveys and tutorials and follows copyright laws.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli57
Selection and Exporting
Tips:
Always try to draw the figure in big scale
Shrinking the figure size does not reduce the quality, but increasing the size does.
When exporting the output, select the area you want to export. Make sure to click the selection only checkbox at the export window.
If you do export the file is very very big, the laTeX will be unable to resize it. If you saw such thing, just reduce the size.
Try to use true type font suggested by the publisher.
IEEE suggest times roman.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli58
Practice OpenOffice 1
Draw the following figures in OpenOffice
These figure appeared in a published paper in IEEE Mobcc’12 and follows copyright laws.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli59
Tables in Latex
1- Define a table Environment
\begin{tabular}[pos]{table spec}
\end{tabular}
POS argument specifies the vertical position of the table
b bottom
c center (default)
t top
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli60
Example
\begin{tabular}[b]{c c c c l l l r}
Means the table should be at top of the page, it has 8 columns with
4 centered, 3 left, and 1 right justified content.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli61
Table Specifications
\begin{tabular}[pos]{table spec}
\end{tabular}
table spec argument tells LaTeX the alignment to be used in each column and the vertical lines to insert.l left-justified column
c centered column
r right-justified column
p{width} paragraph column with text vertically aligned at the top
m{width} paragraph column with text vertically aligned in the middle (requires array package)
b{width} paragraph column with text vertically aligned at the bottom (requires array package)
| vertical line
|| double vertical line
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli62
Example
\begin{tabular}{c l r c l l l r}
Body
\end{tabular}
This example draws a table with 8 cols with different justifying.
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli63
Introducing the table content
Separating Cells, inserting new line.
& column separator
\\ start new row (additional space may be specified after \\ using square brackets, such as \\[6pt])
\hline horizontal line
\newline start a new line within a cell (in a paragraph column)
\cline{i-j} partial horizontal line beginning in column i and ending in column j
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli64
Hands-on Practice 9
Define a table as following:
Has 5 cells,
All are left justified,
The table is located on buttom of the page,
The table should be expanded to the width of two columns,
\begin{tabular}[b]{c c c}
No & Description & Buy & Sell & Profit \\ \hline
1 & Laptop & 1000 & 1500 & 500 \\ \hline\begin{table}[b]
\caption{caption 1}
\begin{tabular}[c]{|l | l | l | l |l |}\hline
No & Description & Buy & Sell & Profit \\ \hline
1 & Laptop & 1000 & 1500 & 500 \\ \hline
\end{tabular}
\end{table}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli65
Hands-on Practice 10
Draw the following table
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli66
\begin{tabular}[t]{c |c |c| c| c}
No & Description & Buy & Sell & Profit \\ \hline
1 & Laptop & 1000 & 1500 & 500 \\ \hline
2 & USB DISK & 100 & 150 & 50 \\ \hline
3 & Laptop & 1000 & 1500 & 500 \\ \hline
4 & USB DISK & 100 & 150 & 50 \\
\end{tabular}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli67
5 Min Break
Mathematical Equations in Latex
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli68
Simple math in LaTex
Use $ Formula $ to define short math block
Example:
X + Y $ X + Y $
X2 X_{2}
X4 X^2
(X2 + Y3)3 (X_{2} + Y_{3})^3
a
b \frac{a}{b}
a’ {a}’
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli69
a’’ {a}’’
\therefore
\sin \cos \tan \cot
Greek Letters: \alpha, \Alpha, \beta, \Beta, \gamma, \Gamma, \pi, \Pi, \phi, \varphi, \Phi
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli70
Hands-on Practice 11
Generate a code for following formula
$\alpha ^{3} + \Theta ^{5} = \gamma $
$ \sum_{x=0}^{10} X^2 + Y2 $
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli71
$\int_{a}^{b} Z^ \frac{x+y}{z+t} + \int_{c}^{d} \sqrt{\frac{x+y}{z+t}}$
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli72
Mathematical Equations in Latex
1. Include amsmath package. No need to use $
2. Create a math environment as following:
\begin{math}
Math codes here
\end{math}
3. Generate the math code and paste in math block.
\sum (X ^2 + Y^ 5)
Tip: Do not put any space between lines in code
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli73
It is very tedious to write the equations manually.
How easily generate complex math code?
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli74
Easy equation generation
It is boring and complicated to program for mathematic equations.
The best way is to use the following portal where you can easily type your formula and copy the code to the latex file.
http://www.codecogs.com/latex/eqneditor.php
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli75
Cross Referencing in LaTex
Once you created your sections, Tables, Figures, and Equations, you should be able to refer to them automatically. In order to do so, we use cross referencing.
1- Labeling entities (\label{name})
2- Referring to labeled entities (\ref{name})
\section{Introduction} \label{intro}
The remainder of this article is as follows: Section \ref{intro} describe….
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli76
Labeling Equations
If you need to number each formula and refer to them in tex you can use the following method.
\begin{eqation} \label{1}
C_{DA}=\sum_{i=1}^{n} C_{i}
\end{equation}
From (\ref{1}) we conclude that….
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli78
Relating authors and their affiliations using * or other symbols
\documentclass{article}
\begin{document}
\title{Latex Tutorial}
\author{Saeid \thanks{This paper is submitted }
\maketitle
\end{document}
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli79
Numbers instead of symbols?
Put this commands before \maketitle
\makeatletter
\let\@fnsymbol\@arabic
\makeatother
Prepare Scholarly Articles Using LATEX - By Saeid Abolfazli80
Troubleshooting Strange Errors in Latex.
Strange Errors: There are some cases that your commands are not executing and some strange error messages appear while you are sure that everything is fine. In this case, close the file, quit the application, remove all generated file except .bib and .tex files.
Open the .tex file and compile from the beginning. If not, try other error tracing approaches.