Section 1.1 An example diagram
Figure 1.1.1 contains a diagram that could appear in a calculus textook and that is authored in PreFigure.
Like PreTeXt, PreFigure is a markup language that is designed to reflect the structure of mathematical diagrams. The PreFigure source for creating this diagram is given in Listing 1.1.2.
<diagram dimensions="(300, 300)" margins="5">
<definition> a=1 </definition>
<definition> f(x)=exp(x/3)*cos(x) </definition>
<coordinates bbox="[-4,-4,4,4]">
<grid-axes xlabel="x" ylabel="y"/>
<graph function="f"/>
<tangent-line function="f" point="a"/>
<point p="(a, f(a))">
<m>(a,f(a))</m>
</point>
</coordinates>
</diagram>
PreFigure provides an XML vocabulary that allows an author to describe the components of a mathematical diagram and how they relate to one another in an intuitive way. The
<diagram>
element delimits all of the PreFigure input.Notice that the graphical components of the diagram in Figure 1.1.1 include a grid, two axes, the graph of a function, the tangent line to the function at some point, and the point itself. The PreFigure source includes an XML element for each of these components.
The
<coordinates>
element defines our window into the \(xy\)-plane while the label is included inside the <point>
element to which it is attached and wrapped in an <m>
element so that it will be processed by MathJax.In addition, authors may define mathematical objects, such as a real number \(a\) and a function \(f(x)\text{,}\) which are to be used in the construction of subsequent graphical components.
Following the PreTeXt paradigm, PreFigure makes stylistic decisions about the appearance of graphical components so that authors can focus on the structure of their diagram. Authors can, however, override these decisions to modify the visual appearance of a diagram. Authors may also provide a publisher file setting their own defaults so that, for instance, all the diagrams in a textbook have a common visual style (yet to be implemented).
PreFigure XML source is processed by a Python package to create output images in the SVG format. As a result, diagrams will scale to an appropriate size when included in a document without sacrifiing quality or visual information.