Report Writing Using LaTex
Report Writing Using LaTex
3TBCS – 606
Practical 1: Understanding LaTex
LaTeX is a document preparation system used by academic and research communities for the
publication of their work. Specifically, the writer uses markup tagging conventions to stylize text
throughout a document, add citations and cross-references, and to define the structure of the
document. LaTeX uses a TeX distribution such as TeX Live or MikTeX to produce an output file (PDF)
suitable for printing or digital distribution.
LaTeX (pronounced lay-tech) is a method of creating documents using plain text, stylized using markup
tags, similar to HTML/CSS or Markdown. LaTeX commonly used to create documents for academia,
such as academic journals. In LaTeX, the author does not stylize the document directly, like in a word
processor such as Microsoft Word, LibreOffice Writer, or Apple Pages; instead they write code in plain
text that must be compiled to produce a PDF document.
LATEX is a typesetting program and is an extension of the original program TEX. Various stages in the
preparation of a document using computers.
4. The final output is printed. In most word processors all these operations are integrated into a single
application package.
But a typesetting program like TEX is concerned only with the second stage above. So to typeset a
document using TEX, we type the text of the document and the necessary formatting commands in a
text editor (such as Emacs in GNU/Linux) and then compile it. After that the document can be viewed
using a previewer or printed using a printer driver. TEX is also a programming language, so that by
learning this language, people can write code for additional features. In fact LATEX itself is such a
(large) collection of extra features. And the collective effort is continuing, with more and more people
writing extra packages.
Let us see LATEX in action by typesetting a short document. Start your favorite text editor and type in
the lines below exactly as shown \documentclass{article} \begin{document} This is my \emph{first}
document prepared in \LaTeX. \end{document} Be especially careful with the \ character (called the
backslash) and note that this is different from the more familiar / (the slash) in and/or and save the
file onto the hard disk as myfile.tex. (Instead of myfile you can use any name you wish, but be sure to
have .tex at the end as the extension.) The process of compiling this and viewing the output depends
on your operating system.
Advanced GUI based open source document processor running on Linux/Unix, Windows, and Mac OS
X. Writing based on the structure of your documents, not their appearance. LyX lets you concentrate
on writing, leaving details of visual layout to the software. LyX automates formatting according to
predefined rule sets, yielding consistency throughout even the most complex documents. LyX
produces high quality, professional output – using LaTeX, an open source, high quality typesetting
engine, in the background.
Practical 2: Understanding Document Structure of Latex
To create PDFs with LaTeX the user must generate a .tex file. The .tex file will consist of the code that
is compiled by the back end LaTeX software to generate the end result PDF document. With LaTeX
installed .tex files can be created in notepad or textedit on Windows or OS X computers respectively,
though it is strongly recommenced to generate these files directly in a LaTeX text editor as discussed
in the Getting Started: Installation tab.
A LaTeX document consists of two main pieces, the preamble and the body, the bibliography can be
considered a third piece depending on how you structure it, but that will be discussed in the BibTex
tab of this guide. It is recommended that the user creates a new folder on their computer for each
LaTeX document they are working on. When LaTeX compiles a .tex file it generates several files in
order to create the PDF having a folder for the each individual document you are working on will help
keep all of the files generated organized. Additionally, it possible the user will want to insert images,
figures, or other objects into their document (BibTex files for example), it is much simpler to insert
items into the document when they are located in the same folder as the .tex file.
Preamble
The preamble to a LaTeX document is all the information that occurs before the document
begins. The preamble starts with the command \documentclass{} and ends with the
command \begin{document}. Below is an image of a document preamble:
Different objects are placed in the preamble between the commands \documentclass{} and
\begin{document}. The most common of these items is the command \usepackage{}. A more
detailed explanation of what packages are can be found under the LaTeX Structures heading on
this page, but briefly a package informs the compiler of certain commands that will be used and
certain procedures to take while generating the final document. Any number of packages can be
included in the preamble, and one of the most common mistakes made by the new LaTeX user is
to include a command in their document without including the proper package in the preamble.
Other commands such as \title, \author, and \date are included in the preamble and than may be
incorporated within the document. Lastly, new commands can be created in the preamble that will
only be used in the current document.
Body
The body of a LaTeX document is where all of the text, equations, figures, tables, etc... will be
placed. The body of the document begins with the command \begin{document} and ends with the
command \end{document}. A very simple sample code and its output can be seen below. The
code contains both the preamble and body of the document.
Practical 3: Understanding Common Commands and Packages in Latex
Common Commands
Here is a list of some useful and common commands for LaTeX. Links to more exhaustive lists
can be found on the Resources tab of this guide. If you are looking for specific mathematical
symbols check the links on the resources tab. If you are interested in more information about a
specific command a simple Google search will often provide great results.
Preamble commands:
\documentclass{}
The first command in any document. Used to specify what type of document is being
made. Some common arguments are article (common for scientific journals), book, IEEEtran (for
IEEE transaction format), slides, beamer (for presentations).
\usepackage{}
This command imports a package into the LaTeX document. This is important for including
any commands that are not standard in LaTeX.
\title{}
The intended title of the document should be used as the argument
\author{}
The author of the document should be used as the argument, for multiple authors use \and to
separate authors name or use the authblk package. For the authblk package uses the
following format where \affil is used to entire the affiliation of the author and the optional
argument denotes the whatever symbol should be used after the author's name:
\author[1]{1st Author}
\author[1]{2nd Author}
\author[1]{3rd Author}
\author[2]{Nth Author}
\affil[1]{Institute 1}
\affil[2]{Institute 2}
\date{}
The argument is the date associated with the document. Note that leaving the argument empty
will create a blank date in the title, and not including the command will default the title to the date
compiled.
Body commands:
\maketitle
Creates a title based on the \title, \author, and \date provided.
\newpage{}
Creates a new page
\\
Creates a line break
\section{}
Denotes a new section. The title section should be used as the argument. Sections will be
automatically included in the table of contents. Use the
commands \subsection{} and \subsubsection{} to create sections within sections.
Common Packages
Packages allow for additional features to be used within a LaTeX document. Both MikTex and
MacTex come pre-installed with a large number of standard packages and instructions for
installing new packages. To use a package include the command \usepackage{} where the
argument is the package name i.e. \usepackage{amsmath}.
geometry
This package is for the more advanced user. It allows the user to better control the formatting of
the document.
graphicx
This package allows graphics to be integrated into a document.
hyperref
This package allows for hyperlinks inside a document. Use the command \hypersetup{} to
control different link colors.
booktabs
A useful package if you are having trouble with spacing inside of tables.
Practical 4: Understanding Latex Editors
LaTeX is a document preparation system used in the publication of scientific documents. It is
useful in rendering mathematical equations, symbols, matrices, tables, and other content in
documents. You can use these LaTeX editors on your Windows PC to create mathematical,
scientific, journals, and other documents.
1. TeXmaker
2. TeXstudio
3. LyX
4. TeXnic
5. TeXworks
6. Notepad++
7. WinShell
8. TexitEasy
9. AUCTeX
10. RTextDoc
11. Miktex
Downloading Miktex
Go to www.miktex.org
Choose the "miktex 2.4" link from the Download/Install menu on the left
If your browser doesn't download automatically, click the link that is provided
Installation of Latex
Standard Website for the Installation Bundle: https://www.lyx.org/Home. Downoload the Bundle for
Windows or Ubuntu. Right Click and Run as Administrator. Say yes to proceed ,License prompt: agree
Choose the destination folder. Default components are checked. Make sure to Check JabRef. Default
repository is checked for loading packages. Simply do Next as when required.
Managing your TeX installation with MiKTeX Console
MiKTeX Console is the tool you use to manage your TeX installation. Most often you
will use it to get package updates.
MiKTeX Console is a desktop application, i.e, it can be started in the usual way by
searching and clicking MiKTeX Console in the application launcher (Windows start
menu, Unity Dash, macOS Launchpad).
Operation mode
By default, MiKTeX Console runs in MiKTeX user mode and so operates on your
private MiKTeX configuration. If you have installed MiKTeX system-wide, this is not
necessarily what you want. For this reason, MiKTeX Console asks you to
switch/confirm the operation mode, if you have a system-wide setup:
Installing updates
To speed up file search, MiKTeX makes use of a file location cache. This is called the
file name database (FNDB).
It is necessary that you refresh the FNDB whenever you manually install TeX/LaTeX-
related files in a user-managed TEXMF directory:
You can turn this feature on or off. And you can let MiKTeX ask you each time a
package has to be installed:
If you have files that you want to integrate into the MiKTeX setup, you can register a
user-managed TEXMF root directory:
If you decide to uninstall MiKTeX, you should first reset the TeX installation to the
factory defaults:
This resets the TeX installation to the initial state. You can now uninstall MiKTeX.
Practical 5: Download and Install TeXstudio
Downloading Texstudio
Free and open source software (FOSS) popular with academics called TexStudio, which
runs on Windows, Unix/Linux, BSD, and Mac OS X.
Launch TexStudio, save your new document. Named helloworld.tex, since for writing
the Hello, World! tradition from programming. Next, add some boilerplate code at the
top of your .tex file that specifies the type and size of your document. This is similar to
the boilerplate code used in HTML5 documents.
This code sets the page size to A4 and the text size to 12pt.
Code:
\documentclass[a4paper,12pt]{article}
\begin{document}
\title{Hello World! My first LaTeX document}
\author{CSE VI Sem}
\date{March}
\maketitle
\end{document}
Click on the large green arrow to compile the document. That's the middle button in the screenshot
below.
If there are any errors, they'll appear in the dialog box at the bottom. After you compile the document,
you can see what it will look like by viewing a PDF within the program as a sort of WYSIWYG preview.
Remember it must be recompiled whenever you make a change to the code, as you would when
programming in C++, for example.
To view your document, click on Tools > Commands > View PDF, as shown in the screenshot below.
The PDF output will be shown on the right, like this
Practical 8: To Print a Paragraph
Code:
\documentclass[a4paper,12pt]{article}
\begin{document}
\title{Paragraph}
\author{CSE VI Sem}
\date{April}
\maketitle
\section{Introduction}
\paragraph{}
LaTeX is a document preparation system used by academic and research communities for the
publication of their work. Specifically, the writer uses markup tagging conventions to stylize text
throughout a document, add citations and cross-references, and to define the structure of the
document. LaTeX uses a TeX distribution such as TeX Live or MikTeX to produce an output file (PDF)
suitable for printing or digital distribution.
\end{document}
Output:
Practical 9: To print the Table of Contents
Code:
% 4.tex SE 606496
\documentclass{extarticle}
\title{Report}
\author{CSE Sem-VI}
\begin{document}
\maketitle
\tableofcontents
I acknowledge \ldots or
\begin
{center}
\large\textbf{Thanks}
%%%
%%%
\end{center}
I acknowledge \ldots
\section{First section}
\end{document}
Output:
Practical 10: To print Equations
Coding
\documentclass{article}
\begin{document}
\begin{equation}
\int_\alpha^\beta f'(x) \, dx=f(\beta)-f(\alpha).
\end{equation}
We can use the fundamental theorem of calculus to say that
$\int_2^3 x^2 \, dx=\frac{3^3}{3}-\frac{2^3}{3}=\frac{19}{3}$.
Also note that $\displaystyle \int_2^3 x^2 \, dx=\frac{3^3}{3}-
\frac{2^3}{3}=\frac{19}{3}$.
We can also give this equation its own line
\[
\int_2^3 x^2 \, dx=\frac{3^3}{3}-\frac{2^3}{3}=\frac{19}{3}.
\]
\end{document}
Output
Practical 11: To Print Multiple Equations
Code
\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation}
(x+3)(x+2)=x^2+5x+6\notag\\
\geq x^2
\end{equation}
\begin{gather}
(x+3)(x+2)=x^2+5x+6\notag\\
\geq x^2
\end{gather}
\begin{align}
(x+3)(x+2)&=x^2+5x+6\notag\\
&\geq x^2
\end{align}
\end{document}
Output
Practical 12: To print References
Code:
\documentclass[a4paper,11pt,twocolumn]{article}
\begin{document}
\author{CSE Sem-VI}
\date{}
\maketitle
\begin{abstract}
\end{abstract}
\section{introduction}
\bibliographystyle{plain}
\bibliography{reference}
\end{document}
Output: