# How to insert picture here?

I want text to flow picture, as it is in the book:

And with advice of @Johannes_B I did it with help of minipage, but It doesn't suit me at all things.

1. See this. First page of my document. Do you see that it is wrong?
2. I want to insert Pictures always on the outer side of the page! but this will do it never.
3. How to add mechanism of solving this problem to my super function of adding pictures. (Before this problem it solved all my problems, in lists, environments, items, etc)

4. # WHY WITH POWER OF LATEX NOBODY KNOWS HOW TO INSERT PICTURE IDEALLY IN ANY SUTIATION?!

like Office 2014 - just press one button.

I don't believe that all of latex users do a lot of manual work when try to insert a picture. But I have been trying to do it for three weeks!

I have 2 hundread pictures to insert in my book, and if I will try to insert it manually , I'll go crazy!

I am really shocked, that there are a lot of sutiations when nothing works.

\documentclass{book}
\usepackage{graphicx}
\usepackage{mwe}
\usepackage{amsmath}
\usepackage{microtype}
\usepackage{caption}
\input{insbox.tex}
\usepackage{threeparttable}
\usepackage{changepage}
\usepackage{xargs}
\usepackage[showframe]{geometry}
\usepackage{printlen}
\newtheorem{thm}{Theorem}

\newcounter{ct}

\newlength\imageheight

\newcount\narrowlinect
\narrowlinect=0\relax
\newcounter{pictnumber}
\newcommand*{\wrapitem}{\apptocmd{\labelenumi}{\hskip\leftmargin}{}{}\item\apptocmd{\labelenumi}{\hskip-\leftmargin}{}{}}
%
\newcommandx{\InsertPictL}[4][1=0,3=0]{\refstepcounter{pictnumber}%
\settoheight\imageheight{\includegraphics[width=#4\textwidth]{#2}}
\narrowlinect=\imageheight\relax
\setcounter{ct}{\numexpr((\narrowlinect)/\baselineskip+2)\relax}
\setlength{\leftskip}{\leftmargin}\mbox{}\vspace*{-\baselineskip}%
\InsertBoxL{#1}{\begin{threeparttable}%
\begin{tabular}{c@{}}\includegraphics[width=#4\textwidth]{#2}\end{tabular}%
\caption*{Pict. \thepictnumber}\end{threeparttable}}[\numexpr(\value{ct}/2+#1+1)]\par
\hspace{\itemindent}
}%

\newcommandx{\InsertPictR}[4][1=0,3=0]{\refstepcounter{pictnumber}%
\settoheight\imageheight{\includegraphics[width=#4\textwidth]{#2}}
\narrowlinect=\imageheight\relax
\setcounter{ct}{\numexpr((\narrowlinect)/\baselineskip+2)\relax}
\mbox{}\vspace*{-\baselineskip}\setlength{\leftskip}{\leftmargin}%
\InsertBoxR{#1}{\hskip-\leftmargin\begin{threeparttable}%
\begin{tabular}{c@{}}\includegraphics[width=#4\textwidth]{#2}\end{tabular}%
\caption*{Pict. \thepictnumber}\end{threeparttable}\hskip\leftmargin}[\numexpr(\value{ct}/2+#1+1)]
}%

\newcommandx{\InsertPict}[4][1=0,3=0]{%
\strictpagecheck%
\checkoddpage%
\ifoddpage
\InsertPictR[#1]{#2}[#3]{#4}
\else%
\InsertPictL[#1]{#2}[#3]{#4}
\fi%
}

\begin{document}
\noindent
\begin{minipage}[t]{0.7\textwidth}
\begin{thm}
\lipsum[1]
$$\int_\gamma f(z)\,dz = 0.$$
\end{thm}
\end{minipage}%
\hfill%
\begin{minipage}[t]{0.3\textwidth}
\InsertBoxR{0}{\includegraphics[width=\dimexpr(\textwidth-2mm)]{example-image-a}}
\end{minipage}

\newpage
\begin{thm}\InsertPict{example-image-a}{0.3}
\lipsum[1]
$$\int_\gamma f(z)\,dz = 0.$$
\end{thm}

\newpage
\begin{thm}\InsertPict{example-image-a}{0.3}
\lipsum[1]
$$\int_\gamma f(z)\,dz = 0.$$
\end{thm}
\end{document}

• wrapfig isn't suited to do the job, use minipages instead. – Johannes_B Mar 19 '16 at 11:06
• @Johannes_B please see my updated question. – Lust_For_Love Mar 19 '16 at 14:10
• I was mislead by your very first picture, wrapfig seems to be the best solution. cutwin is also available, but i don't have any experience. On the other hand, be advised, that wrapping images always need manual interaction. – Johannes_B Mar 19 '16 at 14:17
• I think that your question is written unnecessarily rude. – Dr. Manuel Kuehner Mar 19 '16 at 14:41
• @Dida writing like THIS is considered shouting in chatrooms or forums. I get you are frustrated. May I suggest to take a step back and try a different approach? – naphaneal Mar 19 '16 at 16:05

Here is a minipage solution. See Wrapping image with multiple theorem-like environments and displayed math to break a paragraph (wrap text).

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[russian]{babel}
\usepackage{graphicx}
\usepackage{caption}
\input{insbox.tex}
\usepackage{threeparttable}
\usepackage{xargs}
\usepackage{mwe}
\usepackage{amsmath,amsthm,amssymb}

\newtheorem{thm}{Theorem}

\begin{document}

\noindent\begin{minipage}{\dimexpr 0.8\textwidth-\columnsep}% need some gap
\begin{thm}[Коши]\label{abc2}
Для всякой регулярной функции $f:G\to\mathbb{C}$, заданной в односвязной области G, справедливо равенство
$$\label{abc3} \int_\gamma f(z)\,dz = 0.$$
где интеграл берется по любому замкнутому простому кусочно-гладкому контуру $\gamma$, лежащему в области $G$.
\end{thm}
\end{minipage}\hfill\begin{minipage}{0.2\textwidth}
\includegraphics[width=\textwidth]{example-image-a}
\captionof{figure}{}
\end{minipage}

\end{document}


• Yes, thank you. I have already deleted my own answer, that doing it like you advice me... (because people voted down :( ) Please, see updated question. – Lust_For_Love Mar 19 '16 at 13:54
• Oh \nopar contruction from the reference should solve my first problem. But it is very manual work. – Lust_For_Love Mar 19 '16 at 13:58
• \hangindent and \parshape can automatically adjust the margins (left or right) but only affect one paragraph and don't work on equations (IIRC). – John Kormylo Mar 19 '16 at 15:07