6

I want text to flow pictures. @Bernard adviced me this way of doing it with formulas and theorems. Thanks him, it works great in many cases better than any other variants I have ever seen. I have reworked it for my wishes.

But there are several problems.

zero. How to set default value of optional argument exactly in function?

  1. See the first prinscreen. Distance between left edge of paragraphs and left edge of the page are different! It is awful. Item 2 is natural. Text in the first item should be nearer to the left edge of paper.

the first:

enter image description here

  1. See the second printscreen. Text in the second item is over picture! It is awful. and I do not want to add picture earlier in code. I want text in the second item to flow it. I mean that text relating to the second item should flow the picture relating to the first item. (solution to do \addpicture after the second item is not correct)

the second:

enter image description here

  1. In my function I used very unprofessional (I guess) mechanism of labeling pictures. Can you advice me some better variants?

    1. See the third printscreen and the second page of document. How cannot I do a new paragraph after proof here. I want word "Fusce" to follow "Proof" on the same line. I know that \leavevmode makes new line, but without it I get very bad result (you can see it at the fourth printscreen)

the third:

enter image description here

the fourth:

enter image description here

  1. How to find the right number of lines?

PS. If you know solution not using constructions below, please tell me.

PPS. In two words my questions are: How to make an ideal full automatic command of inserting pictures in latex? I want to make it as easy as possible.

PPPS. I have deleted quetion about odd and even pages, because it was solved: (If Then Else for odd page/even page).

PPPS. See my own anwer to get my success (or not) in this case.

    \documentclass{article}
    \usepackage{graphicx}
    \usepackage{amsthm}
    \usepackage{caption}
    \usepackage{lipsum}
    \usepackage{changepage}
    \usepackage[colorlinks]{hyperref}
    \usepackage{xargs}
    \usepackage{mwe}

\newcounter{pictnumber}
\renewcommand{\thepictnumber}{\arabic{pictnumber}}    

\input{insbox.tex}
\usepackage{threeparttable}

