0% found this document useful (0 votes)
11 views

Common elements

Uploaded by

saifamu2000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Common elements

Uploaded by

saifamu2000
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

 Every latex document should start with this...

.. This command is available for the document classes article and report, but not book. By default, LaTeX will use the word "Abstract" as a title
for your abstract. If you want to change it into anything else, e.g. "Executive Summary", add the following line before you begin the abstract
\documentclass[options]{class} environment:

[options]: \renewcommand{\abstractname}{Executive Summary}


 10pt (default), 11pt, 12pt
 a4paper, legalpaper, letterpaper(default)  Sectioning Commands
 titlepage, notitlepage
 twocolumn
{class}: \chapter{Introduction}
 article This chapter's content...
 IEEEtran
 book \section{Structure}
 exam This section's content...
 report
 memoir \subsection{Top Matter}
 letter This sub section's content...
 beamer
 assignment \subsubsection{Article Information}
 beaulivre This sub subsection's content…
 beautybook
 bookest  Linespread
 colorist
 examdesign \linespread{factor}
 lebhart
 limecv
 Moderncv If you want to use larger inter-line spacing in a document, you can change its value by putting the linespread command into the preamble of
 tikzposter your document. Use \linespread{1.3} for "one and a half" line spacing, and \linespread{1.6} for "double" line spacing. Normally the lines are
not spread, so the default line spread factor is 1.
 Packages can be imported in the preamble of the document like this…
 Stretched spaces
\usepackage[option1,option2,option3]{package_name}
You can insert a horizontal stretched space with \hfill in a line so that the rest gets "pushed" toward the right margin. For instance this
 Top Matter may be useful in the header and also in putting date in an application. /vfill may also be used.

\documentclass{book}
\usepackage{lipsum}
 Justification

%TOP MATTER--------- \begin{flushleft}


\title{My Title} Left justify … {\raggedleft …..}
\author{SUB} \end{flushleft}
\date{\today} \begin{flushright}
%TOP MATTER--------- Right justify … {\raggedright}
\end{flushright}
\begin{document} \begin{center}
\maketitle %PUT IT HERE Center justify … \centering
\lipsum[1] \end{flushleft}
\end{document}
 Paragraph Indentation
 Abstract
\setlength{\parindent}{1cm}
\begin{abstract} This will set paragraph indents to 1cm. May be used after Dear Sir, …
Your abstract goes here...
...
\end{abstract}
e.g.
\documentclass{article}
\usepackage[a4paper, lmargin=1cm, rmargin=1cm, top=6cm, bottom=5cm]{geometry}
\setlength{\parindent}{1cm}
\begin{document}
Paragraph1: Indented paragraph\par
\noindent
Paragraph2: Non-indented paragraph\par
Paragraph3: Indented paragraph\par
\noindent
Paragraph4: Non-indented paragraph
\end{document}
 Paragraph spacing
Output:
\setlength{\parskip}{0.3cm}

 xcolor package

\usepackage{xcolor}
Using this package, you can set the font color, text background, or page background. You can choose from predefined colors or define your
own colors using RGB, Hex, or CMYK. Mathematical formulas can also be colored. The package allows you to use the names of 19 base
colors (black, white, blue, green, yellow, red etc.); these names are always available. Besides, the package has some options to get more
predefined colors, which should be added globally. dvipsnames allows you to access more than 60 colors, and svgnames allows access to
about 150 colors. If you need more color names, then you may also want to look at the x11names option that offers more than 300 colors.
The table option allows colors to be added to tables.
The simplest way to type colored text is by:

\textcolor{declared-color}{text}
where declared-color is a color that, if necessary, was previously defined by \definecolor.

Another possible way is by:


 Line Break
{\color{declared-color}some text}
\\ or \par or \newline ends the current paragraph or line.
 Declaring colors using xcolor
 Verbatim text
\definecolor{mybluei}{RGB}{0,173,239}
\documentclass{article}
\usepackage[a4paper, lmargin=1cm, rmargin=1cm, top=6cm, bottom=5cm]{geometry} Example:
\begin{document} \documentclass{article}
Verbatim section will not be interpreted by compiler and will be recognized as text and will \usepackage{xcolor}
appear as it is typed. Very useful for typesetting source code. \usepackage[a4paper, lmargin=1cm, rmargin=1cm, top=6cm, bottom=5cm]{geometry}
\begin{verbatim} \definecolor{bf2042}{RGB}{71,245,204}
\documentclass{class} \begin{document}
\begin{document} This is a normal sentence containing a
content... \fcolorbox{black}{bf2042}{highlighted text}.
\end{document} \end{document}
\end{verbatim}
\end{document}
Output:
Output:
Example:
\documentclass{article}
\usepackage[dvipsnames]{xcolor}
\usepackage[a4paper, lmargin=1cm, rmargin=1cm, top=6cm, bottom=5cm]{geometry}
\begin{document}
This is a normal sentence containing a
\fcolorbox{blue}{Apricot}{highlighted text}.
\end{document}

 Highlighted text using xcolor Output:


\colorbox{declared-color}{text}

Example:
\documentclass{article}
\usepackage{xcolor}
 Font families
\usepackage[a4paper, lmargin=1cm, rmargin=1cm, top=6cm, bottom=5cm]{geometry}
\begin{document} Font families can generally be grouped into three main categories: serif, sans serif, and monospaced. LaTeX commands generally refer to
This is a normal sentence containing a these with the shorthand rm, sf, and tt respectively. The bodies of LaTeX documents are set in Roman (serif) type by default, but this can
\colorbox{yellow}{highlighted text}. be changed by setting the family default:
\end{document} \renewcommand{\familydefault}{<family>}
where <family> is any of the following:
 \rmdefault
Output:  \sfdefault
 \ttdefault

 Font styles

Latex Command Description

\textsf{…} Sans serif font family

\texttt{…} Teletype font family


Example:
\documentclass{article} \textit{…} Italicized font
\usepackage{xcolor}
\usepackage[a4paper, lmargin=1cm, rmargin=1cm, top=6cm, bottom=5cm]{geometry} \textsc{…} Small capital
\begin{document}
This is a normal sentence containing a \uppercase{…} Uppercase
\colorbox{black}{\color{white}highlighted text}.
\textbf{…} Bold
\end{document}
\textlf{…} Light
Output:
 Font sizes
All lists follow the basic format:
\begin{list_type}
Command
\item {The first item}
\item The second item
\tiny \item The third etc \ldots
\end{list_type}
\scriptsize
Example:
\footnotesize \documentclass{article}
\usepackage{blindtext}
\small \begin{document}

\normalsize \begin{itemize}
\item \blindtext
\item \blindtext
\large \end{itemize}

\Large \begin{enumerate}
\item \blindtext
\LARGE \item \blindtext
\end{enumerate}
\huge
\begin{description}
\item [Ant] \blindtext
\Huge \item [Elephant] \blindtext
\end{description}

These commands change the size within a given scope. For instance {\Large some words} will change the size of only some words, and \end{document}
does not affect the font in the rest of the document.
 Inline enumeration using enumitem
 Alternative Fonts
\documentclass[twocolumn]{article}
If you are using lualatex or xelatex, you can use TTF and OTF fonts with the fontspec package: \usepackage[inline]{enumitem}
\usepackage{xcolor}
\documentclass{article} \begin{document}
\begin{enumerate*}[label={\alph*)},font={\color{red!50!black}\bfseries}]
\usepackage{fontspec} \item bananas
\setmainfont[Ligatures=TeX]{Georgia} \item apples
\setsansfont[Ligatures=TeX]{Arial} \item oranges and
\item lemons.
\begin{document} \end{enumerate*}
Lorem ipsum... \end{document}
\end{document}
 Horizontal list
 List structures
