I am writting some commands for inserting wrapped pictures.
see that topic: How to wrap pictures in lists in theorems with formulas?
Now I see that \begin{wrapfigure}...\end{wrapfigure} without optional argument, which is "number of narrow lines", picks up quite correct number of narrow lines.
I mean that somehow it knows height of picture and does what I need.
But I tried to understand or to create my own mechanism of doing that. I have no success.
For example, How can I do it in the following code ? I have [1=5,3=0] in definition of addpicture, and the number 5 of narrow lines will not grow up with growing of height of picture in it. But wrapfig gives that effect on the second page, if you will vary height of picture.
\documentclass{article}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{xargs}
\usepackage{mwe}
\usepackage{wrapfig}
\input{insbox.tex}
\usepackage{threeparttable}
\newcommandx\addpicture[4][1=5,3=0]{%
\InsertBoxR{#3}{\begin{threeparttable}%
\begin{tabular}{c@{}}\includegraphics[width=#4\textwidth]{#2}\end{tabular}%
\captionof{figure}{}\end{threeparttable}}[#1]}
\begin{document}
\addpicture{example-image-a}{0.3}
\lipsum[1]
\lipsum[2]
\newpage
\begin{wrapfigure}{r}{0.5\textwidth}
\includegraphics[width=0.5\textwidth]{example-image-a}
\end{wrapfigure}
\lipsum[1]
\lipsum[2]
\end{document}
