0% found this document useful (0 votes)
19 views62 pages

latex

Download as pdf or txt
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 62

What is Latex?

The Latex is the markup language used for the typesetting of the technical
documents. To learn Latex, you must have a great idea of MS Word and the way or
method in which you want to design your document. It also needs an understanding
of mathematics and related commands.
The Latex is mostly used by scientists, mathematicians, authors, etc. It is also
designed to help beginners as well as the professional to concise and make their
documents look more attractive. It is a fast and time-saving procedure for writing
documents.
Features of Latex
o Latex is a markup language and free license software. It includes a set of built-
in commands.
o It is a mode of mathematical and special symbols.
o LaTeX is generally distributed along with plain TEX, i.e., it provides a set of
macros for TEX to interpret. The other macros for TEX are Plain TEX, GNU
Texinfo, etc.
o LaTeX is not compatible with the GNU (General Public License). It is
available on most of the operating systems like UNIX, BSD, Linux, Windows,
DOS, etc.
Installation of Latex
For LaTeX, you need to download MiKTeX and Texstudio. MiKTeX is a Latex
distribution, a vast collection of files, and is essential for Latex. Texstudio is called
a specialized editor and helps in the Latex workflow. Installing the editor is optional
but it makes the Latex easier. The process will take some time. Below are the steps
for the download and installation of Latex:
o Search for MiKTeX in any browser.
o As the page opens, click on MiKTeX.org and select the 'Download' option
given at the top.
o Now, click on the 'All downloads' option. You will see the window appear
like the image shown below:
o Select the 'Net Installer' and choose the 64 or 32-bit according to your system
configuration and click on the download option. The download will start.
o After that, close the browser. The MiKTeX download is a two-step process in
this.
o In first step, with the help of Net Installer, we download the files, and in the
second step, we install these downloaded files.
o Now, open this file and accept the conditions.
o Select the option 'Download MiKTeX.' Click on Next and then select
'Complete MiKTeX' and again click next.
o Then select the FTP as a download source. Click on the browse option, and
under downloads category, make a new folder by any name and click 'OK'
and then click on next. You can also select any other folder as per your
requirements.
o Click on the 'Start' option, and the downloading process will start, which will
take a while. Wait for the process to download. The downloading dialogue
box will look like the image shown below:
After this, again, go to the MiKTeX and then select 'Install MiKTeX.' It will still
take some time, and now, the process is complete.
If there is an error, then close the window and restart the downloading process by
selecting another server from the list.
o If you select the option 'Basic Installer', then after the download, you can start
the process. The download will complete within very less time. After the
download is completed, open the software.
o Now you have to download the Texmaker. For this, search for it in the browser
or any other search engine. Click on it and install the software. It will appear
on the desktop after the installation.

MIKTEX Overview
After the process is completed, the MiKTeX will appear as 'MiKTeX console.' When
you open this file, it will look like the image given below:
MiKTeX console is our main maintenance interface for all activities related to
MiKTeX.
Under the "Updates" section, you can update all the already installed packages.
Under "Packages," you can manage the individual packages. But make sure to click
on 'Update DB' first, before you add or remove any single package. You can also
click on the '-'and '+' sign to add or remove any package. The Update DB stands for
Update Database. The term 'package repository' is often used in this context as the
synonym for Update DB. This 'Update DB' synchronizes your local database on your
computer, which is outdated to an up-to-date database on the internet. This option is
shown below in the image:

In the above image, the column 'Packaged on' indicates the date when the packet
was added to the internet. The column 'Installed on' shows the date when the packet
was added to your local destination.
TEXSTUDIO Overview
It is termed as the Latex editor, which eases the work. With this, we do not need to
use 'command prompt' in the future. You can also make the folder to place all the
latex files at one place.

Open the Texstudio and look at the image given below:

The right upper side portion shows the text or writing window, and the left side
shows the structure window. It contains a link to chapters, sections, tables,
equations, etc.

File Types in Latex


