Section 2 Creating Accessible Diagrams
Accessible mathematical diagrams are created through an XML description of the mathematical components of the diagram. Annotations are likewise included in a simple format that specifies how they are to be traversed using a screen reader. A Python script converts XML input directly into SVG output that can be viewed in a browser or sent to an embosser.
Subsection 2.1 Basic Vocabulary
The basic diagram vocabulary, designed to mirror mathematical vocabulary, drives the SVG generation and can roughly be divided into five functional groups: (1) definitions, control, and grouping, (2) basic grids and axes, (3) one-dimensional objects, such as graphs and lines, (4) two-dimensional objects, such as areas and polygons, and (5) labels.
The XML description for the left-most diagram in Figure 1.1 is given in Listing 2.1. The
graphics
element specifies the basic dimension of a the output graphics. Note that since we are constructing a scalalable vector graphics this dimension only serves to give the aspect ratio of the resulting diagram. It is however relevant for PreTeXt to compile the graphics for inclusion in PDF output.The
boundingbox
and grid-axes
elements then specify the basic grid layout. In our case we use a grid with labeled \(x\)-axis and \(y\)-axis which are bounded to the range from \(-4\) to \(4\) each. The following two elements are definitions for a variable and the basic function \(f(x)\text{.}\) Alone they have no graphical output, but are only referenced in later drawing commands. More precisely, graph
command draws the function \(f\text{,}\) while the tangent-line
element draws the tangent at the point \(f(1)\) as we have previously defined \(a=1\text{.}\) Finally we explicitly draw this tangent point with the point
element, giving it a mathematical label of \((a, f(a))\text{.}\) Note, that this label is given in LaTeX code and can be of any complexity as it will later be processed and typeset by MathJax.Here the graph and the tangent line commands are grouped together with a
group
element. This works similar to its SVG counter part g
and ensures that semantically related elements are grouped together in the resulting SVG diagram and that they can be annotated as a single, abstract element. In addition, each element can contain an id which allows the author to provide a individual, manual annotation as we discuss next.The vocabulary currently supports the creation of mathematical diagrams that could appear in algebra and calculus textbooks. Some capabilities exist to create diagrams in other mathematical disciplines, such as linear algebra and discrete mathematics, and we plan to expand these capabilities and allow for the creation of three-dimensional content.
Subsection 2.2 Annotating Diagrams
Annotations are included separately from the graphical descriptions since the order in which elements are drawn may differ from how they are traversed in a screen reader. The set of annotations forms a hierarchical structure that begins with a global description of the diagram and proceeds inward by nesting annotations to examine graphical elements in greater detail. This provides the basic interaction model that we use to allow readers to explore the diagram in detail, as we will discuss in the next section. Many common elements are annotated automatically, leading to a standardised user experience for VI learners—or authors inspecting the diagram during the creation process—when screen reading, exploring or sonifying a diagram. Nevertheless authors can also provide bespoke manual annotations directly.
The annotations that accompany our example diagram are given in Listing 2.2. Note how the ids of the annotations either refer to element ids in the diagram specification or to standard names of elements such as grid and axes. The annotations define the layers of detail for the diagram, which can be arbitrarily deep. In the example we have a nesting depth of three: The top-most annotation provides a summary of the figure, followed by the description of the tangent graph. The latter is again broken down into the three component of graph, tangent line and tangent point, which reflect the drawn elements in the diagram as specified in Listing 2.1. We see that description for the other the main components, the axes and the grid are not explicitly given. Those will be programmatically generated and included automatically. They could, however, be overwritten manually.
In addition to the single text attributes, anotation elements can also have a secondary speech attribute that allows the author to provide more details on a particular element. Other attributes allowed are a flag to indicate that a graph should be sonified or that the children of an annotation should form a circular structure. The latter can, for example, be used in graphics like the unit circle or the network graph in Figure 1.1 to allow for circular navigation of the points of the circle or cycles in the graph.
Subsection 2.3 Processing XML into SVG
A Python script processes the XML input into SVG graphical elements and creates the annotation hierarchy in accompanying XML. Additional graphical elements are included by default to improve the diagrams' accessibility. For example, a clear rectangle is included behind a label so that background features do not interfere with the label's legibility. Mathematical labels are processed using MathJax and placed automatically relative to a specified anchor. Braille labels created by MathJax are carefully positioned for accurate rendering on an embosser.