%% Copyright 2010 R. Matveyev % % This work may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 % of this license or (at your option) any later version. % The latest version of this license is in % http://www.latex-project.org/lppl.txt % and version 1.3 or later is part of all distributions of LaTeX % version 2005/12/01 or later. % % This work has the LPPL maintenance status `maintained'. % % The Current Maintainer of this work is R. Matveyev. % % This work consists of the files: % lpic.sty instructions.tex % instructions.pdf instructions-differential.eps % instructions-differential.pdf README \documentclass[10pt]{amsart} \usepackage{lpic} \setlength{\topmargin}{0mm} \setlength{\textheight}{210mm} \def\cmd#1{\texttt{$\backslash$#1}} \let\tex=\TeX \let\latex=\LaTeX \def\pdflatex{pdf\LaTeX} \title{Package \texttt{lpic.sty}. \latex{} over included graphics.} \author{R. Matveyev} \begin{document} \maketitle The package \textbf{\texttt{lpic}} defines convenient interface to put any \latex{} material on top of included graphics. \latex{} material could also be rotated and typeset on top of a white box overshadowing graphics. Since coordinates of \latex{} boxes are given relative to the original, unscaled graphics, when graphics is rescaled, \latex{} annotations stay at their right places (unless you do something extreme). In a draft mode it allows to draw a coordinate grid over the picture for easy adjustment of positions of the annotations. \section{Usage} Package defines an environment \texttt{lpic} and \cmd{lbl}. The environment \vspace{2mm}\par\noindent \cmd{begin}\{\texttt{lpic}\}[{\sc OPTIONS}] \{$<${\sc filename}$>${\sc DIMENSIONS}\} \begin{quote} \cmd{lbl}[{\sc POSITION}] \{{\sc x-coord,y-coord[,angle];\latex{} material}\}\\ \vdots \end{quote} \cmd{end}\{\texttt{lpic}\} \vspace{2mm}\par\noindent produces a \tex\ box with included graphics and the \latex{} material on top of it. \begin{itemize} \item[$<${\sc filename}$>$] is a name of external graphics in \texttt{PS, EPS} or \texttt{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 \texttt{epsfig} package. \vspace{2mm} \item[{\sc DIMENSIONS}] is one of the following: \begin{enumerate} \item empty string \item \texttt{() } \item \texttt{(,) } \item \texttt{(X) } \item \texttt{(X,) } \item \texttt{(,Y) } \item \texttt{(X,Y) } \end{enumerate} where each \texttt{X} and \texttt{Y} is either a positive decimal (with decimal point, not coma!) or length (currently only numerical constant lengths work). Decimal number is interpreted as a scale coefficient and length is interpreted as the desired horisontal or vertical dimension of the figure. If neither \texttt{X} nor \texttt{Y} are supplied (cases 1, 2, 3), then the original unscaled picture is included. If only one of \texttt{X} and \texttt{Y} is given (cases 4, 5, 6), then picture is scaled homotetically. If both are present (case 7), then graphics is scaled vertically and horisontally, according to given parameters.\\ For example: \\ \cmd{begin}\{\texttt{lpic}\}\{\texttt{tessalation}\} -- means include graphics in the file \texttt{tessalation} at the original size.\\ \cmd{begin}\{\texttt{lpic}\}\{\texttt{tessalation(0.5)}\} -- means include graphics at the half the original size.\\ \cmd{begin}\{\texttt{lpic}\}\{\texttt{tessalation(0.5,3)}\} -- means include graphics shrinking twice in the horisontal direction and stretching 3 times in the vertical direction.\\ \cmd{begin}\{\texttt{lpic}\}\{\texttt{tessalation(,10cm)}\} -- include graphics homotetically scaled, so that height is equal to 10cm.\\ \cmd{begin}\{\texttt{lpic}\}\{\texttt{tessalation(150mm)}\} -- include graphics homotetically scaled, so that width is equal to 150mm.\\ \cmd{begin}\{\texttt{lpic}\}\{\texttt{tessalation(150mm,0.7)}\} -- include graphics scaled, so that width is equal to 150mm and height is 0.7 of the original. \vspace{2mm} \item[\sc OPTIONS] is a coma separated list of options (no spaces). Option are processed sequentially, thus options to the right override preceding ones. Parameter in \texttt{()} is optional, if omitted then some default value is taken. Options are: \item[\texttt{l(length)}] -- the size of the left margin beyond bounding box of graphics (default 0mm). Negative values are also acceptable. \item[\texttt{r(length)}] - right margin \item[\texttt{t(lenght)}] - top margin \item[\texttt{b(length)}] -- bottom margin \item[\texttt{grid(step)}] -- Draw a grid over the picture of step \texttt{step*}\cmd{lpunitlength} and thickness \cmd{lpgridthickness}. Parameter \texttt{step} must be an integer and defaults to 5. \item[\texttt{coords(step)}] -- write coordinates with the step \texttt{step*}\cmd{lpunitlength}. Parameter step must be an integer and defaults to 10. \item[\texttt{frames(length)}] -- draw boxes of thickness {\tt length} over \latex{} material. Default value is 0.01mm \item[\texttt{frame(length)}] -- draw a box around the whole thing (margins included). \texttt{length} is the thickness of the lines. Default value is 0.7mm. \item[\texttt{figframe(length)}] -- draw a box around the included graphics. \texttt{length} is the thickness of the lines. Default value is 0.2mm. \item[\texttt{draft}] -- draw whatever is convenient for adjusting the positions of \latex{} material. That includes grid, coordinates, all types of frames. \item[\texttt{clean}] -- remove all auxiliary stuff. \item[\texttt{nolbl}] -- don't typeset any \latex{} material. \item[\texttt{nofigure}] -- don't include the graphics, just an empty box of appropriate size \end{itemize} \vspace{2mm}\par\noindent Inside of \texttt{lpic} environment one can issue \cmd{lbl} command with the following syntax:\vspace{2mm}\par \texttt{\cmd{lbl}[{\sc OPTIONS}]% \{{\sc COORDINATES; any \latex{} material}\}} \vspace{2mm}\par\noindent \latex{} material is put in a box, rotated if necessary and printed in appropriate place. White rectangular background, which overshadows part of graphics could also be created. \begin{itemize} \item[\sc 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 \cmd{lpunitlength} (default 1mm). So, if the picture is scaled, all the boxes containing \latex{} will hopefully stay at their appropriate places. \item[\sc OPTIONS] is optional and consists of at most three letters, one from the set {\tt\{t,b\}}, one from {\tt\{r,l\}} and one from {\tt\{w,W\}} in any order. \texttt{[t$|$b,l$|$r]} options 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 referring to 9 evenly spaced points in the rectangle. If one of \texttt{[w$|$W]} is given then \latex 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 \texttt{w} and margins \cmd{lpbgsep}-wide are added in case of \texttt{W}. Note that \texttt{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 \texttt{xdvi}. but once postscript file is created, \latex{} will show. \end{itemize} \section{ADJUSTABLE PARAMETERS} \begin{itemize} \item[\cmd{lpunitlength}] (1mm) Units in the unscaled coordinate system. \item[\cmd{lpmarginright}] (0mm) \item[\cmd{lpmarginleft}] (0mm) \item[\cmd{lpmargintop}] (0mm) \item[\cmd{lpmarginbottom}] (0mm) Default sizes of margins. \item[\cmd{lpbgsep}] (\cmd{fboxsep}) Margins for the white background. \item[\cmd{lpgridthickness}] (0.01mm) Thickness of the grid lines. \item[\cmd{lpframethickness}] (0.7mm) Thickness of the frame around the whole box. \item[\cmd{lplblframethickness}] (0.01mm) Thickness of the frame around labels. \item[\cmd{lpfigframethickness}] (0.2mm) Thickness of the frame around included graphics. \item[\tt lpgridstep] (5) Counter containing the step to draw grid lines \item[\tt lpcoordstep] (10) Counter containing the step to draw coordinates \end{itemize} \newpage \section{Example} \def\T{\operatorname{\mathrm T}} \def\d{\operatorname{\mathrm d}} \def\o{\ensuremath{\text{\tiny$\operatorname{\mathcal O}$}}} \def\R{\mathbb R} Provided the file \texttt{instructions-differential.eps} or \texttt{instructions-differential.pdf} contains the graphics one can include it in the document, drawing a grid and putting \latex{} on top of it. \begin{verbatim} \begin{lpic}[l(10mm),r(5mm),t(5mm),b(10mm),draft]{instructions-differential(0.7,0.6)} \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[r]{79,102;$\T_{f(x_0)}Y$} \lbl[lb]{21,115;$\T_{f(x_0)}Y$} \lbl[l]{22,74;$\d f(\delta x)$} \lbl[r]{16,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]{42,99;$\o(\delta x)$} \lbl[b]{10,121;$Y=\R$} \lbl[br]{47,21;Graph of $\d f$} \lbl[bl]{26,36,13;Graph of $y=f(x)$} \end{lpic} \end{verbatim} \vspace{5mm} \begin{lpic}[l(10mm),r(5mm),t(5mm),b(10mm),draft]{instructions-differential(0.7,0.6)} \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[r]{79,102;$\T_{f(x_0)}Y$} \lbl[lb]{21,115;$\T_{f(x_0)}Y$} \lbl[l]{22,74;$\d f(\delta x)$} \lbl[r]{16,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]{42,99;$\o(\delta x)$} \lbl[b]{10,121;$Y=\R$} \lbl[br]{47,21;Graph of $\d f$} \lbl[bl]{26,36,13;Graph of $y=f(x)$} \end{lpic} \vspace{5mm} When all label on the picture are adjusted one can get a ``clean'' picture by either removing \texttt{draft} option or adding \texttt{clean}. \begin{verbatim} \begin{lpic}[l(10mm),r(5mm),t(5mm),b(10mm),draft,clean]{instructions-differential(0.7,0.6)} ... \end{lpic} \end{verbatim} \begin{lpic}[l(10mm),r(5mm),t(5mm),b(10mm),draft,clean]{instructions-differential(0.7,0.6)} \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[r]{79,102;$\T_{f(x_0)}Y$} \lbl[lb]{21,115;$\T_{f(x_0)}Y$} \lbl[l]{22,74;$\d f(\delta x)$} \lbl[r]{16,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]{42,99;$\o(\delta x)$} \lbl[b]{10,121;$Y=\R$} \lbl[br]{47,21;Graph of $\d f$} \lbl[bl]{26,36,13;Graph of $y=f(x)$} \end{lpic} Now if the picture is rescaled, \latex{} boxes also shift to appropriate positions. However, the angles are the visible angles in the final output and sometimes they have to be adjusted after rescaling of the included graphics. \begin{verbatim} \begin{lpic}[l(10mm),r(5mm),t(5mm),b(10mm),draft,clean]{instructions-differential(0.8,0.4)} ... \end{lpic} \end{verbatim} \begin{lpic}[l(10mm),r(5mm),t(5mm),b(10mm),draft,clean]{instructions-differential(0.8,0.4)} \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[r]{79,102;$\T_{f(x_0)}Y$} \lbl[lb]{21,115;$\T_{f(x_0)}Y$} \lbl[l]{22,74;$\d f(\delta x)$} \lbl[r]{16,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]{42,99;$\o(\delta x)$} \lbl[b]{10,121;$Y=\R$} \lbl[br]{47,21;Graph of $\d f$} \lbl[bl]{26,36,13;Graph of $y=f(x)$} \end{lpic} \vspace{5mm} \end{document}