FILE TYPES
The file sizes of the Latex are generally smaller than the Word document files. The
default extension used is .tex, which we can edit with notepad or Simpletext editor.
The Latex file contains the text as well as the commands for writing the text and
equations for the formatting of the document.
When LaTeX processes a file like abc.tex, it creates file abc.dvi, which stands
for DeVice Independent. The ‘.dvi’ is the older format than .pdf, which can be
handled by many devices. Each platform in a computer has its program and files that
can view .dvi, but you cannot send it to the printer. Most of the printers accept
PostScript (.ps). In PC, you can open this file on PC with YAP (Yet Another
Priewer) to print it. With the OzTeXT, you can directly print any file. But for UNIX,
you have to first convert the .dvi file into the .ps file. The conversion in UNIX can
be possible by using the programs such as dvips and then can send the file or data to
the printer after the conversion.
Difference between Microsoft Word and LATEX
Microsoft Word is based on the concept of WYSIWYG (What You See Is What You
Get). It means the way you type it reflects the document along with it, i.e., the final
document will look the same as you type in. We can make the changes in the
document material as we type. The changes include line spacing, font, format, text
style, page style, headings, page breaks, etc.
In LATEX, you cannot see the final document when you are typing. It allows the
users to concentrate and focus on the content rather than its design or look. It is based
on the WYSIWYM (What You See Is What You Mean). It means that you have to
concentrate on the content, rest the computer will take care of the formatting.
Is Latex a programming language?
It is a markup language that is implemented in Tex, a typesetting language. Latex is
considered as the markup extensions, which is no longer a full programming
language. It is a macro package that is indeed a programming language used for
technical typesetting documents. It means, it is written in Tex formatting macro
language. The files of the Latex are processed into the pdf.
LATEX EDITORS
Latex Editors are applications to write the Latex code and allow a user to edit and
publish the paper in Latex. Below are some commonly used Latex Editors:
o Texmaker: It is the most popular editor and has the settings of spell checking
and layout settings through the 'Quick Start' window. It is an open-source,
multi-platform Latex editor with a built-in PDF Viewer. To get started,
its configuration window allows the user to set the settings accordingly. The
warnings and errors are also displayed with the corresponding line number,
which makes the task easy for users.
o TeXnicCentre: It is primarily used for the Windows Operating System. It is
free and open-source software and uses MikTex. It is used to navigate Latex
documents and has a powerful GUI editor. To create complex formulas and
the documentation part of the scientists, it has pre-defined Latex snippets,
which makes this task easy.
o LyX: It has some modern and unique features. It is available for systems like
Windows, Linux, and macOS. With the use of its advanced scripts, you can
also create a structured novel or script. The unique feature of LyX is
its automatic index creation, which is only available in LyX. You can even
drag-drop equations and can edit them using its advanced mathematical tools.
o Texstudio: It is based on the Texmaker and further adds support and features
to it. These features include frequency count analysis, Document Word count,
and more. It is quite popular among academia. It has more than 1000
Mathematical formulas and other key features like code folding, syntax
highlighting, auto-corrections, structure viewing, and spell-checking.
o TeXworks: It also supports many features like auto-completion, Unicode
support, and auto-correction. It is considered as one of the best editors because
of its robust built-in Pdf viewer, interaction with external editors, and insertion
of graphics. It also has a built-in PDF Viewer like other editors discussed
above, but also possess an auto-synchronization feature.
The online Latex editors are:
o Papeeria: The features of an online Latex editor can be achieved by using its
web-based UI and a massive library of templates. These templates include
journals, articles, scientific magazines, etc. It also allows collaboration on the
Latex document. It can be directly accessed from your web browser.
o Authorea: It has a collaboration and template feature. It also supports many
file formats like Latex, HTML, etc. It is considered as the best web-based
editor which possesses features like insertion of images, tables, auto-creation,
ready-to-use templates, document revision history, etc.
o Overleaf: It covers hundreds of templates ranging from lab reports to
formal letters. The feature which brings transparency to the editing work is
its real-time collaboration. It has features, which make your documentation
easier. As you enter the text, the Overleaf offers the real-time preview feature,
which makes authors and editors familiar with the tool.
Some of the editors used for the Linux are:
o Gummi: It is considered as the basic editor used by the starters as it does not
contain many excellent options and tools. It is based on the GTK+ toolkit. It
lets you highlight the syntax, supports exporting the documents to PDF
format, and helps with fundamental error checking functionalities.
o TeXpen: It is also a simple tool, as the above mentioned. It has the feature of
auto-completion. It is considered as the most accessible tool of Latex. It also
helps to improve the impressions and correct the grammar mistakes in the
document.
o Kile: It is more just than an editor. Kile is available for Linux, as well as for
Windows. It is an IDE tool like Eclipse, which provides complete access to
work on projects and documents. It also has the feature of insert citations,
organization of documents, auto-completion of commands, etc.
How to use Latex
As soon as the software MikTex and Texstudio are downloaded, you can now start
your Latex. The Texmaker is used here because it is considered as the best software
used as the Latex editor. The steps to use Latex through the editor Texstudio are
given below:
o All the commands in the Latex begin with the backslash' \.'
o The first step is to open the Texstudio or any corresponding editor you are
using for the Latex.
o Here, we have used the Texstudio, and it will look like the below image:

You can click on the File menu and select New file. You can now start your
programming or writing the code on the screen.
o Let's understand the Latex programming or code by an example. We will be
writing code on the screen, and the corresponding output will be printed, after
the compilation of the code. If there are errors, then at the white bottom
window, as shown above, the errors will be displayed with the line number.
o The example is to print a 'thought of the day.' The same code is written on the
Texstudio screen.
The code is given below:
\documentclass[a4paper]{article}
\begin{document}
\begin{center}
\begin{large}
\textbf{\LaTeX\ Thought of the day}\\
\end{large}

\end{center}

"Life is really liberal to those who pursue their personal legend."


\end{document}

Explanation:
{center} is used to align the text to the center.
\textbf is used to display the text in bold.
{large} is a type of font size.
The same code on the Texstudio screen will look like the image provided below:

