I need to control the vertical skip between ordinary text and macro generated boxed objects in some documents I am redacting. Due to stylistic, reasons I need to respect the following rules:
- If a boxed object is placed between two ordinary text blocks, a fixed vertical skip (say
0.2\baselineskip, for example) should be added above and below it. - The skip between two consecutive boxed objects should be the same as the one between a boxed object and a ordinary text block, i.e. it should not be doubled/multiplied.
- If the box is placed at the start of a new paragraph, no additional vertical skip before it should be added. The same rule should be respected if the boxed object appears at the start of the new page.
- No indentation should be added to the text block coming after a boxed object.
I tried the following, very simple, \simplepic command:
\documentclass[a4paper, 12pt, oneside]{book}
% Preamble
% structure settings
\usepackage{calc}
% lipsum
\usepackage{lipsum}
%%%% Single Image macro
\newcommand{\simplepic}[1]
{\vspace{.2\baselineskip}
\par\noindent
\fbox{%
\begin{minipage}[t]{\linewidth-2ex}
#1
\end{minipage}
}
\vspace{-.2\baselineskip}
\par\noindent
}
\begin{document}
\simplepic{\lipsum[1]}
\lipsum[2]
\simplepic{\lipsum[3]}
\lipsum[4]
\lipsum[5]
\simplepic{\lipsum[6]}
\simplepic{\lipsum[7]}
\lipsum[8]
\end{document}
The code works approximatively well in the sense that it produces vertical spacing according to rules 1, 3 and 4: however, rule 2 is not respected as a simple run of the above code shows in the second page of the resulting output .pdf file.
In sum, my question is: how can I control the vertical spacing above or below a boxed object in order to make it independent on the presence of other boxed objects of the same class?