If you want a horizontal list, package tasks can be handy. In combination with a package like exsheets, you can prepare exam papers for
List structures in LaTeX are simply environments which essentially come in three types: students.
\documentclass[12pt]{article}
 itemize for a bullet list \usepackage{tasks}
 enumerate for an enumerated list and \begin{document}
 description for a descriptive list. Which one of the entries does not fit with the others?
\begin{tasks}(4)
\task mercury
\task iron
\task lead
\task zinc Text Wrapping in tables
\end{tasks}
\begin{tabular}{ | l | l | p{5cm} | }
\settasks{
\hline
label=(\roman*),
Sl. No. & Name & Expenditure\\
label-width=4ex
\hline
}
1 & George & Rs. 1800/-\\
\hline
What is a funkyton?
2 & John & Rs. 900/-\\
\begin{tasks}(2)
\hline
\task A dancing electron
\end{tabular}
\task A dancing proton
\task A dancing neutron
\task A Dixie Dancing Duck
\end{tasks}
\end{document}

Output:

Spacing between Rows

\renewcommand{\arraystretch}{1.5}

Rows spanning multiple columns

The command for this looks like this: \multicolumn{num_cols}{alignment}{contents}.


num_cols is the number of subsequent columns to merge; alignment is either l, c, r, or to have text wrapping specify a width p{5.0cm} .
And contents is simply the actual data you want to be contained within that cell.

\begin{tabular}{ |l|l| }
\hline
\multicolumn{2}{|c|}{Team sheet} \\
\hline
GK & Paul Robinson \\
LB & Lucas Radebe \\
 Tables DC & Michael Duberry \\
DC & Dominic Matteo \\
RB & Dider Domi \\
LaTeX has built-in support to typeset tables and provides two environments: tabular and table. To typeset material in rows and columns,
MC & David Batty \\
the tabular environment is needed; the optional table environment is a container for floating material similar to figure, into which a tabular
MC & Eirik Bakke \\
environment may be included. The table environment contains the caption and defines the float for the table, i.e., where in the document
MC & Jody Morris \\
the table should be positioned and whether we want it to be displayed centered. The \caption and \label commands can be used in the FW & Jamie McMaster \\
same way as for pictures. ST & Alan Smith \\
ST & Mark Viduka \\
\begin{center} \hline
\begin{tabular}{ l | c | r } \end{tabular}
\hline
1 & 2 & 3 \\ \hline
4 & 5 & 6 \\ \hline
7 & 8 & 9 \\
\hline
\end{tabular}
\end{center}
Columns spanning multiple rows \caption{This table shows some data}
\label{tab:myfirsttable}
\end{table}
The first thing you need to do is add \usepackage{multirow} to the preamble. This then provides the command needed for spanning
rows: \multirow{''num_rows''}{''width''}{''contents''}. The arguments are pretty simple to deduce (* for the width means
the content's natural width). [position specifier]:
\begin{tabular}{ |l|l|l| }  h: here
\hline  t: top of page
\multicolumn{3}{ |c| }{Team sheet} \\  b: bottom of page
\hline  !: override
Goalkeeper & GK & Paul Robinson \\ \hline
\multirow{4}{*}{Defenders} & LB & Lucas Radebe \\ --------------------------------TITLE CREATION---------------------------------------
& DC & Michael Duburry \\
& DC & Dominic Matteo \\  Standard titles
& RB & Didier Domi \\ \hline
\multirow{3}{*}{Midfielders} & MC & David Batty \\ The standard classes provide just four storing commands (\title, \author \thanks and \date).
& MC & Eirik Bakke \\
& MC & Jody Morris \\ \hline
The actual title will be typeset by issuing the command \maketitle
Forward & FW & Jamie McMaster \\ \hline
\multirow{2}{*}{Strikers} & ST & Alan Smith \\
& ST & Mark Viduka \\ \documentclass{article}% use option titlepage to get the title on a page of its own.
\hline \usepackage{blindtext}
\end{tabular} \title{A Sample Paper \thanks{My Parents}}
\date{2017\\ December}
\author{John Doe\\ Magic Department\thanks{Happy}, AMU
\and Richard Row, NIT Academy}
\begin{document}
\maketitle
\section{Introduction}
\blindtext
\end{document}

Changing font size

{\Large
\begin{tabular}{| r | r || c | c | c |}
% ...
\end{tabular}
}

Float with tables

\begin{table}[position specifier]
\centering
\begin{tabular}{|l|}
... your table ...
\end{tabular}
\documentclass[12pt,a4paper]{report}
\usepackage{mwe} % FOR SAMPLE LOGO
\begin{document}
\begin{titlepage}
\centering
\includegraphics[width=0.15\textwidth]{example-image-1x1}\par\vspace{1cm}
{\textsc{Jacksonville State University} \par}
\vspace{1cm}
{\Large \textsc{Final year project}\par}
\vspace{1.5cm}
{\huge\bfseries Pigeons love doves\par}
\vspace{2cm}
{\Large\itshape John Birdwatch\par}
\vfill
supervised by\par
Dr.~Mark \textsc{Brown}

\vfill

% Bottom of the page


{\large \today\par}
\end{titlepage}
\end{document}

---------------------PAGE LAYOUT---------------------------------------------------
Documents can be either one- or two-sided. Articles are by default one-sided, books are two-sided. Two-sided documents differentiate the
left (even) and right (odd) pages, whereas one-sided do not. The most notable effect can be seen in page margins. A page in LaTeX is defined
by many internal parameters. Each parameter corresponds to the length of an element of the page, for example, \paperheight is the
physical height of the page. Here you can see a diagram showing all the variables defining the page. All sizes are given in TeX points (pt),
there are 72.27pt in an inch or 1pt ≈ 0.3515mm.
One of the most versatile packages for page layout is the geometry package. The immediate advantage of this package is that it lets you --------------------------------------PAGE HEADERS AND FOOTERS------------------------------------------------------------------
customize the page size even with classes that do not support the options. For instance, to set the page size, add the following to your
preamble:
 Page Style
\usepackage[a4paper]{geometry}
The possibilities of changing the headers in plain Latex are actually quite limited. There are two commands available:
This package allows you to specify the 4 margins without needing to remember the particular page dimensions commands. \pagestyle{''style''} will apply the specified style to the current and all subsequent pages, and \thispagestyle{''style''} will
only affect the current page. The possible styles are:
\usepackage[top=1in, bottom=1.25in, left=1.25in, right=1.25in]{geometry}
empty Both header and footer are cleared
 Top margin above margin Header is clear, but the footer contains the page
plain
number in the center.
The top margin above a chapter can be changed using the titlesec package.
Footer is blank, header displays information
headings according to document class (e.g., section name)
 Orientation of the whole document and page number top right.
Page number is top right, and it is possible to control
\usepackage[landscape]{geometry} myheadings
the rest of the header.

 Page Background The commands \markright and \markboth can be used to set the content of the headings by hand. The following commands placed at
the beginning of an article document will set the header of all pages (one-sided) to contain "John Smith" top left, "On page styles" centered
There are many ways on implementing background for a page. Below is most common packages used: and the page number top right:
 eso-pic package will let you print content in the background of every page or individual pages.
 background package let users include watermarks and pictures in the background. \pagestyle{myheadings}
\markright{John Smith\hfill On page styles\hfill}
 Manual Page Formatting
There are special commands containing details on the running page of the document.
\thepage number of the current page
\newpage Ends the current page and starts a new one. \leftmark current chapter name printed like "CHAPTER 3. THIS IS THE CHAPTER TITLE"
\pagebreak[number] Breaks the current page at the point of the command. The \rightmark current section name printed like "1.6. THIS IS THE SECTION TITLE"
optional number argument sets the priority in a scale from 0 \chaptername the name chapter in the current language. If this is English, it will display "Chapter"
to 4. \thechapter current chapter number
\nopagebreak[number] Stops the page being broken at the point of the command. \thesection current section number
The optional number argument sets the priority in a scale
from 0 to 4. Moreover, with the following commands you can define the thickness of the decorative lines on both the header and the footer:
\clearpage Ends the current page and causes any floats encountered in \renewcommand{\headrulewidth}{0.5pt}
the input, but yet to appear, to be printed. \renewcommand{\footrulewidth}{0pt}

 To have more space between paragraphs use in preamble \setlength{\parskip}{8pt}  Customizing with fancyhdr

To begin, add the following lines to your preamble:

\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}