After writing the code, save the file and then click on the Quick Build option at the
top to view the output.
The output of this code is shown in the image below:
Similarly, you can write as much data and commands to format your document.
It depends on the user, which type and style he/she wants to use in the particular
document. Another example to write a paragraph is shown below:
\documentclass[a4paper]{article}
\begin{document}
\begin{center}
\begin{huge}
\textit{\LaTeX\ Overview}\\
%'\\' is used to display the text in the new line
\end{huge}

\end{center}

\LaTeX\ uses more iteration and floating elements such as tables and the figures
to make the document more refined and polished.%\ In between is used for the
spacing
% here % command is used to write the comments which are ignored by the Lat
ex and hence are not reflected in the output
It is a document typesetting system used for the publication of technical docum
ents. Latex software not only saves time but also makes the text more attractive
and refined. It is used by scientists, authors for the subjects such as mathematic
s, economics, psychology, engineering, etc. there are two types of editors availa
ble for the Latex, which are online and offline editors. It depends on the conven
ience and ease of the user to choose any particular editor for the Latex. The pro
cedure to write the cost makes the user concentrate on the content instead of the
format. It also has the feature of spell checking.
\end{document}.
The same code on the Texstudio screen will look like the image provided below:

The output of this code is shown in the below image:

LATEX SYMBOLS
The Latex symbols are widely used in different subjects over hundreds of categories.
For every symbol, which is used either in mathematics or other subjects, a
corresponding command is used. This topic will give you a detail idea and
explanation of the symbols, and in which way, all the symbols can be used.
With the use of standard text, you can use any symbol. This method not only saves
the efforts or time but also gives the convenience to focus more on the content
without wasting much time on finding the symbols and then proceeding with the
content.
Below is the list of the commands divided into the particular categories. The
essential commands used all over are:
o \ it is called backslash, used as the starting command. The line following it
gets printed.
o {} it is called curly brackets, which is used to group and separate commands
from its surroundings and must appear in pairs.
o \\ terminates a line.
o \\* it also terminates the line, but disallows the page break.
o [] it is used to write the optional parameters that can be passed to a command
to change its behavior.
o % The Latex ignores the rest of the line or commands after %.

SYMBOLS List:
The symbol following the \ will be printed. The commands used for the symbol and
special characters are given below:
symbol input Explanation

# \# A parameter in macro

$ \$ Used to begin and end math mode

& \& Used in alignments

_ \_ Used in math mode for subscripts and


/ \/ also used as an underscore.
It is used for Italic adjustments space.

" \" Makes an umlaut as ἅ.

{ \{ Prints a curly left-brace {


} \} Prints a curly right brace}

~ \~ Makes a tilde ᾶ

yy \yy Is used as ẙ

( \( Starts math mode


) \) Ends math mode

b \b Is a "bar under" as ẕ

bf \bf Switches to bold face type.

≠ \neq It stands for not equal


≡ \equiv Equivalent

» \gg Greater greater than

≤ \leq Less than or equal to

≥ \geq Greater than or equal to

Ͱ \vdash Used in formalization

ǁ \parallel Symbol used to indicate parallel

ǀ \mid Used as a mid

« \ll Less than


Other popular commands are also given below in the table:
Symbol Command Symbol Command

◊ \diamond ⋈ \bowtie

⋆ \star ⨝ \Join

٧ \vee ≐ \doteq

٨ \wedge ≻ \succ

П \sqcap ≺ \prec

ϵ \in ≽ \succeq

϶ \ni ≼ \preceq

⊔ \sqcup ▷ \rhd

∝ \propto ◁ \lhd

ᴖ \frown ⧐ \unrhd

ᴗ \smile ⧏ \unlhd

⊏ \sqsubset ∀ \forall
⊐ \squpset ꭥ \ohm

⊒ \squpseteq ꓱ \exists

⊑ \sqsubseteq ℓ \all
The miscellaneous symbols used are as follows:
Symbols Commands

à \grave{a}
á \acute{a}
ã \tilde{a}
â \hat{a}
ä \ddot{a}
ā \dot{a}
ȧ \bar{a}
NEGATION SYMBOLS
The negations are formed by putting either \not before the symbol or \n before the
command or word. The table for such commands is given below:
Symbols Commands

ł \nmid

≁ \nsim

≉ \not\approx

∦ \not\parallel

∥ \nparallel

≮ \nless

≰ \nleq

⪇ \lneq

⪈ \gneq

≱ \ngeq
≯ \ngtr

≠ \neq

≢ \not\equiv

≇ \ncong

≩ \gneqq

≨ \lneqq
ARROW SYMBOLS
There are various arrows used for different purposes. The commands to use these
common arrows are listed below:
Arrow Command

← \leftarrow

↑ \uparrow

→ \rightarrow

↓ \downarrow

↔ \leftrightarrow

↙ \swarrow

↕ \updownarrow

↖ \nwarrow

↗ \nearrow

