Go to CTAN for the latest version.
lpic.sty(14.11.09), ver. 0.7 (fixed problems with white background in pdf),
lpic.sty(13.10.09), ver. 0.6,
lpic.sty(08.10.07), ver. 0.5,
usage.pdf, example.pdf, example.tgz

lpic is a LaTeX package to put LaTeX on top of included graphics, thus allowing to add TeX annotations to imported graphics. It defines convenient interface to put TeX over included graphics and allows to draw white background under the typeset material to overshadow the graphics.

The package lpic allows to put any LaTeX material on top of included graphics. It defines an environment lpic and two commands \lbl and \lpichelp.

Command \lpichelp dumps usage instructions into the document.

Syntax:

\begin{lpic}[OPTIONS]{"nameofgraficsfile"DIMENSIONS}
   \lbl[POSITION]{x-coord,y-coord,angle;LaTeX material}
    .
    .
    .
\end{lpic}

It produces a TeX box with included graphics and the LaTeX material on top of it.

"nameofgraficsfile" -- is a name of external graphics in PS, EPS or PDF format. There is no need to give the extension of the file, appropriate format will be chosen, depending whether latex or pdflatex is run on the document. Convention is the same as for epsfig package.

DIMENSIONS is one of the following:
  1. empty string
  2. ()
  3. (,)
  4. (X)
  5. (X,)
  6. (,Y)
  7. (X,Y)

If neither X nor Y are supplied (cases 1, 2, 3) then original unscaled picture is included. If only one of X and Y is given (cases 4, 5, 6), then picture is scaled homotetically. If both are present (case 7), then graphics is scaled vertically and horizontally, according to given parameters.

Each X and Y is either a positive decimal (with decimal point, not coma!) or length (any length expression understandable to TeX). Decimal number is interpreted as a scale coefficient and length is interpreted as the desired horizontal or vertical dimension of the figure.

OPTIONS is a coma separated list of options. Option are processed sequentially, so rightmost options override previous ones. options:
Parameter in () is optional, if omitted then some default value is taken.
  l(length) - the size of the left margin beyond bounding box of graphics (default 0mm).
  r(length) - right margin
  t(lenght) - top margin
  b(length) - bottom margin
  grid(step) - Draw a grid over the picture of step step*\lpunitlength and thickness \lpgridthickness. Parameter step must be an integer and defaults to 5.
  coords(step) - write coordinates with the step step*\lpunitlength. Parameter step must be an integer and defaults to 10.
  frames(length) - draw boxes of thickness "length" over latex material. Default value is 0.01mm
  frame(length) - draw a box around the whole thing (margins included). length is the thickness of the lines. Default value is 0.7mm.
  figframe(length) - draw a box around the included graphics. length is the thickness of the lines. Default value is 0.2mm.
  draft - draw whatever is convenient for adjusting the positions of latex material. That includes grid, coordinates, all types of frames.
  clean - remove all auxiliary stuff.
  nolbl - don't typeset any latex material.
  nofigure - don't draw the graphics, just an empty box of appropriate size

Inside of lpic environment one can issue \lbl command with the following syntax:
  \lbl[OPTIONS]{COORDINATES;LaTeX material}
LaTeX material is put in a box, rotated if necessary and printed in appropriate place.

COORDINATES are either pair or a triple of decimals. The first two numbers are coordinates of the point, where LaTeX material should be placed and the third is an angle of rotation applied to the box containing the material. Coordinates are measured in the coordinate system in the original, unscaled picture, with the unit equal to \lpunitlength (default 1mm). So, if the picture is scaled, all the boxes containing LaTeX shift accordingly.

OPTIONS - is at most three letters, one from the set {t,b}, one from {r,l} and one from {w,W} in any order. t,b,l,r give a reference point in a box containing latex text. Coordinates refer to this reference point. Rotation is also centered at this point. Thus, there are total 9 possibilities:

			--------------------------------
			|tl              t            tr|
			|				|
			|				|
			|l   		 .             r|
			|				|
			|				|
			|bl		 b	      br|
			--------------------------------
Dot in the center stands for empty string. If one of w,W is given then LaTeX material is put on top of white box. The size of the box is equal to the size of the box containing the material in case of w and margins \lpbgsep-wide are added in case of W. Note that xdvi apparently renders postscript after dvi, so any postscript covers dvi material. Thus, if you use background, you will not be able to see your latex in xdvi. but once postscript file is created, LaTeX will show.

ADJUSTABLE PARAMETERS:
\lpunitlength=1mm units in the unscaled coordinate system
\lpmarginright=0mm Default values for margins.
\lpmarginleft=0mm
\lpmargintop=0mm
\lpmarginbottom=0mm
\lpbgsep=\fboxsep Margins for the white background.
\lpgridthickness=0.01mm Thickness of the grid lines.
\lpframethickness=0.7mm Thickness of the frame around the whole box.
\lplblframethickness=0.01mm Thickness of the frame around labels.
\lpfigframethickness=0.2mm Thickness of the frame around included graphics.
counters:
lpgridstep=5 Step to draw grid lines
lpcoordstep=10 Step to draw coordinates

EXAMPLE:
\begin{lpic}[l(10mm),r(5mm),t(5mm),b(10mm),draft]{differential(0.96,0.7)}
   \lbl[t]{80,9;$x_0$}
   \lbl[b]{87,11;$\delta x$}
   \lbl[t]{101,7,-7;$x_0+\delta x$}
   \lbl[b]{120,11;$\T_{x_0}X$}
   \lbl[t]{88,59;$\delta x$}
   \lbl[b]{120,61;$\T_{x_0}X$}
   \lbl[tl]{120,3,-10;$X=\R$}
   \lbl[r]{79,74;$\d f(\delta x)$}
   \lbl[l]{21,74;$\d f(\delta x)$}
   \lbl[r]{79,102;$\T_{f(x_0)}Y$}
   \lbl[lb]{21,115;$\T_{f(x_0)}Y$}
   \lbl[l]{21,74;$\d f(\delta x)$}
   \lbl[r]{17,88;$f(x_0)+\d f(\delta x)$}
   \lbl[r]{19,60;$f(x_0)$}
   \lbl[r]{11,110;$f(x_0+\delta x)$}
   \lbl[l]{41,99;$\o(\delta x)$}
   \lbl[l]{21,74;$\d f(\delta x)$}
   \lbl[l]{21,74;$\d f(\delta x)$}
   \lbl[b]{10,121;$Y=\R$}
   \lbl[br]{47,21;Graph of $\d f$}
   \lbl[bl]{30,37,8;Graph of $y=f(x)$}
\end{lpic}
\begin{lpic}[l(10mm),r(5mm),t(5mm),b(10mm),frame]{differential(0.96,0.7)}
   \lbl[t]{80,9;$x_0$}
   \lbl[b]{87,11;$\delta x$}
   \lbl[t]{101,7,-7;$x_0+\delta x$}
   \lbl[b]{120,11;$\T_{x_0}X$}
   \lbl[t]{88,59;$\delta x$}
   \lbl[b]{120,61;$\T_{x_0}X$}
   \lbl[tl]{120,3,-10;$X=\R$}
   \lbl[r]{79,74;$\d f(\delta x)$}
   \lbl[l]{21,74;$\d f(\delta x)$}
   \lbl[r]{79,102;$\T_{f(x_0)}Y$}
   \lbl[lb]{21,115;$\T_{f(x_0)}Y$}
   \lbl[l]{21,74;$\d f(\delta x)$}
   \lbl[r]{17,88;$f(x_0)+\d f(\delta x)$}
   \lbl[r]{19,60;$f(x_0)$}
   \lbl[r]{11,110;$f(x_0+\delta x)$}
   \lbl[l]{41,99;$\o(\delta x)$}
   \lbl[l]{21,74;$\d f(\delta x)$}
   \lbl[l]{21,74;$\d f(\delta x)$}
   \lbl[b]{10,121;$Y=\R$}
   \lbl[br]{47,21;Graph of $\d f$}
   \lbl[bl]{30,37,8;Graph of $y=f(x)$}
\end{lpic}

TODO:
1. Optimise the whole thing.
2. Write legible help.
3. Spaces in the list of options make troubles!
4. Angles should be measured in unscaled coordinate system!
5. Different steps for the grid and coordinates in vertical and horisontal direction
6. Some say they would prefer \lbl[...](x,y[,a]){...} syntax