1

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}  

1 Answers1

1

Heh. For all questions which were asked by me last week exactly I found solution in books and internet. (so, why did I ask them?! * \facepalm *)

I am the author of question - keep it in mind.

May be this algoritm is unprofessional, uses too much variables and etc. but it works. You can see it below and give me advice or use it for yourself.

enter image description here

    \documentclass{article}
    \usepackage{graphicx}
    \usepackage{mwe}
    \usepackage{wrapfig}    
    \usepackage[colorlinks]{hyperref}
    \usepackage{printlen}
        \uselengthunit{cm}             
\usepackage{forloop}

\newcounter{ct}

\newlength\imageheight \newlength\imagewidth

\newcount\narrowlinect \newcount\linelength

\narrowlinect=0\relax \linelength=\baselineskip\relax

\begin{document} \settoheight\imageheight{\includegraphics[width=\textwidth]{example-image-a}} \settowidth\imagewidth{\includegraphics[width=\textwidth]{example-image-a}} \begin{wrapfigure}{r}{\textwidth} \includegraphics[width=\textwidth]{example-image-a} \caption{} \end{wrapfigure} \forloop{ct}{1}{\value{ct} < 28}{\arabic{ct} \newline}

\mbox{}

\narrowlinect=\imageheight\relax

\setcounter{ct}{\numexpr((\narrowlinect)/\linelength+2)\relax}

\arabic{ct}

\end{document}