↘ \searrow
LATEX LISTS
The Latex lists are used to add any additional packages. There are three types of
lists. One is the enumerate list, which produces the numbered list. The second
is itemize, which is used for the bulleted lists. The third one is the description list,
which is neither bulleted nor numbered. In Latex, each list is defined by the \item.
Through this method, sub-lists can also be created.
The example for the lists is shown below:
\begin{enumerate}
\item first point
\item second point
\begin{itemize}
\item first sub-point
\item second sub-point
\end{itemize}
\item third point
\end{enumerate}
The output of this is shown in the image below:

1. Enumerate
It is used to create numbered lists.
The simple code for the enumerate list is given below:
\documentclass{article}
\begin{document}
\begin{enumerate}
\item this is the first point
\item this is the second point
\end{enumerate}
\end{document}
The output is shown in below image:
2. Itemize
It is used to create the unnumbered list. The example is given below:
\documentclass{article}
\begin{document}
\begin{itemize}
\item this is the first point
\item this is the second point
\end{itemize}
\end{document}
The output is shown in the image given below:

3. Description
The description list is least known. It is used when you need to explain terms or
notations. The program or code for the Description list is given below:
\documentclass{article}
\begin{document}
\begin{description}
\item[Chemistry] the study of behavior of elements and compounds
\item[History] the study of past
\item[Geology] the study of the solid Earth
\end{description}
\end{document}
The output is shown in the below image:

Nested Lists
For all the above lists, Nested Lists are used to create different environments. It also
means that it is possible to have a sub-list for an item of a list. The maximum depth
for the number of levels is four. The example for the nested list is given below:
\documentclass[12pt]{article}
\begin{document}
\begin{enumerate}
\item One
\begin{enumerate}
\item First
\item Second
\item Third
\end{enumerate}
\item Two
\item Three
\end{enumerate}
\end{document}
The output is shown in the below image:

