[Tex/LaTex] automatically adjust the size of a minipage

graphicsminipagewrapfigure

I'm trying to get a way to automatically adjust the size of a minipage.

I am creating a report which will have several "paragraphs" that have a floating image on the left and some text on the right of that image. The both of them ( image + text ) make together a "semantic block".

The result I want

First I did that :

\begin{wrapfigure}{L}{0.15\textwidth}
    \centering
    \includegraphics[width=0.1\textwidth]{image}\\
    \emph{image caption with no "figure1"}
\end{wrapfigure}
Text related to this image\\
Text related to this image\\
Text not related to this image\\

and of course the text not related to the image was considered like the other lines of text, printing on the right of the image.

So i tried to wrap it all :

\begin{minipage}[c][10cm]{20cm}
\begin{wrapfigure}{L}{0.15\textwidth}
    \centering
    \includegraphics[width=0.1\textwidth]{image}\\
    \emph{image caption with no "figure1"}
\end{wrapfigure}
Text related to this image\\
Text related to this image\\
\end{minipage}
Text not related to this image\\

but it really isn't convenient and the height is fixed.

Here is a minimal "working" code for both:

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{wrapfig}
\begin{document}

\begin{wrapfigure}{L}{0.2\textwidth}
    \centering
    \includegraphics[width=0.2\textwidth]{image}
    \emph{image caption with no "figure1"}
\end{wrapfigure}
Text related to this image\\
Text related to this image\\
Text not related to this image\\


\begin{minipage}[c][10cm]{20cm}
    \begin{wrapfigure}{L}{0.2\textwidth}
        \centering
        \includegraphics[width=0.2\textwidth]{image}\\
        \emph{image caption with no "figure1"}
    \end{wrapfigure}
    Text related to this image\\
    Text related to this image\\
\end{minipage}
Text not related to this image\\

\end{document}

If there is a better way to do it not using minipage that would be great too.
In the end i plan to make it into a \newenvironment taking 2 parameters : image name and text so I can use it easily in the article.

Best Answer

I am a big fan of floating environments, but if floating is not allowed, you don't have to use it.

shrimpdrakeFigure

\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
\usepackage{blindtext}
\newcommand{\nonfloatingfigure}[3]{%
    \par\addvspace{\abovedisplayskip}
    \noindent\begin{minipage}{\linewidth}
        \begin{minipage}{.5\linewidth}
            \centering
            #1\par#2\end{minipage}\begin{minipage}{.5\linewidth}
            \raggedright#3
        \end{minipage}
    \end{minipage}
    \par\addvspace{\belowdisplayskip}
}
\begin{document}
\blindtext

\nonfloatingfigure{\includegraphics[width=0.6\textwidth]{example-image-a}}{
image caption with no "figure1"}{
    The image on the left shows a Wombat, well it would, but package MWE does not provide
    a picture of a Wombat. It definitely should

}
\blindtext


\nonfloatingfigure{\includegraphics[width=0.4\textwidth]{example-image-b}}{
image caption with no "figure1"}{
    Text related to this image
    Text related to this image
    \blindtext
}
Text not related to this image
\blindtext

\end{document}