\newcommandx\myaddpicture[4][1=5,3=0]{\refstepcounter{pictnumber}%
\InsertBoxR{#3}{\begin{threeparttable}%
\begin{tabular}{c@{}}\includegraphics[width=#4\textwidth]{#2}\end{tabular}%
\captionof{figure}{}\end{threeparttable}}[#1]}

\begin{document}
\begin{proof}
\begin{enumerate}
    \item 
    \lipsum[1]
    \addpicture{example-image-a}{0.3}
    \lipsum[2]
    \addpicture{example-image-a}{0.3}
    \item
    \lipsum[3]
\end{enumerate}
\end{proof}
  \newpage
  \begin{proof}\leavevmode
  \addpicture{example-image-a}[2]{0.45}
  \lipsum[5]
  \end{proof}
\end{document}   
  • 1
    Wrapping text of various types around pictures is a frequent question here. The picins package uses \hangindent and wrapfig uses \parshape. Neither works with \item, but \rightskip will. It can be done, but sometimes you have to manually break paragraphs. – John Kormylo Mar 7 '16 at 2:50
  • 1
    Sorry, but I only get equations when I try to run your code. See tex.stackexchange.com/questions/292780/… – John Kormylo Mar 7 '16 at 17:54
  • 3
    @Dida, help people to help you by creating correct MWE: meta.tex.stackexchange.com/a/3225/79756 – Leonid Mar 9 '16 at 17:01
  • 1
    regarding your question 5, an answer by heiko oberdiek tex.stackexchange.com/a/193105 solves the problem of the nasty spacing for theorems (proofs are quite like theorems in this respect), and also deals with the behavior of linking and labels; it does require hyperref. not an exact "drop in" solution, but might give you a starter. – barbara beeton Mar 9 '16 at 21:13
  • 1
    Sorry, but I don't know anything about the Microsoft Word process of adding pictures so saying that you want something like this means as much to me as describing what you want in Chinese. Actually, less, because I could at least run Chinese through Google translate. It is years and years since I had to add a picture in Word. At that time, it was very far from being simple! – cfr Mar 12 '16 at 22:21
1

(It is anwer of me -- Author of this question -- keep it in mind)

The best solution is to take cup of tea and relax, I guess.

Btw, I've already founded solution to questions 1,2(only for right edge of page),3,5. By the way, I still need answers to the rest questions. AND, that's more important, I need advice to make simpler and better my own commands.

My solution is that not in lists it is better to use command \addpicture(see it below), and in list difficult way to use \wrappicture(see it below) is better.

solution to question 1.

That's all in \wrappicture, exactly in \parbox

enter image description here

solution to question 2.

BUT PEOPLE HELP ME. \WRAPPICTURE DOES NOT WORK ON THE LEFT SIDES OF PAGES.

enter image description here

btw, for right side it is in optional arguments of \wrappicture.

enter image description here

solution to question 3.

I have solution, but it is very dirty and unprofessional, I guess. But it works.

\newcounter{pictnumber}
\renewcommand{\thepictnumber}{\arabic{pictnumber}}   

And I should do \refstepcounter{pictnumber} in command \myaddpicture, because \label will see it, but will not see adding to counter in caption in macro for some reasons. This is works just because the number which indicated my counter is the same as the counter of figures. And after it I should do this adding to my own counter in every \begin{wrapfigure} (for example) to keep it the same. By the way, you can renewcommand caption to show my counter and do everything with my own counter.

enter image description here

solution to question 5.

https://tex.stackexchange.com/a/299007/98432

And this is my final code now:

               \documentclass{book}
\usepackage{graphicx}
\usepackage{amsthm}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{changepage}
\usepackage{xargs}
\usepackage{mwe}
\usepackage{wrapfig}    
\usepackage[colorlinks]{hyperref}
\newcounter{pictnumber}
\renewcommand{\thepictnumber}{\arabic{pictnumber}}  



\input{insbox.tex}
\usepackage{threeparttable}

\newcommandx\addpictureR[4][1=5,3=0]{\refstepcounter{pictnumber}%
\InsertBoxR{#3}{\begin{threeparttable}%
\begin{tabular}{c@{}}\includegraphics[width=#4\textwidth]{#2}\end{tabular}%
\captionof{figure}{}\end{threeparttable}}[#1]}

\newcommandx\addpictureL[4][1=5,3=0]{\refstepcounter{pictnumber}%
\InsertBoxL{#3}{\begin{threeparttable}%
\begin{tabular}{c@{}}\includegraphics[width=#4\textwidth]{#2}\end{tabular}%
\captionof{figure}{}\end{threeparttable}}[#1]}
\newcommandx{\addpicture}[4][1=5,3=0]{%
\strictpagecheck%
\checkoddpage%
\ifoddpage
\addpictureR[#1]{#2}[#3]{#4}
\else%
\addpictureL[#1]{#2}[#3]{#4}
\fi%
}



\newcommandx{\wrappicture}[7][1=12,3=8,5=\mbox{},7=0]
    {

    \parbox[t]{\dimexpr\textwidth-\leftmargin}
        {%
        \vspace{-2.5mm}
            \begin{wrapfigure}[#1]{o}{#4\textwidth}
            \centering
            \vspace{-\baselineskip}
                \InsertBoxL{#7}
                    {\begin{threeparttable}%
                        \begin{tabular}{c@{}}\includegraphics[width=#4\textwidth]{#6}\end{tabular}%
                        \captionof{figure}{}\end{threeparttable}}       
            \end{wrapfigure}#2
      \parbox[t]{\dimexpr\textwidth-\leftmargin}{%
      \vspace{-2.5mm}
      \begin{wrapfigure}[#3]{r}{#4\textwidth}
      \end{wrapfigure}
       #5 }
        }        
    \refstepcounter{pictnumber} 
    }



\begin{document}
 \refstepcounter{pictnumber}\refstepcounter{pictnumber}\refstepcounter{pictnumber}\refstepcounter{pictnumber}\refstepcounter{pictnumber}
\newpage
\begin{proof}\leavevmode
\begin{enumerate}
    \item 
    \lipsum[1]
    \wrappicture [9]{{\lipsum[2]  } }[0]{0.3}{example-image-a}

    \wrappicture [0]{je\newline je\newline je\newline je\newline }[5]{0.3}[{{\item \lipsum[3]}}]{example-image-a}\label{i am seven}

    \end{enumerate}
    \end{proof}     

  \newpage
  \begin{proof}\leavevmode
  \addpicture{example-image-a}[1]{0.45}
  \lipsum[5]
  \end{proof}

   \newpage

hello \ref{i am seven}

\end{document}  
  • May be it is better to ask about problem with left sides separatly? – Lust_For_Love Mar 14 '16 at 17:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.