1

I borrowed the code for my MWE from here. I want to put the table to right side and have difficulty in understanding parshape command. What is the purpose of 15 26pt\linewidth 26pt\linewidth 0.5\linewidth in parshape command. Any help will be highly appreciated. Thanks

\documentclass{article}
\usepackage{cutwin}
\usepackage{caption}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{booktabs}

\begin{document}

\renewcommand\windowpagestuff{%
  \hspace*{25pt}
\begin{tabular}{ccc}\\\toprule  
Header-1 & Header-1 & Header-1 \\\midrule
2 &3 & 5\\  \midrule
2 &3 & 5\\  \midrule
2 &3 & 5\\  \bottomrule
\end{tabular}
}

\opencutleft

\begin{cutout}{3}{10pt}{0.5\linewidth}{12}
\begin{enumerate}
{%
\parshape 15 26pt\linewidth 26pt\linewidth 0.5\linewidth 0.5\linewidth
  0.5\linewidth 0.5\linewidth  0.5\linewidth 0.5\linewidth  0.5\linewidth    0.5\linewidth
  0.5\linewidth 0.5\linewidth  0.5\linewidth 0.5\linewidth  0.5\linewidth    0.5\linewidth 
  0.5\linewidth 0.5\linewidth  0.5\linewidth 0.5\linewidth  0.5\linewidth    0.5\linewidth
  0.5\linewidth 0.5\linewidth  0.5\linewidth 0.5\linewidth  26pt\linewidth

\item \lipsum[1]

}%

\item \lipsum[2]
\item \lipsum[3]

\end{enumerate}

\end{cutout}

\end{document}
MYaseen208
  • 8,587

1 Answers1

2

I have another solution to wrap a figure or table in a list environment. It relies on the insbox.tex generic macros file. Upon this file, I build two commands, \InsertListL and \ InsertListR that take two mandatory and one optional argument and insert any (well, most of them) box in a list environment.

The arguments are:

  • the number of lines that remain unindented (mandatory)
  • the box that is to be wrapped (mandatory…)
  • the number of supplementary lines that will be indented, used as a correction (optional)

It works well, except for the first inserted box, which overlaps the label. So I defined a work around in the form of a patch to the \item command, called wrapitem.

To insert a box, the commands have to be inserted immediately after the \item command. You can't use captions, and no more than 1 box per item paragraph — which seems sensible.

    \documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage{lipsum}
    \usepackage{booktabs}
    \input{insbox}
    \makeatletter
    \@InsertBoxMargin = 12pt
    \makeatother
    \usepackage{nccmath}
    \usepackage[showframe, nomarginpar]{geometry}
    \usepackage{etoolbox}

    \newcommand*{\wrapitem}{\apptocmd{\labelenumi}{\hskip\leftmargin}{}{}\item\apptocmd{\labelenumi}{\hskip-\leftmargin}{}{}}
    %
    \newcommand{\InsertListL}[3][]{%
    \setlength{\leftskip}{\leftmargin}\mbox{}\vspace*{-\baselineskip}%
    \InsertBoxL{#2}{#3}[#1]\par \hspace{\itemindent}
    }%
    \newcommand{\InsertListR}[3][]{%
    \mbox{}\vspace*{-\baselineskip}\setlength{\leftskip}{\leftmargin}%
    \InsertBoxR{#2}{\hskip-\leftmargin#3\hskip\leftmargin}[#1]
    }%

    \begin{document}

    \newcommand\windowpagestuff{%
    \setlength\fboxsep{3pt}
    \begin{tabular}{ccc}
    \toprule
    Header-1 & Header-1 & Header-1 \\
    \midrule
    2 &3 & 5\\
    \midrule
    2 &3 & 5\\
    \midrule
    2 &3 & 5\\
    \bottomrule
    \end{tabular}
    }

    \begin{enumerate}%

    \wrapitem%
    \InsertListL[2]{2}{\windowpagestuff}%
    \lipsum[1]

     \item
    \InsertListR[2]{0}{\windowpagestuff}
    \lipsum[2]

    \InsertListR{3}{\parbox{5cm}{
        \[ (a + b^{2} = a^{2} + 2ab + b^{2} ) \] }}%
    \lipsum[3]

    \end{enumerate}

    \end{document} 

enter image description here

Bernard
  • 271,350