# Format a tutorial with screenshots in LaTeX

I want to format a step-by-step tutorial in LaTeX in a way that each step shows one screenshot and a small piece of text for that step. I could think of a formatting where in each step the screenshot is positioned on the left and the text is on the right. However, if I use \includegraphics the image is dynamically positioned in the document.

How can I realize such formatting?

-

## migrated from stackoverflow.comNov 26 '11 at 13:33

This question came from our site for professional and enthusiast programmers.

Probably belongs on tex.SE – Vatine Nov 26 '11 at 12:45
Welcome to TeX.sx! Your question was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other, otherwise you won't be able to comment on or accept answers or edit your question. – Torbjørn T. Nov 26 '11 at 16:17

It's by no means necessary to place an \includegraphics command inside a figure environment.

If the text doesn't overflow much the figure's height, you can use a simple method:

\documentclass[a4paper]{article}
\usepackage[demo]{graphicx}
\usepackage{lipsum}

\newenvironment{explanation}[2][]
{\begin{flushleft}
\begin{minipage}[t]{\dimexpr\textwidth-6cm\relax}}
{\end{minipage}\end{flushleft}}

\begin{document}
\lipsum[2]

\begin{explanation}{screenshot1}
This is the text that accompanies the first screen shot
and explains it.
\end{explanation}

\lipsum[2]
\end{document}


Note: the demo option for graphicx is just to allow avoiding having real figure files. Here I've provided 6cm space for the screen shot, which is typeset as 5cm wide, so to give it some room. Variations are possible, see the documentation of adjustbox.

In case a caption is needed, one can use the caption or captionof packages and use something like

\newenvironment{explanation}[2][]
{\noindent\begin{minipage}{\textwidth}\vspace{\topsep}
\begin{minipage}[t]{\dimexpr\textwidth-6cm\relax}}
{\end{minipage}
\par
\if\relax\detokenize\expandafter{\expcaptiontext}\relax\else
\captionof{figure}{\expcaptiontext}
\fi
\gdef\expcaptiontext{}%
\vspace{\topsep}
\end{minipage}}
\newcommand{\expcaption}[1]{\gdef\expcaptiontext{#1}}


with

\begin{explanation}{screenshot1}
This is the text that accompanies the first screen shot
and explains it.

\expcaption{This is the caption}
\end{explanation}


If the text overflows the screen shot by several lines, then the wrapfig package should be taken into consideration.

-
It may be obvious to the original poster, but just in case, pdflatex can use PNG and JPG files in \includegraphics, while regular latex can't. So pdflatex tends to make screenshot documents easier. – Mike Renfro Nov 26 '11 at 14:27
This is great! Is there a way to get these graphics to be numbered like all the other images? When I try putting a figure environment around it, it destroys all the beautiful formatting. – florianletsch Dec 13 '11 at 20:31
Nevermind, your second version with the caption works just as I need it. To move the caption directly below the screenshot, I just added \usepackage[singlelinecheck=false]{caption} to my preamble. – florianletsch Dec 14 '11 at 9:46

As suggested by @egreg, here is an example with wrapfigure:

\documentclass[12pt,a4paper]{article}

\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{wrapfig}

\begin{document}

\lipsum[1]

\begin{wrapfigure}{l}{7cm}
\includegraphics[width=6cm]{<image file>}
\end{wrapfigure}

\lipsum[2]

\end{document}


The paragraph that will be wrapped around the figure is placed after the figure itself.

It is worth to take a look at the documentation of the wrapfig package, as it behaves a bit differently than regular floats. Just a short quote about the required argument for the placement of the figure on the page:

Parameter #2 (required) is the figure placement code, but the valid codes are different from regular figures. They come in pairs: an uppercase version which allows the figure to float, and a lowercase version that puts the figure “exactly here”.

r R – the right side of the text

l L – the left side of the text

i I – the inside edge–near the binding (if [twoside] document)

o O – the outside edge–far from the binding

-