The numbering styles of the nested lists depends on the depth of the lists. Let-s
consider another example:
\documentclass[17pt]{article}
\begin{document}
\begin{enumerate}
\item first is entered
\item another item of first
\begin{enumerate}
\item Second one
\item another item of second
\begin{enumerate}
\item third is entered
\item another item of third
\begin{enumerate}
\item Fourth one
\item another item of fourth
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{document}
After writing the above code in Texstudio, the screen will look like the image
given below:
Latex lists are also categorized depending on the order, namely, ordered
list and unordered lists. The example of both these lists is given below:
1. Ordered Lists
Latex provides the enumerate environment for the ordered lists. Let us consider an
example. The code written here is used in the Texstudio to produce the output. The
example for the ordered list is given below:
\documentclass[12pt]{article}
\begin{document}
\begin{enumerate}
\item First
\item Second
\item Third
\end{enumerate}
\end{document}
The output is shown in the below image:
2. Unordered Lists
For Unordered lists, Latex provides the itemize environment. It also works without
any additional packages. In the example given below, the code is the same as that of
an ordered list, just in place of enumerate, itemize is used.
\documentclass[12pt]{article}
\begin{document}
\begin{itemize}
\item First
\item Second
\item Third
\end{itemize}
\end{document}
The output is shown in the below image:
Changing the bullet and numbering pattern/format of Latex Lists
Sometimes, it becomes necessary to change the bullets and numbering of the lists
to use a different format. As we know, for the input of a special character, $ sign
is used at the beginning and at the end. The method for both the ordered and
unordered list is given below:
Unordered lists
If you change the format from bullets to dash, then the following command is
used:
\item[--] or \item[$-$]
If you change the format from bullets to asterisk, then the following command is
used:
\item[$\ast$]
If you change the format from bullets to particular character, then the following
command is used:
\item[$ \Any character$]
The program to change the bullets is given below:
\documentclass[14pt]{article}
\begin{document}
\begin{itemize}
\item[--] Dash
\item[$-$] Dash
\item[$\ast$] Asterisk
\item[$\#$] hash character used
\end{itemize}
\end{document}
The output of the above code in the Texstudio is given below:
Ordered lists
It is a tricky process if you want to change the environment. The easiest step is
to use the enumitem environment. This is used with the usepackage command
like usepackage{enumitem}.
The code for the following lists is given below:
\documentclass[12pt]{article}
\usepackage{enumitem}
\begin{document}
\begin{enumerate}[label=(\alph*)]
\item one item
\item two item
\begin{enumerate}[label=(\arabic*)]
\item third item
\item fourth item
\begin{enumerate}[label=(\roman*)]
\item fifth item
\item sixth item
\end{enumerate}
\end{enumerate}
\end{enumerate}
\end{document}
After writing the above program, the Texstudio screen will look like the below
image:
Itemize
In this type of lists, the renewcommand is used to change the bullets size at
different levels. Let-s understand this by an example. The commands can be used
for the formats to replace the bullet points. The example is given below:
\documentclass{article}
\begin{document}
\renewcommand{\labelitemi}{$\ast$}
\renewcommand{\labelitemii}{$\cdot$}
\renewcommand{\labelitemiii}{$\diamond$}
\begin{itemize}
\item this is the first point
\begin{itemize}
\item this is the second point
\begin{itemize}
\item this is the third point
\end{itemize}
\end{itemize}
\end{itemize}
\end{document}
The output is shown in the below image:
Spacing arguments
These commands are used to change the spacing parameters of the list. Depending
on the document styles and option, the null{} command commonly used here, will
select the default spacings.
The spacing commands, which can be used here, are mentioned below:
o \itemsep: used for extra vertical spaces between the items
o \rightmargin: horizontal distance between the right margin and the lists of
the environment
o \leftmargin: horizontal distance between the left margin and the lists of the
environment
o \topsep: extra vertical spaces at the top of the list
o \labelsep: the separation between the first line of an item and the end of the
box containing a label.
o \labelwidth: the normal width of the box, which contains the label
o \parsep: the vertical spaces between the paragraphs within the items.
o \makelabel{label}: used to generate the label, printed by the \item command
Latex Fonts Size and Styles
Latex Fonts:
Latex Paper size and font size
We usually define the paper size and the font size inside the square brackets [].
The point size can be described in the way [10pt]. The other font sizes are 8pt, 9pt,
10pt, 11pt, 12pt, 14pt, 17pt, 20pt.
The default font size for Latex is 10pt.
The paper types with their dimensions are given below:
o letterpaper (11 x 8.5 in)
o legalpaper (14 x 8.5 in)
o a5paper (5.8 x 8.3 in)
o a4paper (8.3 x 11.7 in)
o executivepaper (10.5 x 7.25 in)
o b5paper (25 x 17.6 cm)
LATEX TYPE SIZE
The default font size or type size that Tex produces is 10pt. There are some of the
declarations which are used for changing the type size. The table for all the type
sizes along with commands is shown below:

In the above sequence, \tiny is the smallest while \Huge is the largest. To
understand, let's consider an example shown below:
\documentclass[a4paper]{letter}
\begin{document}
\begin{center}
\begin{huge}
\textbf{The \LaTeX\ Technical Institute}\\
\end{huge}
\begin{LARGE}
\textsc{\\Certification}
\end{LARGE}
\end{center}
\noindent This to certify that Mr. R.P Sharma has undergone a course in this ins
titute and is qualified to be Technical Expert.
\begin{flushright}
\textsf{The Director}\\
The \LaTeX\ Technical Institute
\end{flushright} %used for aligning to the right
\end{document}
The output of this code is shown in the image below:

LATEX STYLES

The styles are categorized into family, series, and shape. The typestyle in the output
is composed of these three characteristics.

The table for the styles is given below:

Style command

Roman \textrm{roman}

Typewriter \texttt{typewriter}

Sans serif \textsf{sans serif}

The table for the series is given below:

Style command

boldface \textbf{boldface}
medium \textmd{medium}

The table for the shape is given below:

Style command

italic \textit{italic}

slanted \textsl{slanted}

upright \textup{upright}

SMALL CAP \textsc{small cap]

The way or procedure to use these three categories is given below:

\documentclass{article}
\begin{document}
\textit{\textbf{ the topic discussed is Latex.}}
\textrm{\textsl{ it contains the process and characteristics}}
\end{document}

If you want to display the above text in separate lines, \newline command is used as
shown below:

\documentclass{article}
\begin{document}
\textit{\textbf{ the topic discussed is Latex.}\newline}
\textrm{\textsl{ it contains the process and characteristics}}
\end{document}
Output:

The other commands commonly used are given below, which will be implemented
further in this project.

o flushright and flushleft: These commands are written


as \begin{flushright} or \begin{flushleft}. These are used for aligning the
text to the right and left of the document.
o \noindent: If you want to start any paragraph without an indent or to continue
the paragraph without any interruption, this command is used.

Latex Colors

The xcolor package supports adding colors to your text. Using this, you can set the
background, font color, and the page background. You can choose colors from the
predefined colors or can create your color using RGB. The formulas of mathematics
can also be colored.

The package which is imported in the code or program is written as:

1. \usepackage{xcolor}

The commands used to access different numbers of colors are listed below:

o usenames: It allows access to16 base colors.


o dvipsnames: It allows access to 64 more colors.
o svgnames: It allows access to about 150 colors.
o x11names: It offers more than 300 colors.

These commands mentioned above are declared in the code as:

1. \documentclass[dvipsnames, usenames]{beamer}
The commands for entering the colored text are listed below:

There are two ways of typing the colored text. One is by using
the \textcolorcommand, and another is by using the \color command.

The textcolor command is declared as \textcolor{mentioned-color}{text}.

The color command is declared as {\color{mentioned-color}some text}.

The textcolor command is used for all in one paragraph, while the color command
is used for the text to run over other tex environments and the multiple lines.

To change the background color, you can use the command \pagecolor{mentioned-
color}. This command colors the background of a whole page.

To color the background of the text, you can use the \colorbox{mentioned-
color}{text} command.

If you want to change both the background and the text color, you can use the
command in a way as mentioned below:

1. \colorbox{mentioned-color}{text}{\color{mentioned-color}text}

The primary colors used everywhere or which are the root of all the colors
are red, yellow, and blue(RYB). The three secondary colors are orange, purple, and
green, which is formed by mixing two primary colors. There are six tertiary colors,
which are formed by the mixing of primary and secondary colors.

The predefined colors available on all the systems are listed below:
The other predefined colors are listed below:
Let's consider a simple example to color the text. The code is given below:

1. \documentclass[12pt]{article}
2. \usepackage[dvipsnames]{xcolor} % declaring the package is necessary to i
mplement colors
3.
4. \begin{document}
5. The text is written here.\\
6. \textcolor{red}{the purpose of learning \LaTeX\ is great.}\\ %this \LaTeX\
pattern is used to print the default layout of the work Latex.
7. This is also the text
8. \end{document}

Output:
\documentclass[12pt]{article}
\usepackage[dvipsnames]{xcolor}
\begin{document}
\textcolor{red}{This the text} \\
\textcolor{magenta}{the purpose of learning \LaTeX\ is great.} \\
\textcolor{yellow}{the lines of different colors}\\
\textcolor{pink}{the text is written above} \\
\textcolor{green}{The software used is Texmaker.} \\
\textcolor{orange}{the text is a combination of words and sentences.}
\end{document}

Output:

Text Highlight
There are commands used to highlight the text. You can choose any color to
highlight your text, depending on your requirements. You need a soul package with
the xcolor package to implement the highlighted text.

The soul package is written as \usepackage{soul}


The command to highlight the text is written as \hl{ any text}. Here 'hl' command
is used as highlight caption.

The simple code to highlight the text is given below:

\documentclass[12pt]{article}
\usepackage[dvipsnames]{xcolor}
\usepackage{soul}
\begin{document}
\begin{center}
\textbf{\color{red}The highlighted text below :}
\end{center}
The text given here is the \hl{highlighted text.}
\end{document}

You can see in the above example, we have used the bold command, color, and the
highlight command.

The output is shown in the below image:

To specify the color highlight, you need to use the \sethlcolor{color name}
command. You can also use many color highlights in a single program.

The code for the color highlight is given below:

\documentclass[12pt]{article}
\usepackage{xcolor, soul}% you can also write both the packages in this format
\begin{document}
\begin{center}
\textbf{\color{blue}The color highlighted text below :}
\end{center}
\sethlcolor{pink}
The text given here is the \hl{highlighted text in pink.}\\
\sethlcolor{orange}
The text given here is the \hl{highlighted text in orange.}
\end{document}

Output:
Latex Images

The images are used to enhance the information in a document or in any file. In most
of the scientific documents, pictures are essential. In Latex, you can enlarge, shrink,
rotate, and can set the reference of the image in your document.

Latex does not insert the picture itself.

The basic requirements to insert an image are:

o Including the graphicx package. The command will be written


as \usepackage{graphicx}.
o You need to download the particular image from the browser and save that
image in the same folder where the Latex files are present. Otherwise, Latex
cannot access those images. Mention the same in the code or program that you
have mentioned while saving that particular image.

Let's consider a simple example to insert an image. The code is written below:

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
The lion is the king of jungle.\\
\includegraphics[scale=0.1]{lion}
\end{document}

Output:
You can insert many pictures in your document, depending on the requirements.

The code to insert two images is given below:

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
Some stars are visible with the naked \\ eye in the night while some are not.\\
\includegraphics[scale=0.5]{star}\\ % star and star1 are the images saved with t
hese names.
The group of stars is called cluster.\\
\includegraphics[scale=0.25]{star1}
\end{document}

Output:
Path Specification

Sometimes, there are a large number of images present on your computer in different
folders. To insert those images directly in your Latex document, you can specify the
path using the \graphicspath{{ path}} command.

Let's consider the path-images. The command will be written as \graphicspath{{


\images}}. You need to create the folder by the name 'images' so that Latex can
easily insert images or pictures into the document through this path.

