3

I'm attempting to make a document that has boxes of text with notes that the other text wraps around. I've tried doing this both using in the document and using \newenvironment. Here is my MWE:

\documentclass{report}
\usepackage[utf8]{inputenc}
\usepackage{wrapfig}
\usepackage{lipsum}

\title{Title}
\author{Author}
%Environment for Block Notes. Does NOT work how I want:
\newenvironment{NoteBox}{
 \begin{wraptable}{o}{0.4\linewidth}
 \begin{tabular}{|l|}
  \hline
}{
 \\\hline
 \end{tabular}
\end{wraptable}
}

\begin{document}
\maketitle

\lipsum[1]
%This is my notebox that works generally how I want it but is incredibly tedious
\begin{wraptable}{o}{0.4\linewidth}
 \begin{tabular}{|l|}
  \hline
  When once our labour has\\begun, the comfort that\\enables us to endure it is\\the
  prospect of its end...\\
  \hline
 \end{tabular}
\end{wraptable}

\lipsum[2]
%For some reason, the Notebox environment doesn't seem to work
\begin{NoteBox}
 When once our labour has\\begun, the comfort that\\enables us to endure it is\\the
 prospect of its end...
\end{NoteBox}

\lipsum[1]

\end{document}          

This produces the following pdf:

enter image description here

This code seems to have a few problems: the gap above and below the first box is very large and all the line breaks have to be inserted manually. Additionally, typing all those commands every time is really tedious. When using the Notebox environment to create the second box, it seems to work even less well, like without the text wrapping.

I'm looking for something that does what the \wraptable is doing, but with automatic line-breaking and smaller vertical gaps that can used to create a new environment.

2

Like this?

\documentclass{article}
\usepackage{tikz}
\usepackage{wrapfig}
\usepackage{lipsum}
\usepackage{calc}
\setlength\intextsep{0pt}
\begin{document}
\lipsum[1]
\begin{wrapfigure}{r}{5cm+.6666em+.8pt}
\begin{tikzpicture}[every node/.style={draw,text width=5cm,minimum width=5cm}]
\node {\lipsum[2]};
\end{tikzpicture}
\end{wrapfigure}
\lipsum[2-4]
\end{document}

enter image description here

  • 1
    Thank you! I'm just wondering why you used such a strange size for the wrapfigure (5cm+.6666em+.8pt)? – Crigl Apr 4 at 7:18
  • 2
    @Crigl 5cm is the text width, 0.3333em is the default value of inner sep, i.e. the distance between the text and the border (counted twice), and 0.4pt is the width of the border (also counted twice). Therefore we get 5cm+.6666em+.8pt. You may notice that I loaded calc to perform the calculation. – user156344 Apr 4 at 7:31

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.