4

I have a block of text which contains nested enumerate environments and I'd like to place a TikZ picture to the right of that text in such a way that the text does not overrun the picture. I tried implementing the technique here based on the picins package, and it worked well with a single enumerate environment, but not for nested enumerate environments:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings,positioning,arrows}
\usepackage{picins}
\usepackage{mdwlist}
\usepackage{lipsum}

\textwidth=6.5in
\textheight=9.5in
\voffset=-1in
\hoffset=-1in

\begin{document}

\begin{enumerate}
\item \parpic[r]{%
    \begin{tikzpicture}[every node/.style={draw,outer sep=0pt,thick}]
        \tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment length=6}]
        \tikzstyle{dampener}=[thick,decoration={markings,
          mark connection node=dmp,
          mark=at position 0.5 with
          {
            \node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,minimum width=15pt,minimum height=3pt,draw=none] {};
            \draw [thick] ($(dmp.north east)+(2pt,0)$) -- (dmp.south east) -- (dmp.south west) -- ($(dmp.north west)+(2pt,0)$);
            \draw [thick] ($(dmp.north)+(0,-5pt)$) -- ($(dmp.north)+(0,5pt)$);
          }
        }, decorate]
        \tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=2cm,minimum height=0.3cm]
    \node (M) [ground,anchor=north] {};
    \node[draw=none,below=1.5cm of M,inner sep=-2,minimum size=0mm] (pt1){};
    \node[circle,below=1.5cm of pt1] (pt2){$m$};
    \draw [dampener] (pt1.north) -- ($(M.south)$) node[draw=none,pos=.52,right=.4cm] {$b$};
    \draw [spring] (pt1.south) -- ($(pt2.north)$) node[draw=none,pos=.5,right=.25cm] {$k$};
    \node[draw=none,left=1.25cm of pt2,minimum size=0mm] (pt3){};
    \node[draw=none,right=1.25cm of pt2,minimum size=0mm] (pt4){};
    \node[draw=none,right=.25cm of pt2,minimum size=0mm] (pt5){};
    \node[draw=none,below=.75cm of pt5,minimum size=0mm] (pt6){};
    \draw[dashed] (pt3) -- (pt2.west);
    \draw[dashed] (pt4) -- (pt2.east);
    \begin{scope}[>=latex]
    \draw[->,thick,xshift=.25cm] (pt5) -- (pt6) node[draw=none,pos=.5,right=.15cm] {$y(t)>0$};
    \end{scope}
    \end{tikzpicture}
}%

\lipsum[66]
    \begin{enumerate}
    \item \lipsum[66]
    \item \lipsum[66]
    \end{enumerate}
\end{enumerate}
\end{document}  

enter image description here

Suggestions?

5
  • \parpic and \parshape are only good for one paragraph, and each item is a separate paragraph. I suspect you will just have to keep adding \parshape to each item until done. Commented Oct 14, 2014 at 3:42
  • In case it helps, I am open to other methods (ones that don't rely on picins)... I tried minipage but it wasn't any less cumbersome than you describe.
    – JohnD
    Commented Oct 14, 2014 at 4:05
  • Actually, \parpic is much easier to use. Commented Oct 14, 2014 at 4:08
  • Thank you for the answer below. I want to leave the question open for a little while to see if it might get some more/different answers to compare.
    – JohnD
    Commented Oct 16, 2014 at 18:54
  • I did think of a way to automatically set the height as well the width, but it still means putting one in each item. Commented Oct 16, 2014 at 19:40

1 Answer 1

2

It seems you don't need to add it to every item, just the first item of nested enumerate. BTW, since tikz saves origin locations in the aux file, you will need to run this twice.

picins

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,decorations.pathmorphing,decorations.markings,positioning,arrows}
\usepackage{picins}
\usepackage{mdwlist}
\usepackage{lipsum}

\textwidth=6.5in
\textheight=9.5in
\voffset=-1in
\hoffset=-1in

% macro creates an empty area corresponding to the remaining space.
\makeatletter
\newcommand{\emptybox}{\begingroup% preserve \@temidima and \@tempdimb
\begin{tikzpicture}[remember picture]
\pgfextractx{\@tempdima}{\pgfpointdiff{\pgfpointanchor{bottom left}{center}}
  {\pgfpointanchor{bottom right}{center}}}%
\pgfextracty{\@tempdimb}{\pgfpointdiff{\pgfpointorigin}
  {\pgfpointanchor{bottom left}{center}}}%
\ifdim\@tempdimb>0pt\relax
\else\path (0,0) (\@tempdima, \@tempdimb);
\fi
\end{tikzpicture}
\endgroup}
\makeatother

\begin{document}

\begin{enumerate}
\item \parpic[r]{%
\begin{tikzpicture}[remember picture, every node/.style={draw,outer sep=0pt,thick}]
        \tikzstyle{spring}=[thick,decorate,decoration={zigzag,pre length=0.3cm,post length=0.3cm,segment length=6}]
        \tikzstyle{dampener}=[thick,decoration={markings,
          mark connection node=dmp,
          mark=at position 0.5 with
          {
            \node (dmp) [thick,inner sep=0pt,transform shape,rotate=-90,minimum width=15pt,minimum height=3pt,draw=none] {};
            \draw [thick] ($(dmp.north east)+(2pt,0)$) -- (dmp.south east) -- (dmp.south west) -- ($(dmp.north west)+(2pt,0)$);
            \draw [thick] ($(dmp.north)+(0,-5pt)$) -- ($(dmp.north)+(0,5pt)$);
          }
        }, decorate]
        \tikzstyle{ground}=[fill,pattern=north east lines,draw=none,minimum width=2cm,minimum height=0.3cm]
    \node (M) [ground,anchor=north] {};
    \node[draw=none,below=1.5cm of M,inner sep=-2,minimum size=0mm] (pt1){};
    \node[circle,below=1.5cm of pt1] (pt2){$m$};
    \draw [dampener] (pt1.north) -- ($(M.south)$) node[draw=none,pos=.52,right=.4cm] {$b$};
    \draw [spring] (pt1.south) -- ($(pt2.north)$) node[draw=none,pos=.5,right=.25cm] {$k$};
    \node[draw=none,left=1.25cm of pt2,minimum size=0mm] (pt3){};
    \node[draw=none,right=1.25cm of pt2,minimum size=0mm] (pt4){};
    \node[draw=none,right=.25cm of pt2,minimum size=0mm] (pt5){};
    \node[draw=none,below=.75cm of pt5,minimum size=0mm] (pt6){};
    \draw[dashed] (pt3) -- (pt2.west);
    \draw[dashed] (pt4) -- (pt2.east);
    \begin{scope}[>=latex]
    \draw[->,thick,xshift=.25cm] (pt5) -- (pt6) node[draw=none,pos=.5,right=.15cm] {$y(t)>0$};
    \end{scope}
    \coordinate (bottom left) at (current bounding box.south west);
    \coordinate (bottom right) at (current bounding box.south east);
    \end{tikzpicture}
}\lipsum[66]

    \begin{enumerate}
    \item \parpic[r]{\emptybox}\lipsum[66]
    \item \lipsum[66]
    \end{enumerate}
\end{enumerate}
\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .