1

I'd like to illustrate my \begin{example} \lipsum[2] \end{example} with a table yet adding the table to the environment sends it to the very end of the document:

\documentclass{article}
\usepackage{wrapfig, lipsum, amsthm, thmtools}
\declaretheorem[style=remark,name=Example]{example}
\begin{document}

\begin{example}

\begin{wraptable}{r}{5.5cm}
    \begin{tabular}{cc}
    \hline
    header-a & header-b \\ 
    1 & 2 \\ 
    3 & 4 \\  
    \hline
    \end{tabular}
\end{wraptable} 

\lipsum[2]

\end{example}

\lipsum[2]

\end{document}

And this is how it looks like: table

  • That seems normal since theorem-like environments are based on a list environment and wrapfig isn't very list-friendly. – Bernard Aug 2 '14 at 21:04
1

Here is a hack that uses the generic macros from the insbox.tex set. I define a \InsertExampleR command, that can insert (almost) any box on the right, and has 2 mandatory and 1 optional arguments: the mandatory arguments are the number of lines whose length remain unchanged and the box to be inserted. The optional argument is the number of supplementary lines to be shortened, in case the box height is not well calculated. It may be adapted to any theorem-like environment, but depends on the theorem label.

\documentclass{article}
\usepackage{wrapfig, lipsum, amsthm, thmtools, caption, xcolor, makebox}
\declaretheorem[style=remark,name=Example]{example}
\input{insbox.tex}

\newcommand{\InsertExampleR}[3][]{%
\leavevmode\vspace*{-\baselineskip}
\InsertBoxR{#2}{\enspace#3}[#1]
\hspace*{-\parindent}\makebox*{\textit{Example} \theexample.$\:$}{}
}%

\makeatletter
\newcommand*\InsertBoxMargin[1]{\@InsertBoxMargin = #1}
\makeatother

\begin{document}

\begin{example}
\InsertExampleR{0}{%
\begin{tabular}{cc}
 \hline
 header-a & header-b \\
 1 & 2 \\
 3 & 4 \\
 \hline
 \end{tabular}}
\lipsum[2]%
\end{example}

\end{document}

enter image description here

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.