# Spacing around image

Knuth is on record that he incorporated approximately 100 typographical rules in TeX. I am struggling to discover the balance. Consider the figure below,

What should be the amount of space around the image? In the minimal below, I tried to relate it to baselineskip after a few experiments I used the figures as shown in the minimal. Having the image flush with the outer margin looked wrong to me and crying for a little bit of optical correction. This question was inspired by Apply \intextsep at top of page, that from a typography point of view looked wrong.

Here is the MWE.

\documentclass[imperial,11pt]{octavo}
\usepackage[english,latin]{babel}
\usepackage{microtype}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{xcolor,calc}
\setlength{\parindent}{1em}
\setlength{\parskip}{\baselineskip}
\parbox{\linewidth}{\textbf{#1}}\vspace{10px}%
}
\newcommand*\WrapFigure[1]{%
%\ifhmode\else\leavevmode\vspace*{\dimexpr(-\normalbaselineskip+10pt)}\fi%
\setlength\intextsep{5pt}%
\setlength{\columnsep}{\baselineskip}
\begin{wrapfigure}{r}[-15pt]{3cm}%
\raggedleft% right align the figures
\includegraphics[height=8\baselineskip]{graphics/13}%
\end{wrapfigure}
}%
\newcommand*{\lorem}{\parindent1em
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis pellentesque iaculis nunc eget congue. Etiam lobortis nisi velit. Proin tristique massa a lectus ullamcorper semper. Aenean ut dignissim diam. Integer ullamcorper eros nibh. Cras molestie neque quis lectus lobortis egestas. Maecenas vel tortor in nulla sagittis venenatis. Nulla ac eros dui, eget lacinia ante. Fusce elementum nisl ac tortor hendrerit id lacinia orci malesuada. Praesent eu iaculis mi. Vestibulum sodales tempor rutrum. }
\begin{document}
\hrule
\unskip
\begin{center}
\unskip
\begin{minipage}{12cm}
\lorem
\WrapFigure{foo}
\end{minipage}
\end{center}
\hrule
\end{document}


With graphics on demo I was getting weird sizes here is a link for the stamp, if you want to use it.

Although wrapped figures are not so popular, they have their uses. For example a lone image of the size shown in the image on a single page would look wrong otherwise.

-
IMHO, the top edge of the image should align at <x-height> above the baseline of the first line, and the bottom edge with the baseline of the last line. Thus the spacing should be \baselineskip-<x-height> (on all four sides, I think). Dunno the best way to achieve this... –  Brent.Longborough Nov 8 '11 at 14:02
@Brent.Longborough try \intertexsep{1pt}, \begin{wrapfigure}{r}[-25pt]{3cm}%,\includegraphics[height=9.3\baselineskip]{‌​graphics/13}%. –  Yiannis Lazarides Nov 8 '11 at 14:05
I'm not fond of "wrap figures"; if I had to use them, I'd put them flush with the margin. –  egreg Nov 8 '11 at 14:43
Seems to me that you may want more horizontal space than vertical space, because of the optical illusion that the (horizontal) lines are curving above and below the figure. Perhaps the ratio of the h-space to the v-space should be as 1em:1ex? –  Ryan Reich Nov 8 '11 at 15:05
@egreg Depends, if you had for example diagrams they would look wrong to set them in, as they have a lot of white space. Also when flush left they look better in line with the margin. If one has uncaptioned illustrations wrapped look ok, at least through an Engineer's eye:) –  Yiannis Lazarides Nov 8 '11 at 15:08

I'm by no means an expert on the matter but I did notice a couple of things in your example:

1. Your figure is "starting" at the same point as the paragraph is: I personally find this distracting (weird at the very least), I'd leave a couple of "full" paragraph lines before starting to warp the figure around it (think of it as an orphan of sorts)
2. Your paragraph is ending "too soon": like in the previous point, this looks off, maybe allow for more than a single line of text below it?

Now to your question proper, this is what I'd do:

• The top of the figure should be aligned (near) to the x-height of the line it wraps around of (ie. the image should be a "continuation" of sorts to the very first line of the wrapping paragraph). Setting it to exactly the x-height may leave too little space between the image and the previous (non-wrapped) line.
• The bottom of the figure should be (near) the baseline of the last line it wraps (same reasoning as before).

This deals with the vertical spacing. As for the horizontal spacing:

• In the first place, the amount of left and right space will depend on where the wrapped image will actually be typeset: to the left, right, or center (think two columns) of the block. That being said, I'd leave something close to 1 em between the image and the block (in your example).
• the space to leave to the side of the image that lies close to the margin is a bit trickier: like protrusion, it will depend on the actual image. I think that a framed image (like yours) is best treated like a very big "M" would for protrusion, so the amount of space needed will be close to a standard separation (ie. one m space); were your image to be non-framed then maybe this distance could be decreased.

On a side note, maybe there are other tactics you could try:

• I think that there's a critical point of sorts: you could leave an "excessive" space of a \qquad around the image and it would look "ok" (in terms of whether the spacing is off or not relative to each other)... of course this may be too much space and look awful in the block.
• Maybe you could try letting the image "overflow" to the margin altogether: allow for 1/3 of the image to protrude to the right. This would make the point of whether the spacing to the margin is off or not moot.

I agree with @egreg in that these look pretty bad most of the times, but acknowledge that there may be situations in which this is just the thing to have.

Once more, this is just an amateur's opinion on the matter.

-