The following commands puts custom things in header and footer.


\lhead{}
\chead{}
\rhead{} b Position at the bottom of the page.

And… p Put on a special page for floats only.


! Override internal parameters LaTeX uses for determining "good" float positions.
\lfoot{}
\cfoot{} H Places the float at precisely the location in the LaTeX code.
\rfoot{}
Use \listoffigures to add a list of the figures in the beginning of the document. To change the name used in the caption from Figure to
For odd/even pages, Example, use \renewcommand{\figurename}{Example}

 Page n of m  Wrapping text around figures

Some people like to put the current page number in context with the whole document. LaTeX only provides access to the current page To use wrapfig, you must first add this to the preamble:
number. However, you can use the lastpage package to find the total number of pages, like this:
\usepackage{wrapfig}
\documentclass{book} This then gives you access to:
\usepackage{lipsum}
\usepackage{lastpage} \begin{wrapfigure}[lineheight]{position}[overhang]{width}
\usepackage{fancyhdr}
\pagestyle{fancy} There are overall eight possible positioning targets:
\rfoot{Page \thepage\ of \pageref{LastPage} }
\begin{document} r R right side of the text
\chapter{My First Chapter}
\lipsum[1-3] l L left side of the text
\section{First section} i I inside edge–near the binding (in a twoside document)
\lipsum[1-6]
\end{document} o O outside edge–far from the binding

Also, add a backslash after \thepage to ensure adequate space between the page number and 'of'. The uppercase-character allows the figure to float, while the lowercase version means "exactly here".
The overhang of the figure can be manually set using the overhang option in pt, cm, etc...
The width is, of course, the width of the figure.
------------------------------------------IMPORTING GRAPHICS-----------------------------------------------------------------------------
You can import external graphics using package graphicx. The most important command is
 Subfloats
