Showing posts with label LaTeX. Show all posts
Showing posts with label LaTeX. Show all posts

Thursday, July 15, 2021

LaTeX Tutorial: An Introduction

In this video, you will learn an introduction on how to write a document using LaTeX.

Thursday, March 13, 2014

Ubuntu: How to enable spellchecker in LyX


  1. Open the Terminal and install Enchant.
    sudo apt-get install enchant
  2. Open LyX and select Tools > Preferences > Language Settings > Spellchecker
  3. Select Enchant for Spellchecker Engine.
  4. Click on Apply, Save and finally Close.

Friday, November 11, 2011

Prevent Indentation for One Paragraph in LaTeX

To prevent indentation for one paragraph, add
\noindent
at the beginning of a paragraph, followed by a space.

Wednesday, September 30, 2009

Multiple column layout in LaTeX

To create a multiple column layout in LaTeX is easy. What you need is the multicol package.
\usepackage{multicol}


For example, to create a two column layout.
\begin{multicols}{2}
put the contents here
\end{multicols}


To manually break the column, use the \columnbreak command.
\begin{multicols}{2}
Column 1 \columnbreak Column 2
\end{multicols}


If you are using standard LaTeX class, such as "article", you can simple create a two column layout using the code below:
\documentclass[twocolumn]{article}

Friday, September 18, 2009

LaTeX editor with live preview pane for Ubuntu/Linux

Gummi
Gummi is a lightweight LaTeX editor written in Python/GTK+ released as open-source software under a dual MIT/Beerware license, and was written by a BSc student of Artificial Intelligence at the University of Amsterdam, Alexander van der Mey.

The main feature of Gummi is that the Preview Pane will update as you are typing. In my opinion, this feature is good if you are learning LaTeX.

Give Gummi a try, and tell me your opinion.

Click here to download.

Tuesday, June 9, 2009

LaTeX: How to change the word Figure or Table

To change the word Figure or Table

What you need is \renewcommand{}{}.

Example:

  1. Change Figure to Rajah:
    \renewcommand{figurename}{Rajah}

  2. Change Table to Jadual:
    \renewcommand{tablename}{Jadual}

What about List of Figures and List of Tables?

We can still use the same \renewcommand{}{}.

Example:

  1. Change List of Figures to Senarai Rajah:
    \renewcommand{listfigurename}{Senarai Rajah}

  2. Change List of Tables to Senarai Jadual:
    \renewcommand{listtablename}{Senarai Jadual}

Friday, May 29, 2009

Table of contents in LaTeX

LaTeX has an ability to produce table of contents automatically for the whole document. Table of contents contain the section numbers and corresponding headings, together with the page numbers on which they begin. This article gives some introduction on generating and printing the table of content, as well as list of figures and tables in LaTeX.

Printing the table of contents

To display the table of contents, place the following command
\tableofcontents
at the location where the table of contents is to appear.To set the depth of table of contents, use the following command.
\setcounter{tocdepth}{the number of depth}
To add additional entry to the table of contents, use the following command.
\addcontentsline{toc}{section name}{entry text}\addtocontents{toc}{entry text}
For example, to include a *-form subsection named Preface in table of contents.
\subsection*{Preface}
\addcontentsline{toc}{subsection}{Preface}
To include reference or bibliography entry in table of contents, use the following command right before the bibliography command.
\addcontentsline{toc}{section}{References}
To produce roman style page number for the table of contents and arabic style page number for the rest of the documents, use the following command.
\pagenumbering{roman}
\tableofcontents
\newpage
\pagenumbering{arabic}
\tableofcontents
To change the title of table of contents, use the following command.
\renewcommand{contentsname}{New table of contents title}

List of figures and tables

Besides table of contents, LaTeX can also produce list of figures and tables automatically.The commands are
\listoffigures % to produce list of figures
\listoftables % to produce list of tables
The entries in these lists use the entries from the \caption command in the figure and table environments.

Wednesday, May 27, 2009

Insert source code with syntax highlighting in LaTeX

To insert source code with syntax highlighting, one possibility is to use the Listings package.

The Listings package supports a huge number of languages: ABAP, IDL, Plasm, ACSL, inform, POV, Ada, Java, Prolog, Algol, JVMIS, Promela, Ant, ksh, Python, Assembler, Lisp, R, Awk, Logo, Reduce, bash, make, Rexx, Basic, Mathematica1, RSL, C, Matlab, Ruby, C++, Mercury, S, Caml, MetaPost, SAS, Clean, Miranda, Scilab, Cobol, Mizar, sh, Comal, ML, SHELXL, csh, Modula-2, Simula, Delphi, MuPAD, SQL, Eiffel, NASTRAN, tcl, Elan, Oberon-2, TeX, erlang, OCL, VBScript, Euphoria, Octave, Verilog, Fortran, Oz, VHDL, GCL, Pascal, VRML, Gnuplot, Perl, XML, Haskell, PHP, XSLT, HTML, and PL/I.



To use the Listings package, first define the package in the preamble.
\usepackage{listings}
Second, define the language to use, anywhere in the document.
\lstset{language=Python}
Finally, insert the source code.

  1. write code within your document
    \begin{lstlisting}
    put your code here
    \end{lstlisting}

  2. import the code from other file
    \lstinputlisting{source_filename.py}

For more information, read

  1. PDF by Carsten Heinz

  2. Listings package on CTAN

Tuesday, May 26, 2009

How to set the margins of a page in LaTeX

To set the page margins in LaTeX, use the geometry package.
\usepackage[a4paper]{geometry}
\geometry{top=1.0in, bottom=1.0in, left=1.5in, right=1.0in}

Monday, May 25, 2009

How to insert very large image/figure in LaTeX

To insert a very large image in LaTeX, use the textwidth command to stretch the image.
\includegraphics[width=0.75\textwidth]{...}

0.75\textwidth meant 75% of the text width.

Sunday, May 24, 2009

How to create annotation for table of contents in LaTeX

To add a description about what a particular section is all about, in the table of contents, use the following code.
\addcontentsline{toc}{subsection}{the description}
Add the code after the each section declaration.

Monday, May 18, 2009

How to create a matrix in LaTeX

We can create a matrix in LaTeX using the array environment, or simplematrix, matrix, pmatrix, bmatrix, vmatrix, and Vmatrix environments via amsmath package. This article provides some examples on how to create a matrix in LaTeX.

Creating a matrix with array

Here are some examples.
  1. unbracketed matrix

    \[
    M =
    \begin{array}{cc}
    x & y \\
    z & w
    \end{array}
    \]
  2. matrix surrounded by square brackets

    \[
    M =
    \left[ {\begin{array}{cc}
    x & y \\
    z & w
    \end{array} } \right]
    \]
  3. matrix surrounded by parentheses

    \[
    M =
    \left( {\begin{array}{cc}
    x & y \\
    z & w
    \end{array} } \right)
    \]
  4. matrix surrounded by single vertical lines

    \[
    M =
    \left| {\begin{array}{cc}
    x & y \\
    z & w
    \end{array} } \right|
    \]

Using amsmath package

Call \usepackage{amsmath} in the preamble, after documentclass{}.

The amsmath package environment for matrix:
  1. smallmatrix: inline matrix


    $M = \begin{smallmatrix}
    x & y \\
    z & w
    \end{smallmatrix}$

    $M = \left( \begin{smallmatrix}
    x & y \\
    z & w
    \end{smallmatrix}\right)$
  2. matrix: unbracketed matrix
    $M = \begin{matrix}
    x & y \\
    z & w
    \end{matrix}$

  3. pmatrix: matrix surrounded by parentheses
    $M = \begin{pmatrix}
    x & y \\
    z & w
    \end{pmatrix}$
  4. bmatrix: matrix surrounded by square brackets
    $M = \begin{bmatrix}
    x & y \\
    z & w
    \end{bmatrix}$
  5. vmatrix: matrix surrounded by single vertical lines
    $M = \begin{vmatrix}
    x & y \\
    z & w
    \end{vmatrix}$
  6. Vmatrix: matrix surrounded by double vertical lines

    $M = \begin{Vmatrix}
    x & y \\
    z & w
    \end{Vmatrix}$

Thursday, May 14, 2009

4 ways to framed displayed formulas in LaTeX

This article will show on how to display formulas (mathematics equations) inside a box or frame.

Using fbox and parbox

The formula will be framed. Must declare the width of the frame.
\fbox {
    \parbox{5cm} {
     [
     \oint\limits_C V,d\tau =
     \oint\limits_\Sigma \nabla \times V,d\sigma
     ]
    }
}

Using fbox and minipage

The formula will be framed. Must declare the width of the frame.
\fbox {
    \begin{minipage}[position]{5cm}
    [
     \oint\limits_C V,d\tau =
     \oint\limits_\Sigma \nabla \times V,d\sigma
    ]
    \end{minipage}
}

Using equation environment and fbox

The formula will be centred, framed and numbered.
\begin{equation}
\fbox {
    $ \displaystyle \oint\limits_C V,d\tau =
     \oint\limits_\Sigma \nabla \times V,d\sigma $
}
\end{equation}

Using displaymath enviroment and fbox

The formula will be centred, framed and unnumbered.
\begin{displaymath}
\fbox {
    $ \displaystyle \oint\limits_C V,d\tau =
    \oint\limits_\Sigma \nabla \times V,d\sigma $
}
\end{displaymath}

Sunday, March 22, 2009

How to compile LaTeX file

Here are the typical steps to produce DVI, PostScript or PDF file from a LaTeX source file:

  1. Create the LaTeX source file. It must be in the plain ASCII format. Simple text editor like Notepad, VIM or Emacs would be fine. Please do not use word processor like Microsoft Office.

  2. Run LaTeX on the LaTeX source. Any warning or error will be reported, if exists. If the source file contains table of contents, or references, you may need to run the above command several times. If you are lucky, you will get a DVI file, called yourfile.dvi. To view it, use dvi viewer like xdvi or Yap.
    latex yourfile.tex

  3. To convert the DVI file to PostScript format, run
    dvips -Pcmz yourfile.dvi -o yourfile.ps

  4. To produce a PDF file, you don't need to do step 1. Just run
    pdflatex yourfile.tex

  5. To produce a PostScript file from a PDF file,
    pdf2ps yourfile.pdf newfile.ps

  6. To produce a PDF file from a PostScript file,
    pdf2ps yourfile.ps newfile.pdf

Saturday, March 21, 2009

Minimal LaTeX file

An example LaTeX source file for writing a journal article.
\documentclass[a4paper,11pt]{article}
\author{Rizauddin}
\title{Very simple article}

\begin{document}

%generates the title
\maketitle

% insert table of contents
\tableofcontents

\section{Introduction}
The intro will be here.

\section{Conclusion}
\ldots{} and it ends here.

\end{document}

Friday, March 6, 2009

Manually markup changes of text, such as additions, deletions, orreplacements in LaTeX

In LaTeX there is a package that allows user to manually markup changes of text, such as additions, deletions, or replacements. The changes will be shown in different colour. Deleted text will be crossed out. The package is called "Manual change markup". It is a free package under the LaTeX Project Public License. If you install LateX from MiKTeX or TeX Live, most probabily, you already have this package installed.

The identifier to this package is 'changes'. Therefore, in order to use it, make the declaration to the use of this package in the preamble, after the documentclass{}. For example,
\documentclass{article}

\usepackage{changes}

Examples of usage:

  1. \added{new text} for addition.

  2. \deleted{old text} for deletion.

  3. \replaced{new text}{old text} for replacement.


In order to deliver the final version of the document, add 'final' option to the 'changes' option.
\usepackage[final]{changes}
'Manual change markup' documentation on CTAN (pdf).

Friday, January 30, 2009

LaTeX title page

A document is usually divided into several parts. One of the part is the title page. To produce the title page, use the \maketitle command. The format of the title page will depends on the document class used, such as article, book or report.

A document title page usually consists of several items: title, author(s), date, and some footnote. The first item is the title. The command to use is \title{}. A standard LaTeX format for the title page will align all entries centered on the lines in which they appear. The title will be broken up automatically, if the title is too long. To manually break the title, please use the \\ command. For example, title{...\\...\\...}.

The second item is the author(s). To display the author, use the \author{} command. If there are several authors, separate their name with and from one another. For example \author{S. Kasim \and P. Ramli}. The author names will be printed in parallel next to each other on the same line. Replace \and with \\ to display the author(s) on top of one another.

To include the address, use the \\ command, such as
\author{S. Kasim\\Company\\Address
\and
P. Ramli\\Company\\Address}
Extra item such as telephone number or email may be produce in the footnote via the \thanks{} command. For example, \author{S. Kasim\thanks{Tel. 03--3367638}}.

The last item is the date, which can be produced using the \date{} command. If the \date{} command is omitted, then the current date is printed automatically below the author entries on the title page.

An example of a title page

\documentclass{article}

\title{A simple LaTeX title page}

\author{
S. Kasim \thanks{Tel. 03--3367638}\\Company1\\Address1
\and
P. Ramli \thanks{Email. ramli@ramli.com}\\Company2\\Address2
}

\date{Kuala Lumpur, \today}

\begin{document}
\maketitle

\end{document}

Wednesday, July 9, 2008

LaTeX special characters

Special symbols

CharacterCommandDescription
§Ssection sign
dagdagger
ddagdouble dagger
Ppilcrow sign (paragraph)
©copyrightcopyright sign
£poundsPound sign

Printing command characters

CharacterCommandDescription
$$dollar sign
&&ampersand
%%percent sign
##
__underscore
{{opening curly brace
}}closing curly brace

European letters

CharacterCommandDescription
œ{oe}latin small ligature oe
Œ{OE}latin capital ligature OE
æ{ae}latin capital ligature ae
Æ{AE}latin small ligature AE
å{aa}latin small letter a with ring above
Å{AA}latin capital letter A with ring above
Ø{o}latin capital letter O with stroke
Ø{O}latin small letter o with stroke
ßsssharp S
¿?`inverted question mark
¡!`inverted exclamation mark

Accents (diacritic marks)

CharacterCommandDescription
ò`{o}with grave
ó'{o}with acute
ô^{o}with circumflex
ö"{o}with umlaut
õ~{o}with tilde
={o}with macron
.{o}with a dot above
u{o}with breve
v{o}with caron
H{o}with double acute
d{o}with a dot below
ob{o}with an underline

Note: You can replace o with the desired character.