The example is given below:

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\graphicspath{ {images/} }
\includegraphics[scale=0.65]{cloud}\\
The image of the cloud is given above.
\end{document}
We have first created the images folder in the location where the Latex files are
present. You can save several images in that folder and can access those directly.

Output:

Changing the size of Image


You can specify the height and width of the image according to the requirements.
The example is given below:

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\graphicspath{ {images/} }
\includegraphics[width=6cm, height=4cm]{smiley}\\
The image of a smiley is given above.
\end{document}

Output:

Here, you can use any path and dimensions according to the requirements.
Rotation of Image

You can rotate any image by specifying the angle in


the \includegraphics command. Let's consider a single picture of a butterfly.

The code for such type is given in the below example:

\documentclass[12pt]{article}
\usepackage{graphicx}
\begin{document}
\graphicspath{ {images/} }
\includegraphics[scale=0.2, angle=50]{butterfly}\\
The rotated image is shown above.
\end{document}

Output:
Image alignment
In the image alignment, two commands are used. The first command
is \baselineskip, which is used to generate vertical line spacing. The second
command is the \quad, which is used to maintain the horizontal space. It has only a
width.

If you want to align the images in the matrix form, then make sure that the width
mentioned of all the photos is equal.

The code to arrange the six images in matrix form is given below:

\documentclass{article}
\usepackage{graphicx}
\begin{document}
\begin{center}
\graphicspath{ {images/} }
\includegraphics[width=.2\linewidth]{smiley}\quad
\includegraphics[width=.2\linewidth]{smiley}\quad
\includegraphics[width=.2\linewidth]{smiley}
\\[\baselineskip]% adds vertical line spacing
\includegraphics[width=.2\linewidth]{cloud}\quad
\includegraphics[width=.2\linewidth]{smiley}\quad
\includegraphics[width=.2\linewidth]{cloud}
\end{center}
\end{document}

LATEX MATH SYMBOLS

The math or mathematical symbol are those symbols, which are used as an
intermediate to perform the mathematical functions. The variables and functions in
mathematics are used for various purposes.

The command $ is recommended as the math mode. The input commands mentioned
below are inserted between the $ to produce the corresponding output.

The most used math type commands are given below:

Input Output (math Input Output (math


commands mode) commands mode)

\| ǁ \leq ≤

\alpha α \lnot ¬

\ast * \mid |

\bigodot ʘ \mu µ
\approx ≈ \pm ±

\bullet ● \P ¶

\copyright © \div ÷

\Box □ \prod ∏

\downarrow ↓ \perp ꓕ

\delta ∆ \sqrt √

\geq ≥ \int ∫

\gets ← \oe œ

\gg » \mho Ʊ

\infty ∞ \deg deg

Other popular math symbols are:

Output Input Commands

± \pm

∞ \infty

≠ \neq

= \eq

~ \sim

× \times

÷ \div

∝ \propto

< \less
≤ \leq

≪ \ll

> \gtr

≫ \gg

∂ \partial

∓ \mp

≅ \cong

≈ \approx

≡ \equiv

∀ \forall

∁ \complement

+ \plus

√ \surd

θ \theta

∪ \cup

∩ \cap

∅ \phi

∆ \traingle

∇ \nabla

∃ \exists

∄ \nexists

∈ \in
∋ \ni

← \leftarrow

↑ \uparrow

¬ \neq

∴ \therefore

↔ \leftrightarrow

∎ \blacksquare

⋱ \ddots

⋯ \cdots

⋮ \vdots

\ \diagdown

/ \diagup

ꭥ \ohm

ℵ \aleph

℘ \wp

∠ \angle

♣ \clubsuit

♠ \spadesuit

♦ \blacklozenge

⊕ \oplus

ln \ln

log \log
ϴ \ominus

ʃ \int

ℓ \ell

℗ \circledP

ℵ \aleph

ℶ \beth

ℏ \hslash

ℜ \Re

ℕ \N

ℝ \R

ℚ \Q

ℤ \Z

↺ \circlearrowleft

↻ \circlearrowright

↶ \curvearrowleft

↷ \curvearrowright

⇊ \downdownarrows

↩ \hookleftarrow

↪ \hookrightarrow

↫ \looparrowleft

Some other commonly used symbols are listed in the below table:
Symbol Commands

∮ \oint

∬ \iint

∭ \iiint

∩ \cap

∪ \cup

≑ \doteqdot

≖ \eqcirc

≗ \circeq

≍ \asymp

≲ \lesssim

≳ \gtrsim

⊂ \subset

⊃ \supset

≒ \fallingdotseq

≎ \Bumpeq

⊆ \subseteq

⊇ \supseteq

⊈ \nsubseteq

⊉ \nsupseteq

⊏ \sqsubset

⊐ \sqsupset
⊑ \sqsubseteq

⊒ \sqsupseteq

⊓ \sqcap

⊔ \sqcup

⊗ \otimes

⊖ \ominus

⊘ \oslash

⊠ \boxtimes

⊡ \boxdot

⋬ \ntrainglelefteq

⦾ \circledcirc

⨄ \uplus

⊛ \circledast

Greek Symbols

The Greek symbols are listed below:

Symbols Input Commands

α \alpha

β \beta

γ \gamma

δ \delta

ε \varepsilon
ϵ \epsilon

ϑ \vartheta

μ \mu

π \pi

ρ \rho

σ \sigma

τ \tau

φ \varphi

ω \omega

χ \chi

Π \prod

Σ \sum

Λ \wedge

V \vee

η \eta

ς \varsigma

ζ \zeta

λ \lambda

ϒ \Upsilon

ϖ \varpi

Trigonometric functions

The trigonometric functions are listed in the table below:


Functions Commands

cos \cos

sin \sin

tan \tan

cot \cot

sec \sec

cosec \cosec

csc \csc

arcsin \arcsin

arccos \arccos

arctan \arctan

arcsec \arcsec

arccot \arccot

sinh \sinh

cosh \cosh

tanh \tanh
Brackets The brackets in your document are used for various purposes. Let’s
consider an alphabet a, to understand the format of brackets. The brackets are
listed in the below table:
Brackets Input commands

⟨a \langle

a⟩ \rangle

{ \lbrace
} \rbrace

| \lvert

| \rvert

ǁa \lVert

aǁ \rVert

⌊a \lfloor

