0

This is a general question.

I find that the wrapfigure environment is very tricky. It depends on where you put it and if you add things to the top part you can make a good wrapfig bad. I would like to know if there is a way to tell the environment to put a particular figure to be in a particular part of a particular page.

  • Not exactly, but a generic package such as insbox lets ins you insert about any box on the left or the right of a paragraph, with a predefined number of lines of ‘normal’ length before the box is inserted. – Bernard Aug 12 '14 at 11:34
  • would love to have more guidance about insbox – ankhi Aug 13 '14 at 8:17
1

insbox is a set of generic macros that allow to insert (almost) any box (graphic file, equation, …) on the left ot the right of a paragraph. The two main commands are \InsertBoxL{n}{boxcontent}[correction] and \InsertBoxR{n}{boxcontent}[correction] where n is the number of lines at the beginning of the paragraph that remain untouched, and the optional correction is the number of supplementary lines that should be left or right indented, in case the box height is not exactly computed. In addition, there is an \InsertC{boxcontent}that interrupts a paragraph at the point of insertion, just terminating the current line, inserting the box contents centred on the page and resuming the parargraph afterwards.

I wrote once a very small insbox.sty file, that is a wrapper for insbox.tex and adds \InsBoxO and \InsBoxImacros (put on the outside or inside margin), that mimic the o and i options of the wrapfigureenvironments. Here is the code:

\ProvidesPackage{insbox}[2004/03/21 package wrapper for insbox.tex]
\RequirePackage{ifthen}
\input insbox
\newlength\insboxmargin
\insboxmargin=3mm
\makeatletter\@InsertBoxMargin=\insboxmargin\makeatother
\newcommand{\InsBoxO}[2]{\ifthenelse{\isodd{\value{page}}}{\InsertBoxR{#1}{#2}}{\InsertBoxL{#1}{#2}}}
\newcommand{\InsBoxI}[2]{\ifthenelse{\isodd{\value{page}}}{\InsertBoxL{#1}{#2}}{\InsertBoxR{#1}{#2}}}
\makeatletter\newcommand{\resetmargin}{\@restore@}\makeatother
\endinput 

For the problem of inserting figures in lists environments, you can see my answer (based on insbox) to this question.

To insert a caption, one must use the threeparttable environment and the \captionof command (from the caption package).

Here is an example:

\documentclass[a4paper,10pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{insbox, wrapfig}
\usepackage{graphicx, captdef, threeparttable, caption}
\usepackage{lipsum}

\begin{document}
\setcounter{table}{2}
 \lipsum[1-2]
\verb+\InsertBoxR inserted here: +
 \InsertBoxR{10}{%
 \begin{threeparttable}
 \begin{tabular}{lrrr}
 \hline
 sgnj  & 0.31  & 1.16  & 1.16 \\     safd  & 0.46  & 0.91  & 0.99 \\     dsfv  & 0.42  & 0.78  & 0.56 \\     jl;;  & 0.35  & 1.18  & 1.47 \\     sdfd  & 0.38  & 0.76  & 0.79 \\     degf  & 0.27  & 1.29  & 1.33 \\     fewf  & 0.24  & 0.58  & 0.59 \\     werf  & 0.30  & 0.71  & 0.71 \\     fhjj  & 0.64  & 1.45  & 0.60 \\     wdff  & 0.45  & 1.16  & 0.79 \\
 \hline
 \end{tabular}
 \captionof{table}{My table}%\label{c_table3}
 \end{threeparttable}
 }[6]%
\lipsum [3-5]

\end{document}

enter image description here

  • \value{page} isn't reliable, since your code may be put on the next page by the output routine; the satisfactory way of doing it is by using a label; i think the zref bundle has an appropriate module, but there are lots of other ways. – wasteofspace Aug 13 '14 at 11:24
  • \InsertBoxR{10}{\begin{table}[htbp] \scriptsize \centering \caption{h;ghglj,,f} \begin{tabular}{lrrr} & $h$ & $P_r$ & $sgsh$ \\ & (fdsg) & (sg) & (sg) \\ \hline ;ogi & 0.27 & 1.29 & 1.33 \\ ljkl & 0.64 & 1.45 & 0.60 \\ ljhg & 0.45 & 1.16 & 0.79 \\ \hline \end{tabular}% \label{c_table3}% \end{table}} tried to compile this using above sty file. didnt compile – ankhi Aug 13 '14 at 11:32
  • @ankhi: You forgot a closing brace. See my updated answer, with your example and a precision about corrective term. – Bernard Aug 13 '14 at 12:11
  • What is a threeparttable?? is it better than the normal table?............also what about figures in the box? – ankhi Aug 13 '14 at 13:19
  • well I tried your code with a longer table and it made the main text half width for 3 pages :( – ankhi Aug 13 '14 at 16:06

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.