2

How to place tikzpicture inside theorem environments with wrapping? I found many decisions with cutwin package. But the decisions concern to the wrapping inside own theorem environment (besides, they look cumbersome). But what if one need to place picture between two theorem-environments with wrapping?

\documentclass[]{article}
\usepackage{ntheorem}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{wrapfig}

\theoremseparator{-----------}
\newtheorem{theorem}{}
\input{insbox.tex}
\begin{document}


%=========================================================
\begin{theorem}
    \lipsum[1]
    %--------------- cutwin? wrapfig? anything else ? ------------------
    \begin{wrapfigure}{O}{0.5\linewidth}\centering
        \begin{tikzpicture}
            \draw (0,0) rectangle (5,5);
        \end{tikzpicture}
        \caption{}
        \label{}
    \end{wrapfigure}
    %---------------------------------------------------------  
\end{theorem}

\begin{theorem}
    \lipsum[2]
\end{theorem}

\end{document}

Desired view looks like the following enter image description here

  • problem's the wrapfigure cannot be placed in list environments. you could thread the path with picins. – naphaneal Jun 11 '18 at 20:42
3

Here is a solution with insbox, which requires some manual adjustments:

\documentclass[english]{article}
\usepackage{babel}
\usepackage{ntheorem}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{tikz}
\newtheorem{theorem}{}
\input{insbox.tex}

\begin{document}
%=========================================================

\begin{theorem}\leavevmode\vspace{-\baselineskip}\InsertBoxR{6}{\parbox{5.2cm}{\raggedleft\begin{tikzpicture}
 \draw (0,0) rectangle (5,5);
 \end{tikzpicture}
 \captionof{figure}{}\label{mylabel}}}
 \lipsum[1]
\end{theorem}

\begin{theorem}\leavevmode\vspace{-\baselineskip}\InsertBoxR{0}{\quad\makebox[5cm]{}}[3]
    \lipsum[2]
\end{theorem}

\end{document} 

enter image description here

In case these theorems are numbered bu=y section, you have to change the value of \parindent inside the theorem. This can be done with \theoremprework. Also, note the change theorem style gives a better positioning of the label:

\documentclass[english]{article}
\usepackage{babel}
\usepackage{ntheorem}
\usepackage{caption}
\usepackage{lipsum}
\usepackage{tikz}

 \theoremstyle{change}
 \theoremprework{\parindent=2em}
 \newtheorem{theorem}{}[section]

\input{insbox.tex}

\begin{document}

\begin{theorem}\leavevmode\vspace{-\baselineskip}\InsertBoxR{6}{\parbox{5.2cm}{\raggedleft\begin{tikzpicture}
 \draw (0,0) rectangle (5,5);
 \end{tikzpicture}
 \captionof{figure}{}\label{mylabel}}}\lipsum[1]
\end{theorem}

\begin{theorem}\leavevmode\vspace{-\baselineskip}\InsertBoxR{0}{\quad\makebox[5cm]{}}[3]
  \lipsum[2]
\end{theorem}

\end{document} 

enter image description here

  • Thank you! As a temporary solution it will do. But, unfortunately, too much needs to be corrected by hands. – sergiokapone Jun 11 '18 at 21:19
  • It should be more or less automatic if the tikz picture does not overflow to the next theorem? Other tha that, since your ‘theorem’ has no name, couldn't you consider using an enumerate environment indtead, as you can have the tools from enumitem? – Bernard Jun 11 '18 at 21:24
  • I do not consider the enumitem, for my purposes, the ntheorem is required only. – sergiokapone Jun 11 '18 at 21:29
  • Maybe there is some way to determine the size of the tikzpicture to put it in \parbox {<size>} {...} and to other required places? – sergiokapone Jun 11 '18 at 21:36
  • I suppose so. Then you can convert this code into a macro, and the only parameters to enter would be 1) the width of the parbox, 2) How many lines are untouched at the beginning of the theorem (it's the first argument of insbox) and, as an optional argument, the number of supplementary shortened lines at the end (I used it to shorten the first lines of the second theorem). – Bernard Jun 11 '18 at 21:44

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.