\includegraphics. LaTeX itself treats the image like normal text, i.e. as a box of certain height and width.
A useful extension is the subcaption package, which uses subfloats within a single float.
\includegraphics[width=5cm]{image.png}
\usepackage{graphicx}
-----------------------------FLOATS, FIGURES AND CAPTIONS---------------------------------------------------------------------- \usepackage{subcaption}
However, just having a picture stuck in between paragraphs does not look professional. To start with, we want a way of adding captions, and
to be able to cross-reference. What we need is a way of defining figures. It would also be good if LaTeX could apply principles similar to \begin{figure}
when it arranges text to look its best to arrange pictures as well. This is where floats come into play. \centering
To create a figure that floats, use the figure environment. \begin{subfigure}[b]{0.3\textwidth}
\includegraphics[width=\textwidth]{gull}
\begin{figure}[placement specifier] \caption{A gull}
... figure contents ... \label{fig:gull}
\end{figure} \end{subfigure}
~ %add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc.
%(or a blank line to force the subfigure onto a new line)
Specifier Permission \begin{subfigure}[b]{0.3\textwidth}
Place the float here, i.e., approximately at the same point it occurs in the source text (however, \includegraphics[width=\textwidth]{tiger}
h \caption{A tiger}
not exactly at the spot)
\label{fig:tiger}
t Position at the top of the page. \end{subfigure}
~ %add desired spacing between images, e. g. ~, \quad, \qquad, \hfill etc. \hypersetup{
%(or a blank line to force the subfigure onto a new line) bookmarks=true, % show bookmarks bar?
\begin{subfigure}[b]{0.3\textwidth} unicode=false, % non-Latin characters in Acrobat’s bookmarks
\includegraphics[width=\textwidth]{mouse} pdftoolbar=true, % show Acrobat’s toolbar?
\caption{A mouse} pdfmenubar=true, % show Acrobat’s menu?
\label{fig:mouse} pdffitwindow=false, % window fit to page when opened
\end{subfigure} pdfstartview={FitH}, % fits the width of the page to the window
\caption{Pictures of animals}\label{fig:animals} pdftitle={My title}, % title
\end{figure} pdfauthor={Author}, % author
pdfsubject={Subject}, % subject of the document
pdfcreator={Creator}, % creator of the document
------------------------------------------FOOT NOTE AND MARGIN NOTE---------------------------------------------------------------- pdfproducer={Producer}, % producer of the document
pdfkeywords={keyword1, key2, key3}, % list of keywords
The command you need is: \footnote{text}. Do not leave a space between the command and the word where you wish the footnote pdfnewwindow=true, % links in new PDF window
marker to appear, otherwise LaTeX will process that space and will leave the output not looking as intended. colorlinks=false, % false: boxed links; true: colored links
linkcolor=red, % color of internal links (change box color with linkbordercolor)
Creating a footnote is easy.\footnote{An example footnote.} citecolor=green, % color of links to bibliography
filecolor=cyan, % color of file links
To insert a margin note use \marginpar{margin text} urlcolor=magenta % color of external links
}
The marginnote and geometry package can set the widths of the margins and margin notes as follows:

\documentclass[a4paper,twoside,english]{article} ----------------------------------LABELS AND CROSS REFERENCING------------------------------------------------------------


\usepackage{lipsum} The objects which can be referenced include chapters, sections, subsections, footnotes, theorems, equations, figures and tables. The
\usepackage{marginnote}
commands to be used do not depend on what you are referencing, and they are:
\usepackage[top=1.5cm, bottom=1.5cm, outer=5cm, inner=2cm, heightrounded, marginparwidth=2.5cm,
marginparsep=2cm]{geometry}
\label{marker}
\begin{document}
Used to give the object you want to reference a marker — a name which can be used to refer to that object later.
\section{Margin notes}
\marginnote{This is a margin note using the geometry package, set at 0cm vertical offset to the
first line it is typeset.}[0cm] \ref{marker}
\marginnote{This is a margin note using the geometry package, set at 5cm vertical offset to the Used to reference an object with the specified marker. This will print the number that was assigned to the object.
first line it is typeset.}[5cm]
\lipsum[1-10] \pageref{marker}
\end{document}} Used to print the page number where the object with the specified marker is found.

\begin{figure}
------------------------------------------------------HYPERLINKS------------------------------------------------------------------------------- \centering
LaTeX enables typesetting of hyperlinks, useful when the resulting format is PDF, and the hyperlinks can be followed. It does so using the \includegraphics[width=0.5\textwidth]{gull}
package hyperref. The basic usage with the standard settings is straightforward. Just load the package in the preamble: \caption{Close-up of a gull}
\label{fig:gull}
\usepackage{hyperref} \end{figure}
Figure~\ref{fig:gull} shows a photograph of a gull.

The command \label must appear after (or inside) \caption. Otherwise, it will pick up the current section or the list number instead of
 Hyperlink and Hypertarget what is intended.

It is also possible to create an anchor anywhere in the document (with or without caption) and to link to it. To create an anchor, use: \eqref{} is used for equations, offcourse this would need amsmath package.

\hypertarget{label}{target caption}

and to link to it, use:

\hyperlink{label}{link caption}

where the target caption and link caption are the text that is displayed at the target location and link location respectively.

You might also like