Common elements
Common elements
.. 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:
\documentclass{book}
\usepackage{lipsum}
Justification
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.
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
\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:
\renewcommand{\arraystretch}{1.5}
\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}
{\Large
\begin{tabular}{| r | r || c | c | c |}
% ...
\end{tabular}
}
\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
---------------------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
\usepackage{fancyhdr}
\setlength{\headheight}{15.2pt}
\pagestyle{fancy}
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:
\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}
\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.