Here are the Code examples of this chapter. You can compile them online right on this web page by pressing the Typeset / Compile button. You can also edit them for testing, and compile again.
For a better view with the online compiler, I sometimes use \documentclass[border=10pt]{standalone} instead of \documentclass{article}. Instead of having a big letter/A4 page, the standalone class crops the paper to see just the visible text without an empty rest of a page.
Any question about a code example? Post it on LaTeX.org, I will answer. As forum admin I read every single question there. (profile link).
Including an image
\documentclass[a5paper]{article} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{graphicx} \pagestyle{empty} \begin{document} \section{Including a picture} \blindtext \begin{figure} \centering \includegraphics[width=4cm]{example-image} \caption{Test figure} \end{figure} \blindtext \end{document}
Figure 5.1
Managing floating of images
\documentclass[a5paper]{article} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{graphicx} \pagestyle{empty} \begin{document} \section{Including a picture} \blindtext \begin{figure}[ht] \centering \includegraphics[width=4cm]{example-image} \caption{Test figure} \end{figure} \blindtext \end{document}
Figure 5.2
An image at the page bottom
\documentclass[a5paper]{article} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{graphicx} \pagestyle{empty} \begin{document} \section{Including a picture} \blindtext \begin{figure}[!b] \centering \includegraphics[width=4cm]{example-image} \caption{Test figure} \end{figure} \blindtext \end{document}
Figure 5.3
Letting text flow around images
\documentclass[a5paper]{article} \usepackage[english]{babel} \usepackage{blindtext} \usepackage{graphicx} \usepackage{wrapfig} \pagestyle{empty} \begin{document} \section*{Text flowing around an image} \blindtext \begin{wrapfigure}{l}{4cm} \includegraphics[width=4cm]{ example-image} \caption{Test figure} \end{wrapfigure} \blindtext \end{document}
Figure 5.4
This code is available on Github. It is licensed under the MIT License, a short and simple permissive license with conditions only requiring preservation of copyright and license notices.
Go to next chapter.