a⌋ \rfloor

⌈a \lceil

4⌉ \rceil

Latex Mathematical Equations

The equations are used in the document, either in Microsoft Word or in the Latex.
In Latex, you can easily write the equations using the commands. You can quickly
insert such commands to write the equations between or anywhere in your document
with the use of simple text. You need not to search for the equations or symbols on
the menu bar as compared to the others.

The environment used to implement the mathematical command and equations is


given below:

1. \begin{equation}
2. ...........
3. \end{equation}

The package used to implement the mathematical command and equations is given
below:

1. \usepackage{amsmath}
Or
1. \usepackage{mathtools}

The mathtools package also loads the amsmath package. Hence, from the above
two packages, either one can be used.

Let's understand with a simple example of equation x + y = 4.

The code for such an example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
x + y = 4 % there should be no gap between any of the two rows
\end{equation}
\end{document}
Output:

You can also write the equation of any order.

The code to write the second-order equation is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
x^2 +2x+ 6 = 0
\end{equation}
\end{document}

Output:

Let's consider another example to write the equations. The code is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
x^3 - y^2 = 23
\end{equation}
\end{document}

Output:

If you're going to write the numbers, etc. in the infinite or finite series format, then
you can use the command given in the below code:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
1, 2, 3, 4, 5, 6........... \infty
\end{equation}
\end{document}

Output:

You can also write a simple equation in different formats. The code for such an
example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{equation}
10 \text{oranges} \times 2 \text{dozens of oranges} = 120 \text{oranges}
\end{equation}
\end{document}

Output:
You can also write several equations in your document, depending on the
requirements. The equation number will be adjusted automatically according to the
equations. But you need to use a separate environment for every equation.

The code for such type of example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{equation} % to implement equations more than one, you need to use a se
parate equation environment for every equation.
x^3 + y^3 = 9
\end{equation}
\begin{equation}
x^2 + 2x + 4 = 0
\end{equation}
\begin{equation}
y^2 + 4y = 5
\end{equation}
\end{document}

Output:

You can also perform the derivation anywhere in your document using the
commands discussed so far.
Let's understand the concept of derivation with a simple example.

The example is of newton's equation of motion.

The code for such type of an example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}

\begin{center}
The three equations of motion are: \\
\end{center}

\begin{equation} % to insert extra space between equations, you can leave spac
e between the equation environments. But you should not leave space inside an
y environment.
v = u + at
\end{equation}

\begin{equation}
v^2 = u^2 + 2as
\end{equation}

\begin{equation}
s = ut + 1/2at^2
\end{equation} \\
where,\\
s = displacement; \\
u = initial velocity; \\
v = final velocity; \\
a = acceleration; \\
t = time of motion

\end{document}
Output:

Operators

An operator is defined as a function, written in the form


of logarithmic functions, trigonometric functions, exponential functions and
limits.

Let's consider an example of the above three functions.

Latex introduces a simple way to use the trigonometric functions, exponential


functions, and logarithmic functions and to display in the form of equations.

1) Let's consider two examples of the trigonometric functions.

The code for the first example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}

\begin{equation}
\cos^2 \theta + \sin^2 \theta = 1
\end{equation}

\end{document}

The code for the second example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}

\begin{equation}
cos2 \theta = 1 - 2sin^2\theta % you can specify any equation according to the r
equirements.
\end{equation}

\end{document}

Let's consider two examples of the exponential functions and limits.

The code for the first example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}

\begin{equation}
\lim\limits_{x \to n-1} \exp(x) = 0
\end{equation}

\end{document}
Output:
The code for the second example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}

\begin{equation}
\lim\limits_{x \to \infty} \Sigma f(x) = 0
\end{equation}

\centering
where,

\begin{equation}
f(x) = 3x^3 + 2x^2 - 4ax +2 = 0
\end{equation}

\end{document}

Here, you can also combine different forms and types of mathematical equations
depending on the requirements.

Output:
Power and Indices

The power and indices are considered similar to the superscripts and subscripts in
the standard text.

The curly brackets {} are used to enclose the power of more than one digit.

The subscript notation is mentioned in Latex using the underscore symbol (_).

You can also insert the vertical bar in the equations using the | symbol.

Let's understand it with some examples.

The code for the first example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}

\begin{equation}
k_n = k_{n-1} + k_{n-2}
\end{equation}

\end{document}

Output:
The code for the second example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{center}

\begin{equation}
a^{12} \times a^{22} = a^{34}
\end{equation}
where,\\
12 + 22 = 34 \\
equation 1 signifies that the powers are added when multiplied.

\begin{equation}
b^9 \div b^4 = b^5
\end{equation}
where,\\
9 - 4 = 5 \\
equation 2 signifies that the powers are subtracted when divided.

\end{center}
\end{document}

Output:
The code for the third example is given below:

\documentclass[12pt]{article}
\usepackage{mathtools}
\begin{document}
\begin{center}

\begin{equation}
f(x) = x^3 + 2x^2 + 4x + 2 |_{x = -2}
\end{equation}

\end{center}
\end{document}

Output:

You might also like