latex include figure code example
Example 1: insert figure latex
%...
\begin{figure}[h!]
\centering
\begin{subfigure}[b]{0.2\linewidth}
\includegraphics[width=\linewidth]{coffee.jpg}
\caption{Coffee.}
\end{subfigure}
\begin{subfigure}[b]{0.2\linewidth}
\includegraphics[width=\linewidth]{coffee.jpg}
\caption{More coffee.}
\end{subfigure}
\begin{subfigure}[b]{0.2\linewidth}
\includegraphics[width=\linewidth]{coffee.jpg}
\caption{Tasty coffee.}
\end{subfigure}
\begin{subfigure}[b]{0.5\linewidth}
\includegraphics[width=\linewidth]{coffee.jpg}
\caption{Too much coffee.}
\end{subfigure}
\caption{The same cup of coffee. Multiple times.}
\label{fig:coffee3}
\end{figure}
%...
Example 2: latex figure
\usepackage{graphicx}
% inside document:
\begin{figure}
\centering
\includegraphics[scale=1]{name_of_file_inside_directory}
\caption{Your caption}
\label{given_label_that_used_to_reference_figure_in_the_future}
\end{figure}
% use float option [H] after {figure} to place figure exactly as positioned in LeTeX code
% preferably place file of image inside directory of tex file
Example 3: include code in latex
\usepackage{listings}
\usepackage{color}
\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}
\lstset{frame=tb,
language=Java,
aboveskip=3mm,
belowskip=3mm,
showstringspaces=false,
columns=flexible,
basicstyle={\small\ttfamily},
numbers=none,
numberstyle=\tiny\color{gray},
keywordstyle=\color{blue},
commentstyle=\color{dkgreen},
stringstyle=\color{mauve},
breaklines=true,
breakatwhitespace=true,
tabsize=3
}
Example 4: latex include without new page
\include always uses \clearpage, a not entirely sensible default.
It is intended for entire chapters, not for subsections.
You can fix it either by using \input{filename} or loading the "newclude" package
and writing \include*{filename} instead.
Example 5: insert figure latex
%Path relative to the main .tex file
\graphicspath{ {./images/} }