LaTeX Module
LaTeX Module
1 What is LaTeX
LaTeX, which is pronounced ’Lah-tech’ or ’Lay-tech’, is a document preparation
system for high-quality typesetting. It is most often used for medium-to-large
technical or scientific documents but it can be used for almost any form of pub-
lishing.
Open source
The source of LaTeX is completely free and readable for everyone. This enables
to study and to change everything from the core of LaTeX to the latest extension
packages. There’s a huge LaTeX community with a lot of friendly, helpful
people. Even it cannot benefit from the open source code directly, they can
read the sources and assist.
Portability
LaTeX is available for nearly every operating system such as Windows, Linux,
Mac OS X and many more. Its format is plain text - readable and editable, on
all systems.
LaTeX itself doesn’t have a graphical user interface; that’s one of the reasons
why it’s so portable. Can choose any text editor. There are many editors even
specialized in LaTeX, for every operating system.
LaTeX generates PDF output - printable and readable, on most computers and
looks identical regardless of the operating system. Besides PDF, it supports
2017
c LPSK, INSPEM, UPM 1
LATEX: An Introduction to Malaysian Academicians
DVI, PostScript, and HTML output, preparing the ground for distribution both
in print and online, on screen, electronic book readers, or smart phones.
LaTeX is for science, Word for general use (and even for that...) LaTeX makes
it very simple to handle equations, figures, bibliographies, indexes, etc. With
LaTeX you focus on the content of the document and let the program handle
how the output is formatted. LaTeX is more stable, especially if writing thesis
or reports. You can get enough details on Latex from net. A lot of user friendly
and easy to use interfaces are available. If you want to write a paper with LaTeX
you can start from a template like this below.
\begin{document}
\maketitle
2017
c LPSK, INSPEM, UPM 2
LATEX: An Introduction to Malaysian Academicians
\section{Introduction}
Write the introduction here...
\section{Conclusions}
The conclusions are here...
\end{document}
2 Getting started
General parts
The latex code consists of two general parts:
1. The preamble consists of the parameters for the document, i.e. the mar-
gins, the font, the spacing, the document type, supplementary packages,
2017
c LPSK, INSPEM, UPM 3
LATEX: An Introduction to Malaysian Academicians
etc. Some Latex commands require the use of a package defined in the
preamble.
2. The body contains the text, figures, tables, etc.
\begin{document}
First document. This is a simple example, with no
extra parameters or packages included.
\end{document}
The first line of code declares the type of document, in this case is a arti-
cle. Then enclosed in the \begin{document}...\end{document} tags you must
write the text of your document.
\title{First document}
\author{Hubert Farnsworth \thanks{funded by the ShareLaTeX team}}
\date{February 2014}
Below a detailed description of each line:
2017
c LPSK, INSPEM, UPM 4
LATEX: An Introduction to Malaysian Academicians
The next three lines are self-descriptive. Anyway, you can see a descrip-
tion about what they actually do in the next section. Another important
parameter that can be passed to the \documentclass command is twocol-
umn if you want your text in a two-column format and twoside for two-side
paper sheet printing.
\title{First document}
\author{Hubert Farnsworth \thanks{funded by the ShareLaTeX team}}
\date{February 2014}
\begin{document}
\begin{titlepage}
\maketitle
\end{titlepage}
\end{document}
2017
c LPSK, INSPEM, UPM 5
LATEX: An Introduction to Malaysian Academicians
Figure 1: There is a block with three lines in the preamble that define what
information is going to be included in the title page.
1. \title{First document}
This is the title.
2. \author{Hubert Farnsworth}
Here you put the name of the Author(s) and, as a optional parameter,
you can add the next command:
3. \thanks{funded by the ShareLaTeX team}
This can be added after the name of the author, inside the braces of the
title command. It will add a superscript and a footnote with the text inside
the braces. Useful if you need to thank an institution in your article.
4. \date{February 2014} You can enter the date manually or use the com-
mand October 30, 2017so the date will be updated automatically at the
time you compile your document. Once you have that in the preamble
now in the body of your document you can use the next commands for
the information to be printed.
2017
c LPSK, INSPEM, UPM 6
LATEX: An Introduction to Malaysian Academicians
5. \begin{titlepage} \end{titlepage}
This declares an environment, a block of code with a specific behaviour
depending on its type. In this case whatever you include in this titlepage
environment will appear in the first page of your document.
6. \maketitle
This command will print the title, the author and the date in the format
shown in the example. If it’s not enclosed in a titlepage environment, it
will be shown at the beginning of the document, above the first line.
\begin{document}
\begin{abstract}
This is a simple paragraph at the beginning of the
document. A brief introduction about the main subject.
\end{abstract}
\end{document}
Abstract
This is a simple paragraph at the beginning of the document. A
brief introduction about the main subject.
In this document some extra packages and parameters were added. There
is a encoding package an a pagesize and fontsize parameters. This line will
start a second Paragraph. And I can brake
the lines
and continue in a new line.
2017
c LPSK, INSPEM, UPM 7
LATEX: An Introduction to Malaysian Academicians
When writing the contents of your document, if you need to start a new
paragraph you must hit the ”Enter” key twice (to insert a double blank line).
Notice that paragraphs have a white space before the first line.
To start a new line without actually starting a new paragraph insert a break
line point, this can be done by \\ (a double backslash as in the example) or the
\newline command
Comments
Sometimes it’s necessary to add comments to your LaTeX code for readability.
This is straightforward, put a % before the comment and LaTeX will ignore that
text.
\documentclass{article}
\usepackage[utf8]{inputenc} %codification of the document
\usepackage{comment}
%Here begins the body of the document
\begin{document}
This documents contains a lot of comments, none of them
will appear here, only this text.
\begin{comment}
This text won’t show up in the compiled pdf
this is just a multi-line comment. Useful
to, for instance, comment out slow-rendering
while working on the draft.
\end{comment}
\end{document}
2017
c LPSK, INSPEM, UPM 8
LATEX: An Introduction to Malaysian Academicians
3 About MiKTeX
MiKTeX (pronounced mick-tech) is an up-to-date implementation of TeX/La-
TeX and related programs for Windows (all current variants). It is very easy to
install MiKTeX. The MiKTeX Setup Wizard guides you through the installation
process. You don’t have to be a computer expert. A complete set of additions
(programs, styles, fonts, . . . ) are available to help you typeset your documents.
MiKTeX’s integrated package manager installs missing components from the
Internet, if required. For example, the LaTeX directive \usepackage{memoir}
would trigger the installer, if the memoir package is not already installed. This
unique feature allows you to keep your computer clutter-free: only install pack-
ages you actually need. The MiKTeX Update Wizard helps you to keep your
MiKTeX system up-to-date by installing the latest package updates. The TeX
output viewer Yap allows for an optimized edit-compile-view cycle (if the TeX
authoring system in use supports source specials). The MiKTeX package repos-
itory is updated regularly. MiKTeX is open source. Users are welcome to re-
distribute MiKTeX under certain conditions. Further information on MiKTeX
can be obtained from https://miktex.org/.
Figure 2: Read the text carefully and click ”I accept the MiKTeX copying
conditions”, click ”Next”, to go to the next page.
2017
c LPSK, INSPEM, UPM 9
LATEX: An Introduction to Malaysian Academicians
Shared installation
Create the option to shared MiKTeX installation. Use this Option, if you are
the Administrator (of your Computer) and if you want to install MiKTeX for all
users (this Option is not available, if you are logged into a limited user account).
Click ”Anyone who uses this Computer (all users), if you want to install MiK-
TeX for all users.
Click ”Only for ...”, if you want to install MiKTeX for yourself only.
2017
c LPSK, INSPEM, UPM 10
LATEX: An Introduction to Malaysian Academicians
Installation directory
Make the option to specify the MiKTeX installation directory:
2017
c LPSK, INSPEM, UPM 11
LATEX: An Introduction to Malaysian Academicians
Settings
It also have the option to change the default behavior of the integrated package
manager for the case where a required package is missing. Select ”Ask me
first”, if the package manager shall ask for permission. Select ”Always”, if the
package manager is always allowed to install missing packages. Select ”Never”,
if disallow the installation of missing packages. All these preferences can be
changed later.
Figure 8: The installer allows to set the preferred paper size. Click ”Next” to
go to the next page
2017
c LPSK, INSPEM, UPM 12
LATEX: An Introduction to Malaysian Academicians
Review
Before the actual installation process begins, get a chance to review your deci-
sions.
Figure 9: If satisfied with the settings, then click ”Start” to start the actual
installation.
Installation Process
The installation will take a few minutes. The progress bar shows an approximate
percentage of completion.
Figure 10: When the installation has finished, click ”Next” to open the last
page.
2017
c LPSK, INSPEM, UPM 13
LATEX: An Introduction to Malaysian Academicians
Finish
MiKTeX is now installed. The installation also includes the TeXworks editor.
After installed MiKTeX, it is recommended that you run the update wizard in
order to get the latest updates.
5 LaTeX distributions
The styles, contents and layout in a LaTeX document are defined by means
of tags or commands in a plain .tex file, this file can be used to generate the
”human-readable” version of the document to PDF output format.
The set of programs that make possible to compile TeX and LaTeX documents
is called a TeX typesetting or distribution. There are many TeX distributions
available for different operating systems:
• MiKTeX for Windows
• TeX Live for Linux and other UNIX-like systems
• MacTeX redistribution of TeX Live for Mac OS X
• teTeX for Linux and other UNIX-like systems, now is no longer actively
maintained
• proTeXt is based on MiKTeX
6 LaTeX Editors
There are many advanced text editors specifically dedicated to LaTeX for the
most popular operating systems, some of them can be downloaded for free while
2017
c LPSK, INSPEM, UPM 14
LATEX: An Introduction to Malaysian Academicians
TeXworks features many of the key capabilities of a LaTeX editor like auto-
completion, auto-correction, Unicode support and more. If only the basic bare
bones of a LaTeX editor is required, It ticks in all the boxes perfectly. This tool
although does not feature many of the key features, its minimalistic approach to
LaTeX editing gets the work done without fussing much about its functionali-
ties. Code folding, Insertion of graphics/tables, interaction with external editors
and its powerful built-in PDF viewer and exporter makes this tool one of the
best LaTeX editors that the academia often tend to consider.
• Key Features: Code folding, auto-completion, auto-correction, Unicode
support and built-in PDF viewer.
• Platforms Supported: Windows, Mac OS X and Linux.
• Official Website: https://www.tug.org/texworks/
2017
c LPSK, INSPEM, UPM 15
LATEX: An Introduction to Malaysian Academicians
TeXmaker
Once the groundwork of your document layout is set up using TeXmaker, the
document can now be compiled to get it extracted as a PDF, HTML or ODF
file format. Another key feature of TeXmaker is the way it allows users to track
errors during the compilation stage. All warnings and errors are displayed to let
the user take the needed action regarding the same. Parts/sections of your doc-
uments could be easily folded/unfolded using TeXmaker. This tool is also great
for creating a structured Bibliography section of your document. Keyboard
short-cuts are abundant for TeXmaker and it makes the overall experience with
this tool pretty worthwhile.
• Key Features: Unicode support, Code folding, Spell-checking, Built-in
PDF viewer, Auto-completion, 370 mathematical symbols and more.
• Platforms Supported: Windows, Mac OS X and Linux.
2017
c LPSK, INSPEM, UPM 16
LATEX: An Introduction to Malaysian Academicians
ShareLaTeX
If all of the above tools do not interest you in trying out LaTeX editors, here
is one that doesn’t need any kinds of installations on your local device. Share-
LaTeX takes all of your LaTeX document editing tasks online and now you can
edit your documents right from your web browser. One of its key features is the
400 templates that come built-in with it. Among these templates are Techni-
cal paper layouts, Scientific magazine articles, CV and more. You can simply
choose one such layout and get started on editing your content without worrying
much about the formatting associated with it.
2017
c LPSK, INSPEM, UPM 17
LATEX: An Introduction to Malaysian Academicians
Overleaf
Another great online LaTeX editing tool is Overleaf. Trusted by over 200,000
academia worldwide, Overleaf is a great LaTeX editing tool with all the fea-
tures that make your document creations easy. Overleaf comes with over 100’s
of templates ranging from Lab report and Thesis to Resume/CV and formal let-
ters. If starting over fresh isn’t something you’d consider, getting started with
one of their many templates is an easy way to develop professionally formatted
documents.
Among the key features of Overleaf are the ability to collaborate with your
team members on technical papers or academia documents. This real-time col-
laboration brings transparency to the editing work that is being put in by all the
authors involved in its development. Your final document could easily be shared
to different social networks and Git account using your custom generated link.
Make this link as ‘Read-only’ or ‘Read-and-Write’ depending on the person you
are sharing the document with. Mathematical formulae insertion is one of the
important aspects of LaTeX editors and Overleaf provides a real-time preview
of your text as it gets entered. Its Error control and Notation support makes
co-authors familiar with WYSIWIG editors easily take up to this tool.
2017
c LPSK, INSPEM, UPM 18
LATEX: An Introduction to Malaysian Academicians
8 LaTeX Environments
Environments are used to format blocks of text in a LaTeX document. A LaTeX
document of any style (article, letter or report) starts (right after the preamble)
with the tag \begin{document} and ends with \end{document} which serves
as the overall environment of the document.
2017
c LPSK, INSPEM, UPM 19
LATEX: An Introduction to Malaysian Academicians
Defining Environments
Environments are delimited by an opening tag \begin and a closing tag \end.
Everything inside those tags will be formatted in a special manner depending
on the type of the environment.
Example
\begin{tabular}{ c c c }
cell1 & cell2 & cell3 \\ cell1 cell2 cell3
cell4 & cell5 & cell6 \\ cell4 cell5 cell6
cell7 & cell8 & cell9 \\ cell7 cell8 cell9
\end{tabular}
2017
c LPSK, INSPEM, UPM 20
LATEX: An Introduction to Malaysian Academicians
\begin{center}
This text will be centred
since it’s inside a special This text will be centred since it
environment. is inside a special environment.
Environments provide a Environments provide a efficient
efficient way of modifying way of modifying blocks of text
blocks of text within your within your document.
document.
\end{center}
The centering environment is also used for the same purpose. centering
is commonly used to centre align something that is already vertically positioned
such as a figure. Whereas, center is used to implement a displayed construct
that happens to need centred content. The use of centering will be illustrated
in a figure environment example in this section.
The figure environment using the includegraphics utility from graphicx
package is used to insert figures in a document.
\begin{figure}
\centering
\includegraphics[scale=0.05]
{google}
\caption{Google} Figure 16: Google
\label{fig:google}
\begin{quotation}
The quote and quotation
environments are similar, but The quote and quo-
use different settings for tation environments
paragraph indentation and are similar, but use
spacing. different settings for
paragraph indentation
\em When in doubt, consult and spacing.
the manual. When in doubt,
\end{quotation} consult the manual.
2017
c LPSK, INSPEM, UPM 21
LATEX: An Introduction to Malaysian Academicians
The itemize environment sets off list items with ”bullets” like this:
\begin{itemize}
\item Javascript
\item HTML • Javascript
\end{itemize} • HTML
\begin{enumerate}
\item Javascript
\item HTML 1. Javascript
\end{enumerate} 2. HTML
The tabular environment is used to display tables and the center environment
is used to display the table properly in the center such as:
\begin{center}
Numbers of Programmers:
\begin{tabular}{lr} Numbers of Programmers:
C++&175\\ C++ 175
Python&60\\ Python 60
Java&110\\ Java 110
\end{tabular}
\end{center}
Unique Features:
\begin{description} Unique Features:
\item[C++] Speed
C++ Speed
\item[Python] Flexsible
\end{description} Python Flexible
2017
c LPSK, INSPEM, UPM 22
LATEX: An Introduction to Malaysian Academicians
\begin{verbatim}
/*The Parallel Hello World
Program*/ /*The Parallel Hello
#include <stdio.h> World Program*/
#include <mpi.h> #include <stdio.h>
main(int argc, char **argv) #include <mpi.h>
{ main(int argc, char **argv)
int node; {
MPI_Init(&argc,&argv); int node;
MPI_Comm_rank(MPI_COMM_WORLD, MPI_Init(&argc,&argv);
&node); MPI_Comm_rank(MPI_COMM_WORLD,
printf("Hello World from Node &node);
%d\n",node); printf("Hello World from Node
MPI_Finalize(); %d\n",node);
} MPI_Finalize();
\end{verbatim} }
Using table and tabular environments, we can create tables and position
it.
Note the use of float [H] for table to fix the position of the table.
2017
c LPSK, INSPEM, UPM 23
LATEX: An Introduction to Malaysian Academicians
r !
x+1
z 1 + ωi+1 + ζ − y+1 = 1
Θ+1
" N
#
X
X + a ≥ â lim δC (1)
x→k
i
2017
c LPSK, INSPEM, UPM 24
LATEX: An Introduction to Malaysian Academicians
To typeset several equations together and have them properly aligned, use
the align environment:
The equations are aligned along the & and each line is terminated by \\. To
suppress the equation numbering (i.e. if the equations won’t be referred to) use
align* instead of align.
Piecewise functions may be defined using the cases environment from the
amsmath package:
\[ f(x) = \begin{cases}
0 & x\leq 0 \\
\frac{100-x}{100} & 0\leq x\leq 100 \\
0 & 100\leq x
\end{cases}
\]
0
x≤0
100−x
f (x) = 0 ≤ x ≤ 100
100
0 100 ≤ x
9 LaTeX Commands
LaTeX typesetting is made by using special tags or commands that provide a
handful of ways to format your document. Sometimes standard commands are
not enough to fulfill some specific needs, in such cases new commands can be
defined. Most of the LaTeX commands are simple English words preceded by a
special character.
A word of caution, LaTeX typesetting uses the American English spelling,
thus please be sure to use the correct spelling. Commands written using British
English spelling will not be run as LaTeX is spelling sensitive and this would
result in error. For instance, to centre align a content, we would use center
and not centre.
2017
c LPSK, INSPEM, UPM 25
LATEX: An Introduction to Malaysian Academicians
In the above example there are different types of commands. For instance,
\textbf will make boldface the text passed as parameter to the command.
In mathematical mode ($...$) there are special commands to display Greek
characters such alpha, beta and gamma.
We may insert cross-references to numbered elements such as equations,
sections and figures in our document with ref and label commands in LaTeX.
The command label{ } is used to set an identifier that is later used in the
command ref{ } to set the reference. Additionally, we can insert the page
where these labels to be referenced appear using pageref command. For an
example, we have labelled this section (LaTeX Commands) as commands; the
Google figure as fig:google and the first mathematical equation on page 24 as
eq:1.
2017
c LPSK, INSPEM, UPM 26
LATEX: An Introduction to Malaysian Academicians
# $ % ^ & _ { } ~ \
All of these apart from the backslash \ can be inserted as characters in your
document by adding a prefix backslash:
\# \$ \% \^{} \& \_ \{ \} \~{}
Note that you need to type a pair of curly brackets {} after the hat ˆ and
tilde ˜, otherwise these will appear as accents over the following character. For
example, \^e will produce ê.
The backslash character \ can not be entered by adding a prefix of another
backslash \\, as this is used for line breaking. Use the \backslash command
instead.
2017
c LPSK, INSPEM, UPM 27
LATEX: An Introduction to Malaysian Academicians
,;. ? ! : ’ ’ -
and the spacebar, and Return (or Enter) key.There are thirteen special keys
that are mostly used in LaTeX instructions are reserved character which have
a special meaning. These symbols are:
\#”$%&@|ˆ {}˜
If you need to use them in your document, you will need to precede them
with a \. The only time this will not work is in the case of the backslash itself
since \\ is the command to create a new line. For examples, to put a \ in your
document you must type $\backslash$ , $ is typed as \$, the underscore ( ) is
typed as \ and % is typed as \%, whereas ä is typed as \”{a} and @ is simply
typed @.
In a LaTeX source file, each comment line begins with %. LaTeX willl ignore
everything on the line after the % character.
2017
c LPSK, INSPEM, UPM 28
LATEX: An Introduction to Malaysian Academicians
large ones.
\end{center}
Your lines can have small spaces between them, or large ones.
In addition you can use the \vspace {enter space here} command to set the
space lines to whatever you like. For example, \vspace{.75in} will leave .75
inches of blank space in your text. If vertical space is requested in the middle of
a paragraph, the space will appear after the current line has ended like below:
\begin{center}
These lines have a\\
\vspace{.75in} \$.75\$ inch space between them.
\end{center}
2017
c LPSK, INSPEM, UPM 29
LATEX: An Introduction to Malaysian Academicians
Command Declaration
\textbf \bfseries Boldface text
\textit \itshape Italic text
\textsl \slshape Slanted text
\underline \uline Underlined text
\textsc \scshape SMALL CAPS
\textup \upshape Upright text
\emph \em Emphasized text
\textrm \rmfamily Times New Roman
\texttt \ttfamily Typewriter
\textsf \sffamily Sans Serif
\tiny Tiny font size
2017
c LPSK, INSPEM, UPM 30
LATEX: An Introduction to Malaysian Academicians
By default, in standard LaTeX classes the serif typeface (a.k.a. roman) font is
used. You can set up the use of sans font as a default in LaTeX document by
using the command:
\renewcommand{\familydefault}{\sfdefault}
Note that the font size definitions are set by the document class. Depending
on the document style the actual font size may differ from that listed below.
And not every document class has unique sizes for all 10 size commands. Table
3 below lists the absolute point sizes in the article, proc, report, book, and letter.
Please note that the absolute point sizes in LaTeX and Ms Word may not be
the same. For example, 12pt in LaTeX is not equivalence to 12pt in Ms Word.
MS Word uses a slightly different version of the unit ”point” (pt) than LaTeX
does. The 12 point of Ms Word will be PostScript point, which in LaTeX would
be called 12bp. A LaTeX pt is slightly smaller: it’s 1/72.27 inch, while a bp
\PostScript point is 1/72 inch. The difference in width is around 0.04pt and
0.03pt in height, which translates to about 0.01mm - a roughly 0.3% increase.
This is virtually negligible to the naked eye at regular font sizes. In order to get
the output looks like what we get in the MS Word documents with Times New
Roman 12pt, the commands are stated below:
\documentclass[12pt]{article}
\usepackage{tgtermes} %times font
\begin{document}
\end{document}
2017
c LPSK, INSPEM, UPM 31
LATEX: An Introduction to Malaysian Academicians
Environments
Itemize, Enumerate and Desription
The itemize environments is suitable for simple lists, the enumerate environ-
ment for enumerated lists, and the descriptions environment for descriptions.
\flushleft
\begin{enumerate}
\item You can nest the 1. You can nest the list
list environment to your taste: environment to your taste:
\begin{itemize} • But it might start to
\item But it might start to look look silly.
silly.
\item[-] With a dash. - With a dash.
\end{itemize} 2. Therefore remember:
\item Therefore remember:
\begin{description} Stupid things will not
\item[Stupid] things will not become smart because
become smart because they are in they are in a list.
a list. Smart things, though, can
\item[Smart] things, though, can be be presented beautifully
presented beautifully in a list in a list
\end{description}
\end{enumerate}
2017
c LPSK, INSPEM, UPM 32
LATEX: An Introduction to Malaysian Academicians
to the right,
to the left,
There are two similar environments: the quotation and the verse envi-
ronments. The quotation environment is useful for longer quotes going over
several paragraphs, because it indents the first line of each paragraph. The
verse environment is useful for poems where the line breaks are important.
The lines are seperated by issuing a \\ at the end of a line and an empty line
after each verse.
2017
c LPSK, INSPEM, UPM 33
LATEX: An Introduction to Malaysian Academicians
11 Tables
The Tabular Environment
Used to typeset beautiful tables with optional horizontal and vertical lines. La-
TeX determines the width of the columns automatically. To construct a table,
start with :
\begin{tabular}[pos]{table spec}
• ”table spec” tells LaTeX the alignment to be used in a column and the
vertical lines to insert.
• ”pos” is used to specify the vertical position of the table relative to the
baseline of the surrounding text, e.g.
– h insert the table where the code is
– b insert the table at the bottom of the page (if space is available)
– t insert the table at the top of the page (if space is available), and
– p insert the table at the end of the document on a separate page
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
The width necessary for each column is determined automatically from the
widest entry. Inside the tabular environment, use the tab character (&) to
move to the next column, && to end each line (except the last one) and \hline
to insert the horizontal line.
Standard Table
You can insert very nice looking tables into your document using LaTeX. To
insert a table into a LaTeX document, you must enter the table environment,
then define your table as required, using tabular environment. Table 5 is a
2017
c LPSK, INSPEM, UPM 34
LATEX: An Introduction to Malaysian Academicians
sample of a basic table which can be created in LaTeX using few commands
below:
The tabular environment acts much like the array math environment, and
the | character instructs LaTeX to draw a vertical line between columns. You
can use the \hline command to draw horizontal lines. Here are the commands
used to create the table below:
\begin{table}
\begin{center}
\begin{tabular}{|l|c|r|} %3 columns (left, center, right);
vertical lines
\hline % draw horizontal line
Name & Oblateness & Diameter \\ \hline
Mercury & 0 & 3,100 \\
Venus & 0 & 7,700 \\
Earth & 1/297 & 7,927 \\
Mars & 1/192 & 4,200 \\
Jupiter & 1/15 & 88,700 \\
Saturn & 1/9.5 & 75,100 \\
Uranus & 1/14 & 32,100 \\
Neptune & 1/40 & 27,700 \\
Pluto & 0 & 3,600\\ \hline
\end{tabular}
\end{center}
\end{table}
2017
c LPSK, INSPEM, UPM 35
LATEX: An Introduction to Malaysian Academicians
\multicolumn{n}{pos}{item}
2017
c LPSK, INSPEM, UPM 36
LATEX: An Introduction to Malaysian Academicians
\begin{table}[h]
\caption{Sample Table Using Column Headings} \label{Table}
\begin{center}
\begin{tabular}{l c c c| c c c} &
\multicolumn{3}{c}{\textbf{Strong Actor}} & \multicolumn{3}{c}
{\textbf{Weak Actor}} \\
\cline{2-7}
\textbf{} & Inter & Intra & Extra & Inter & Intra & Extra \\
\hline
\textbf{Total} & 23 (55\%) & 7 (64\%) & 77 (76\%) & 19 (45\%) &
4 (36\%) & 24 (4\%)\\
\textbf{Pre-1950} & 15 (55\%) & 3 (100\%) & 74 (81\%) & 12 (45\%)
& 0 (0\%) & 18 (19\%)\\
\textbf{Post-1950} & 8 (53\%) & 4 (50\%) & 3 (33\%) & 7 (47\%)
& 4 (50\%) & 6 (67\%)\\
\hline
\end{tabular}
\end{center}
\end{table}
2017
c LPSK, INSPEM, UPM 37
LATEX: An Introduction to Malaysian Academicians
\usepackage{rotating}
Column 333
Column 22
Column 1
...
\begin{tabular}{|l|l|l|}
\hline
\multicolumn{1}{|c|}{
\begin{sideways} aa bbbb cccc
Column 1 \, aaa bbbb cccc
\end{sideways}}& aaaa bbbb cccc
\multicolumn{1}{c|}{ aaaaa bbbb cccc
\begin{sideways} aaaaaa bbbb cccc
Column 22 \,
\end{sideways}}&
\multicolumn{1}{c|}{
\begin{sideways}
Column 333 \,
\end{sideways}} \\\hline
aa & bbbb & cccc \\\hline
aaa & bbbb & cccc \\\hline
aaaa & bbbb & cccc \\\hline
aaaaa & bbbb & cccc \\\hline
aaaaaa & bbbb & cccc \\\hline
\end{tabular}
Sideways
The most versatile way to turn a table sideways is to use the sideways envi-
ronment from the rotate package.
\usepackage{rotating}
1,2
2,2
3,2
4,2
5,2
6,2
7,2
8,2
9,2
...
\begin{sideways}
1,1
2,1
3,1
4,1
5,1
6,1
7,1
8,1
9,1
\begin{tabular}{|l|l|}
\hline
1,1 & 1,2\\ \hline
2,1 & 2,2\\ \hline
3,1 & 3,2\\ \hline
4,1 & 4,2\\ \hline
4,1 & 4,2\\ \hline
5,1 & 5,2\\ \hline
6,1 & 6,2\\ \hline
7,1 & 7,2\\ \hline
8,1 & 8,2\\ \hline
9,1 & 9,2\\ \hline
\end{tabular}
\end{sideways}
2017
c LPSK, INSPEM, UPM 38
LATEX: An Introduction to Malaysian Academicians
Footnotes in Tables
A footnote is a non-floating longtable or tabulary table is put with any normal
page footnotes at the end of the page containing the table.
Footnotes can be kept next to their table by using a minipage to hold the
table. Each minipage has its own disjoint footnote counter, and uses alphabetic
lower case footnote marks. This method does not work for tabulary, but it can
be used with floating tables. The following is a tabular example:
2017
c LPSK, INSPEM, UPM 39
LATEX: An Introduction to Malaysian Academicians
2017
c LPSK, INSPEM, UPM 40
LATEX: An Introduction to Malaysian Academicians
\includegraphics[scale=1.2, angle=45]{figure.here}.
The parameter angle=45 rotates the picture 45 degrees counter-clockwise. To
rotate the picture clockwise use a negative number.
Positioning
In the previous section was explained how to include images in your document,
but the combination of text and images may not look as we expected. To change
this we need to introduce a new environment. The figure environment is used
to display pictures as floating elements within the document. This means you
include the picture inside the figure environment and you don’t have to worry
about it’s placement, LaTeX will position it in a such way that it fits the flow
of the document.
Anyway, sometimes we need to have more control on the way the figures
are displayed. An additional parameter can be passed to determine the fig-
ure positioning. In the example, begin{figure}[h], the parameter inside the
brackets set the position of the figure to here. Below a table to list the possible
positioning values.
Parameter Position
h Place the float here, i.e., approximately at the same point it occurs in the source text
t Position at the top of the page.
b Position at the bottom of the page.
p Put on a special page for floats only.
! Override internal parameters LaTeX uses for determining ”good” float positions.
In the next example you can see a picture at the top of the document, despite
being declared below the text.
The additional command \centering will centre the picture. The default
alignment is left. It’s also possible to wrap the text around a figure. When the
document contains small pictures this makes it look better. For the commands
in the example to work, you have to import the package wrapfig. Add to the
preamble the line \usepackage{wrapfig}.
Now you can define the wrapfigure environment by means of the commands
\begin{wrapfigure}{l}{0.25\textwidth}\end{wrapfigure}.
Notice that the environment has two additional parameters enclosed in braces.
Below the code is explained with more detail:
{l}
This defines the alignment of the figure. Set l for left and r for right. Fur-
thermore, if you are using a book or any similar format, use instead o for the
outer edge and i for the inner edge of the page.
{0.25\textwidth}
This is the width of figure box. It’s not the width of the image itself, that
must be set in the includegraphics command. Notice that the length is relative
to the text width, but normal units can also be used (cm, in, mm, etc).
2017
c LPSK, INSPEM, UPM 41
LATEX: An Introduction to Malaysian Academicians
Captions
It’s really easy, just add the\caption{Some caption} and inside the braces
write the text to be shown. The placement of the caption depends on where
you place the command; if it’a above the includegraphics then the caption will
be on top of it, if it’s below then the caption will also be set below the figure.
Captions can also be placed right after the figures. The sidecap package
uses similar code to the one in the previous example to accomplish this. There
are two new commands
\usepackage[rightcaption]{sidecap}
As you may expect this line will import a package named sidecap, but there
is an additional parameter: rightcaption. This parameter establishes the place-
ment of the caption at the right of the picture, you can also use leftcaption.
In book-like documents outercaption and innercaption are also available. The
names of these are self-descriptive.
\begin{SCfigure}[0.5][h] \end{SCfigure}
Defines an environment similar to figure. The first parameter is the width of
the caption relative to the size of the image, as declared in includegraphics. The
second parameter h works exactly as in the figure environment. See the place-
ment section for more information. You can do a more advanced management
of the caption formatting. Check the further reading section for references.
\label{fig:mesh1}
This will set a label for this figure. Since labels can be used in several types of
elements within the document, it’s a good practice to use a prefix, such as fig:
in the example.
\ref{fig:mesh1}
This command will insert the number assigned to the figure. It’s automatically
generated and will be updated if insert some other figure before the referenced
one.
2017
c LPSK, INSPEM, UPM 42
LATEX: An Introduction to Malaysian Academicians
\pageref{fig:mesh1}
This prints out the page number where the referenced image appears. The
\caption is mandatory to reference a figure.
Another great characteristic in a LaTeX document is the ability to auto-
matically generate a list of figures. This is straightforward.
\listoffigures
This command only works on captioned figures, since it uses the caption in the
table. The example above lists the images in this article. Important Note: When
using cross-references your LaTeX project must be compiled twice, otherwise
the references, the page references and the table of figures won’t work.
13 Colours in LaTeX
When writing any things, colour is one important method to highlights some
important messages from the writer to the reader. Colour in computer in the
term of RGB (Red, Green and Blue). LaTeX is same like other word processing
software, its also got method how to do regarding colour. Colouring the text
may involve colour box such as INSPEM .
\documentclass[]{article}
\usepackage{graphicx}
\usepackage{color}
\usepackage{xcolor}
...
...
...
This package provides both foreground and background for colour manage-
ments and use device driver for configuration mechanism of the graphics package
to determine how to control the output. Here is the web site link regarding the
Color package, https://ctan.org/pkg/color?lang=en
This is Blue
This is \textcolor{blue}{Blue}
This example shows different examples on how to use the color package to
change the colour of elements in LaTeX.
2017
c LPSK, INSPEM, UPM 43
LATEX: An Introduction to Malaysian Academicians
• First item
• Second item
This example shows different examples on how to use the \texttt{color} package
to change the colour of elements in LaTeX.
\begin{itemize}
\color{blue}
\item First item
\item Second item
\end{itemize}
\noindent
{\color{red} \rule{\linewidth}{0.5mm} }
This example shows different examples on how to use the color package to
change the colour of elements in LaTeX.
• First item
• Second item
The background colour of some text can also be easily set. For instance, you
can change to orange the background of this text and then continue typing.
14 Mathematical Equations
There are many ways how to write equations in LaTeX. In this section we wil
show you the commands but at the end we will recommend the user using only
one command to present other commands available for LaTeX. A few rules about
writing equations are
2017
c LPSK, INSPEM, UPM 44
LATEX: An Introduction to Malaysian Academicians
15 Delimiters
See how the delimiters are of reasonable size in these examples:
\[ \left(a+b\right)
\left[1-\frac{b}{a+b}\right]=
a\] b
(a + b) 1 − = a,
\[\sqrt{|xy|}\leq\left| a+b
\frac{x+y}{2}\right| \]
p x + y
|xy| ≤ ,
2
\[ \int_a^bu\frac{d^2v}{dx^2}\,
dx=\left.u\frac{dv}{dx}\right| b Z b
b
d2 v
Z
_a^b-\int_a^b\frac{du}{dx} dv du dv
\frac{dv}{dx}\,dx.\] u dx = u − dx.
a dx2 dx a a dx dx
16 Spacing
Differentials often need a bit of help with their spacing as in:
2017
c LPSK, INSPEM, UPM 45
LATEX: An Introduction to Malaysian Academicians
\[\iint xy^2\,dx\,dy =
\frac{1}{6}x^2y^3,\] ZZ
1 2 3
xy 2 dx dy = x y ,
6
\[
u=\frac{-y}{x^2+y^2}\,,\quad
v=\frac{x}{x^2+y^2}\,, −y x
u= , v= , w = 0.
\quad w=0\,. x2
+ y2 x2 + y2
\]
Occasionally one gets horrible line breaks when using a list in mathematics
such as listing the first twelve primes 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 . In
such cases, perhaps include \mathcode‘\,="213B inside the inline maths envi-
ronment so that the list breaks: 2 , 3 , 5 , 7 , 11 , 13 , 17 , 19 , 23 , 29 , 31 , 37 . Be
discerning about when to do this as the spacing is different.
17 Arrays
Arrays of mathematics are typeset using one of the matrix environments as in:
\[
\begin{bmatrix}
1 & x & 0 \\ 1
1 x 0 1 + xy
0 & 1 & -1 y = .
0 1 −1 y−1
\end{bmatrix} 1
\begin{bmatrix}
1 \\ y \\ 1
\end{bmatrix}
=\begin{bmatrix}
1+xy \\ y-1
\end{bmatrix}.
\]
\[ \]
|x|=\begin{cases}
x, & \text{if }x\geq 0\,,
\\ -x, & \text{if }x< 0\,.
\end{cases}
2017
c LPSK, INSPEM, UPM 46
LATEX: An Introduction to Malaysian Academicians
(
x, if x ≥ 0 ,
|x| =
−x, if x < 0 .
2017
c LPSK, INSPEM, UPM 47
LATEX: An Introduction to Malaysian Academicians
2017
c LPSK, INSPEM, UPM 48
LATEX: An Introduction to Malaysian Academicians
\[
\begin{matrix}
-2 & 1 & 0 & 0 & \cdots & 0 −2 1 0 0 ··· 0
\\ 1 −2 1 0 ··· 0
1 & -2 & 1 & 0 & \cdots & 0 0 1 −2 1 ··· 0
\\ .. ..
0 0 1 −2 . .
0 & 1 & -2 & 1 & \cdots & 0 .. .. .. .. ..
\\ . . . . . 1
0 & 0 & 1 & -2 & \ddots & 0 0 0 ··· 1 −2
\vdots \\
\vdots & \vdots & \vdots &
\ddots & \ddots & 1 \\
0 & 0 & 0 & \cdots & 1 & -2
\end{matrix}
\]
18 Equation arrays
In the flow of a fluid film we may report:
\begin{eqnarray}
u_\alpha & = & \epsilon^2
\kappa_{xxx} 2 1 2
uα = κxxx y − y ,(5)
\left( y-\frac{1}{2}y^2 \right) 2
, v = 3 κxxx y , (6)
\label{equ} \\
p = κxx . (7)
v & = & \epsilon^3 \kappa_{xxx}
y\,,
\label{eqv} \\
p & = & \epsilon \kappa_{xx}\,.
\label{eqp}
\end{eqnarray}
Alternatively, the curl of a vector field (u, v, w) may be written with only
one equation number:
2017
c LPSK, INSPEM, UPM 49
LATEX: An Introduction to Malaysian Academicians
}\,.
\nonumber
\end{eqnarray} ∂w ∂v
ω1 = − ,
∂y ∂z
∂u ∂w
ω2 = − , (8)
∂z ∂x
∂v ∂u
ω3 = − .
∂x ∂y
19 Functions
Observe that trigonometric and other elementary functions are typeset prop-
erly, even to the extent of providing a thin space if followed by a single letter
argument:
\[
\exp(i\theta)=\cos\theta +i\sin\theta\,,\quad
\sinh(\log x)=\frac{1}{2} \left(x-\frac{1}{x} \right).
\]
1 1
exp(iθ) = cos θ + i sin θ , sinh(log x) = x− .
2 x
2017
c LPSK, INSPEM, UPM 50
LATEX: An Introduction to Malaysian Academicians
\[
\lim_{q\to\infty}\|f(x)\|_q
=\max_{x}|f(x)|, lim kf (x)kq = max |f (x)|,
q→∞ x
\]
∞ n
X xn Y
ex = where n! = i,
n=0
n! i=1
\
Uα = Uα .
α
In inline mathematics the scripts are correctly placed to the side in order to
conserve vertical space, as in:
\( P∞
1/(1-x)=\sum_{n=0}^\infty x^n 1/(1 − x) = n=0 xn .
.
\)
20 Accents
Mathematical accents are performed by a short command with one argument,
such as:
\[
\tilde f(\omega)=\frac{1}{2\ Z ∞
pi} 1
f˜(ω) = f (x)e−iωx dx ,
\int_{-\infty}^\infty 2π −∞
f(x)e^{-i\omega x}\,dx\,,
\]
or
2017
c LPSK, INSPEM, UPM 51
LATEX: An Introduction to Malaysian Academicians
\[
\dot{\vec \omega}= ~˙ = ~r × I~ .
ω
\vec r\times\vec I\,.
\]
21 Command definition
The Airy function, Ai(x), may be incorrectly defined as this integral:
\[
\Ai(x)=\int\exp(s^3+isx)\,ds Z
\,. Ai(x) = exp(s3 + isx) ds .
\]
This vector identity serves nicely to illustrate two of the new commands:
\[
\vec\nabla\times\vec q
=\vec i\left(\D yw-\D zv\right)
+\vec j\left(\D zu-\D xw\right)
+\vec k\left(\D xv-\D yu\right).
\]
∂w ∂v ∂u ∂w ∂v ∂u
∇×q =i − +j − +k − .
∂y ∂z ∂z ∂x ∂x ∂y
22 Theorems et al.
Define new theorem as below:
\newtheorem{theorem}{Theorem}
\newtheorem{corollary}[theorem]{Corollary}
\newtheorem{lemma}[theorem]{Lemma}
\newtheorem{definition}[theorem]{Definition}
2017
c LPSK, INSPEM, UPM 52
LATEX: An Introduction to Malaysian Academicians
\begin{definition}
[right-angled triangles] Definition 1 (right-angled trian-
\label{def:tri} gles). A right-angled triangle is a
A \emph{right-angled triangle} triangle whose sides of length a, b
is a and c, in some permutation of or-
triangle whose sides of length der, satisfies a2 + b2 = c2 .
~\(a\), \(b\) and~\(c\), in
some
permutation of order, satisfies
\(a^2+b^2=c^2\).
\end{definition}
\begin{lemma} \end{lemma}
The triangle with sides of
length
~\(3\), \(4\) and~\(5\) is Lemma 2. The triangle with sides
right- of length 3, 4 and 5 is right-angled.
angled.
\begin{theorem}[Pythagorean
triplets] \label{thm:py} Theorem 3 (Pythagorean triplets).
Triangles with sides of length Triangles with sides of length a =
\(a=p^2-q^2\), \(b=2pq\) and p2 − q 2 , b = 2pq and c = p2 + q 2
\(c=p^2+q^2\) are right-angled are right-angled triangles.
triangles.
\end{theorem}
The real power of LaTeX (for us) is in the math environment. You push
and pop out of the math environment by typing $. For example, 2x3 − 1 = 5
is typed between dollar
PN signs as $2x^3 - 1 = 5$. Perhaps a more interesting
example is limN →∞ k=1 f (tk )∆t.
You can get a fancier, display-style math environment by enclosing your
equation with double dollar signs. This will center your equation, and display
sub- and super-scripts in a more readable fashion:
2017
c LPSK, INSPEM, UPM 53
LATEX: An Introduction to Malaysian Academicians
There are many more things to know about LaTeX and we can’t possibly talk
about them all here. You can use LaTeX to get tables, commutative diagrams,
figures, aligned equations, cross-references, labels, matrices, and all manner of
strange things into your documents. You can control margins, spacing, align-
ment, et cetera to higher degrees of accuracy than the human eye can percieve.
You can waste entire days typesetting documents to be “just so”. In short,
LaTeX rules.
The best way to learn LaTeX is by example. Get yourself a bunch of .tex files,
see what kind of output they produce, and figure out how to modify them to do
what you want. There are many template and sample files on the department
LaTeX page and in real life in the big binder that should be in the computer
lab somewhere. Good luck!
23 Others
Notation. For p, q ∈ P and n ∈ ω we write (q, n) ≤ (p, n) if q ≤ p and Aq,n =
Ap,n .
\begin{notation} For $p,q\in P$ and $n\in\omega$
...
\end{notation}
2017
c LPSK, INSPEM, UPM 54
LATEX: An Introduction to Malaysian Academicians
$$\frac{\partial x}{\partial y}
\pmb{\bigg\vert} ∂x ∂y
\frac{\partial y}{\partial z}$$ ∂y ∂z
P Q
So-called “large operator” symbols such as and require an additional
command, \mathop, to produce proper spacing and limits when \pmb is used.
For further details see The TEXbook.
$$\sum_{\substack{i<B\\\text{ \kappa(r_i)$$
$i$
odd}}}
\prod_\kappa \kappa F(r_i)\
qquad XY XY
\mathop{\pmb{\sum}}_{\substack{ κF (ri ) κ(ri )
i<B i<B κ i<B κ
i odd i odd
\\\text{$i$ odd}}}
\mathop{\pmb{\prod}}_\kappa
2017
c LPSK, INSPEM, UPM 55
LATEX: An Introduction to Malaysian Academicians
tween them nicely adjusted, in both text and display style. \idotsint gives
two integral signs with dots between them.
\begin{gather}
\iint\limits_A f(x,y)\,dx\,
dy\qquad\iiint\limits_A f(x,y,z)\,dx\,dy\,dz\\
\iiiint\limits_A f(w,x,y,z)\,dw\,dx\,dy\,dz\\
\idotsint\limits_A f(x_1,\dots,x_k)
\end{gather}
ZZ ZZZ
f (x, y) dx dy f (x, y, z) dx dy dz (9)
A A
ZZZZ
f (w, x, y, z) dw dx dy dz (10)
A
Z Z
··· f (x1 , . . . , xk ) (11)
A
\begin{align*}
\overrightarrow{\psi_\delta(t)
−−−−−−→
E_t h}& ψδ (t)Et h = ψδ (t)Et h
=\underrightarrow{\psi_\delta(t −−−−−−→
←−−−−−−
) ψδ (t)Et h = ψδ (t)Et h
E_t h}\\ ←−−−−−−
←−−−−→
\overleftarrow{\psi_\delta(t) ψδ (t)Et h = ψδ (t)Et h
←−−−−→
E_t h}&
=\underleftarrow{\psi_\delta(t)
E_t h}\\
\overleftrightarrow{\psi_\delta
(t)
E_t h}&
=\underleftrightarrow{\psi_\
delta
(t) E_t h}
\end{align*}
2017
c LPSK, INSPEM, UPM 56
LATEX: An Introduction to Malaysian Academicians
\[\int_{\overrightarrow{AB}} Z
ax\,dx\]
−
−→
ax dx
AB
Dots
Normally you need only type \dots for ellipsis dots in a math formula. The
main exception is when the dots fall at the end of the formula; then you need
to specify one of \dotsc (series dots, after a comma), \dotsb (binary dots, for
binary relations or operators), \dotsm (multiplication dots), or \dotsi (dots
after an integral). For example, the input:
Accents in math
Double accents:
\[\Hat{\Hat{H}}\quad\Check
{\Check{C}}\quad
ˆ ´ ` ˘
\Tilde{\Tilde{T}}\quad\Acute Ĥ ȡ T̃˜ Á G̀ Ḋ˙ ¨
D̈ B̆ ¯
B̄ V
{\Acute{A}}\quad
\Grave{\Grave{G}}\quad\Dot
{\Dot{D}}\quad
\Ddot{\Ddot{D}}\quad\Breve
{\Breve{B}}\quad
\Bar{\Bar{B}}\quad\Vec{\Vec{V
}}\]
This double accent operation is complicated and tends to slow down the
processing of a LaTeX file.
2017
c LPSK, INSPEM, UPM 57
LATEX: An Introduction to Malaysian Academicians
Dot accents
\dddot and \ddddot are available to produce triple and quadruple dot accents
in addition to the \dot and \ddot accents already available in LaTeX:
\[\dddot{Q}\qquad\ddddot{R}\]
... ....
Q R
Roots
In the amsmath package \leftroot and \uproot allow you to adjust the position
of the root index of a radical:
\sqrt[\leftroot{-2}\uproot{2}\beta]{k}
Boxed formulas
The command \boxed puts a box around its argument, like \fbox except that
the contents are in math mode:
\boxed{W_t-F\subseteq V(P_i)\subseteq W_t}
Wt − F ⊆ V (Pi ) ⊆ Wt .
Extensible arrows
\xleftarrow and \xrightarrow produce arrows that extend automatically to
accommodate unusually wide subscripts or superscripts. The text of the sub-
script or superscript are given as an optional resp. mandatory argument: Ex-
ample:
\[0 \xleftarrow[\zeta]{\alpha}
F\times\triangle[n-1]
\xrightarrow{\partial_0\alpha(b α ∂0 α(b)
− F × 4[n − 1] −−−−→ E ∂0 b
0←
)} ζ
E^{\partial_0b}\]
2017
c LPSK, INSPEM, UPM 58
LATEX: An Introduction to Malaysian Academicians
\[\overset{*}{X}\qquad
\underset{*}{X}\qquad ∗ a
X X X
\overset{a}{\underset{b}{X}}\] ∗ b
\[\sideset{_*^*}{_*^*}\prod_k\
qquad
∗ Y∗ X0
\sideset{}{’}\sum_{0\le i\le m} Ei βx
∗ ∗
E_i\beta x k 0≤i≤m
\]
\[\mathbf{y}=\mathbf{y}’
\quad\text{if and only if}\quad
y’_k=\delta_k y_{\tau(k)}\] y = y0 if and only if yk0 = δk yτ (k)
Operator names
The more common math functions such as log, sin, and lim have predefined con-
trol sequences: \log, \sin, \lim. The amsmath package provides \DeclareMathOperator
and \DeclareMathOperator*for producing new function names that will have
the same typographical treatment. Examples:
\[\norm{f}_\infty=
\esssup_{x\in R^n}\abs{f(x)}\]
kf k∞ = ess supx∈Rn |f (x)|
$$\meas_1\{u\in R_+^1\colon
f^*(u)>\alpha\}
=$$ 1
meas1 {u ∈ R+ : f ∗ (u) > α} =
$$\meas_n\{x\in R^n\colon
\abs{f(x)}\geq\alpha\} measn {x ∈ Rn : |f (x)| ≥ α} ∀α > 0.
\quad \forall\alpha>0.$$
2017
c LPSK, INSPEM, UPM 59
LATEX: An Introduction to Malaysian Academicians
\begin{align}
&\varlimsup_{n\rightarrow\infty
} lim Q(un , un − u# ) ≤ 0 (12)
n→∞
\mathcal{Q}(u_n,u_n-u^{\#})\le0
\\ lim |an+1 | / |an | = 0 (13)
n→∞
&\varliminf_{n\rightarrow\infty
lim(mλi ·)∗ ≤ 0 (14)
} −→
\left\lvert a_{n+1}\right\rvert lim Ap ≤ 0 (15)
←−
/\left\lvert a_n\right\rvert p∈S(A)
=0\\
&\varinjlim (m_i^\lambda\cdot)
^*
\le0\\
&\varprojlim_{p\in S(A)}A_p\le0
\end{align}
2017
c LPSK, INSPEM, UPM 60
LATEX: An Introduction to Malaysian Academicians
\begin{align}
x&\equiv y+1\pmod{m^2}\\
x&\equiv y+1\mod{m^2}\\ x≡y+1 (mod m2 ) (20)
x&\equiv y+1\pod{m^2} 2
x≡y+1 mod m (21)
\end{align}
2
x≡y+1 (m ) (22)
X k k−1 k k−2
Iγ = 2k − 2 + 2
1 2
γ∈ΓC
(23)
k k−l
+ · · · + (−1)l 2 + · · · + (−1)k
l
= (2 − 1)k = 1
2017
c LPSK, INSPEM, UPM 61
LATEX: An Introduction to Malaysian Academicians
\text{\cn{overwithdelims}: }&
\genfrac{\langle}{\rangle}{}{}{n+1}{2}\\
\text{\cn{atop}: }&\genfrac{}{}{0pt}{}{n+1}{2}&
\text{\cn{atopwithdelims}: }&
\genfrac{(}{)}{0pt}{}{n+1}{2}\\
\text{\cn{above}: }&\genfrac{}{}{1pt}{}{n+1}{2}&
\text{\cn{abovewithdelims}: }&
\genfrac{[}{]}{1pt}{}{n+1}{2}
\end{align}
n+1 n+1
\over: \overwithdelims: (24)
2 2
n+1 n+1
\atop: \atopwithdelims: (25)
2 2
n+1 n+1
\above: \abovewithdelims: (26)
2 2
Continued fractions
The continued fraction
\begin{equation}
\cfrac{1}{\sqrt{2}+
\cfrac{1}{\sqrt{2}+ 1
\cfrac{1}{\sqrt{2}+ √ 1
\cfrac{1}{\sqrt{2}+ 2+
√ 1
\cfrac{1}{\sqrt{2}+\dotsb 2+
√ 1
}}}}} 2+
\end{equation} √ 1
2+ √
2 + ···
(27)
Smash
In amsmath there are optional arguments t and b for the plain TEX command
\smash, because sometimes it is advantageous to be able to ‘smash’ only the top
or only the bottom of something while retaining the natural depth or height. In
2017
c LPSK, INSPEM, UPM 62
LATEX: An Introduction to Malaysian Academicians
√
the formula Xj = (1/ λj )Xj0 \smash[b] has been used to limit the size of the
radical symbol.
$X_j=(1/\sqrt{\smash[b]{\lambda_j}})X_j’$
Without the use of \smash[b] the formula would have appeared thus: Xj =
(1/ λj )Xj0 , with the radical extending to encompass the depth of the subscript
p
j.
(
0 if r − j is odd,
Pr−j = (28)
r! (−1)(r−j)/2 if r − j is even.
Matrix
Here are samples of the matrix environments,\matrix, \pmatrix, \bmatrix,
\Bmatrix, \vmatrix and \Vmatrix:
\begin{equation} \end{bmatrix}
\begin{matrix} \end{equation}
\vartheta& \varrho\\\varphi& \
varpi
\end{matrix}\quad
\begin{pmatrix}
\vartheta& \varrho\\\varphi& \
varpi
\end{pmatrix}\quad
\begin{bmatrix}
\vartheta& \varrho\\\varphi& \
varpi
2017
c LPSK, INSPEM, UPM 63
LATEX: An Introduction to Malaysian Academicians
ϑ % ϑ % ϑ %
ϕ $ ϕ $ ϕ $
(29)
\begin{equation}
\begin{Bmatrix}
\vartheta& \varrho\\\varphi& \ ϑ % ϑ
%
ϑ
%
varpi ϕ $ ϕ $
ϕ $
\end{Bmatrix}\quad (30)
\begin{vmatrix}
\vartheta& \varrho\\\varphi& \
varpi
\end{vmatrix}\quad
\begin{Vmatrix}
\vartheta& \varrho\\\varphi& \
varpi
\end{Vmatrix}
\end{equation}
To produce a small matrix suitable for use in text, use the smallmatrix
environment.
\begin{math}
\bigl( \begin{smallmatrix}
a&b\\ c&d
\end{smallmatrix} \bigr)
\end{math}
To show the effect of the matrix on the surrounding lines of a paragraph, we
put it here: ac db and follow it with enough text to ensure that there will be at
least one full line below the matrix.
\hdotsfor{number } produces a row of dots in a matrix spanning the given
number of columns:
ϕ
0 ... 0
(ϕ1 , ε1 )
ϕkn2 ϕ
(ϕ , ε ) (ϕ , ε ) . . . 0
W (Φ) =
2 1
2 2
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
ϕkn1 ϕkn2 ϕkn n−1 ϕ
(ϕ , ε ) (ϕ , ε ) . . . (ϕ , ε
n 1 n 2 n n−1 ) (ϕn , εn )
\[W(\Phi)= \begin{Vmatrix}
\dfrac\varphi{(\varphi_1,\varepsilon_1)}&0&\dots&0\\
\dfrac{\varphi k_{n2}}{(\varphi_2,\varepsilon_1)}&
2017
c LPSK, INSPEM, UPM 64
LATEX: An Introduction to Malaysian Academicians
\dfrac\varphi{(\varphi_2,\varepsilon_2)}&\dots&0\\
\hdotsfor{5}\\
\dfrac{\varphi k_{n1}}{(\varphi_n,\varepsilon_1)}&
\dfrac{\varphi k_{n2}}{(\varphi_n,\varepsilon_2)}&\dots&
\dfrac{\varphi k_{n\,n-1}}{(\varphi_n,\varepsilon_{n-1})}&
\dfrac{\varphi}{(\varphi_n,\varepsilon_n)}
\end{Vmatrix}\]
The spacing of the dots can be varied through use of a square-bracket option,
for example, \hdotsfor[1.5]{3}. The number in square brackets will be used
as a multiplier; the normal value is 1.
A slightly more generalized form is the subarray environment which allows you
to specify that each line should be left-aligned instead of centered, as here:
X
P (i, j) (32)
0≤i≤m
0<j<n
\sum_{\begin{subarray}{l}
0\le i\le m\\ 0<j<n
\end{subarray}}
P(i,j)
Big-g-g delimiters
Here are some big delimiters, first in \normalsize:
\[\biggl(\mathbf{E}_{y}
\int_0^{t_\varepsilon}L_{x,y^x( Z tε
s)}
Ey Lx,yx (s) ϕ(x) ds
\varphi(x)\,ds \biggr) 0
\]
2017
c LPSK, INSPEM, UPM 65
LATEX: An Introduction to Malaysian Academicians
{\Large
\[\biggl(\mathbf{E}_{y}
\int_0^{t_\varepsilon}L_{x,y^x(
Z tε
s)} Ey Lx,yx (s) ϕ(x) ds
\varphi(x)\,ds \biggr) 0
\]}
\begin{thebibliography}{1}
\end{thebibliography}
You can put this at the end of your LaTeX file. If you want to refer to
something from your bibliography you can put something like this in your file:
2017
c LPSK, INSPEM, UPM 66
LATEX: An Introduction to Malaysian Academicians
References
[1] John W. Dower Readings compiled for History 21.479. 1991.
[2] The Japan Reader Imperial Japan 1800-1945 1973: Random House, N.Y.
[3] E. H. Norman Japan’s emergence as a modern state 1940: International
Secretariat, Institute of Pacific Relations.
2017
c LPSK, INSPEM, UPM 67