FPIC pictures are included in LATEX documents by using the fpic command:
\fpic{picture-name}{ ... FPIC specification ... }
The specified picture becomes an ordinary box in LATEX, so that it can be included anywhere within the document like any other piece of text. For example, this and this are placed in-line. Notice that LATEX knows their sizes and creates the right amount of horizontal and vertical space for them.
The other side of this coin is the inclusion of TEX text within FPIC pictures. The text function turns a string--interpreted as LATEX input--into an FPIC picture. Any LATEX input can be used here, and once the text function is applied it becomes subject to the same transformations as any other piece of text:
let val A = text "$\\begin{array}{cc} a & b \\\\ c & d \\end{array}$" in hseqsplist 0.5 [A scale 1.5, A rotate 45.0] end;
The only difficulty here is that FPIC does not know how large the text will turn out to be. We adopt a solution to this problem similar, in essence, to that used by Chailloux and Suarez in mlPicTeX [2]. When FPIC is first run, it produces LATEX code that causes LATEX to write the size of the text to its intermediate (aux) file; on subsequent runs, FPIC reads this information from that file. As is common with LATEX utilities, this requires that LATEX be run twice when a new picture with text is added, or when the text of an existing picture is changed, to be sure that FPIC knows the size of the text.
With this feature, we can define a picture-framing function that will correctly frame text:
fun frame p = box (width p + 0.2) (height p + 0.2) cseq p;
frame (text "\\huge a") hseq frame (text ("\\begin{tabular}{cc} a & b" ^ "\\\\ c & d \\end{tabular}") hseq frame (text "$\\int_{0}^{1} f$" rotate 90.0);
Note that the argument to text can be any string, not just a string literal. The size of the text will still be calculated correctly:
hseqlist (map (fn i => frame (text (Int.toString (pow 10 i)))) [1, 2, 4, 8]);