Section 1.4 Installation and use
PreFigure may be used in several different ways.
-
The PreFigure Playground is a web-based environment in which might easily begin constructing diagrams.
-
PreFigure is available in a GitHub Codespace. For many users, this will be a convenient way to create figures since it provides a fully configured authoring environment. More information is available at that link.
-
PreFigure may also be installed as a Python package on your own machine. There are, however, a few additional steps required so be sure to follow the instructions given here.
From a codespace or once installed, PreFigure can be called from the command line. General help is available with
$ prefig --help
and help for specific commands can be found with, for instance,
prefig build --help.
These are the available PreFigure commands:
- build
- To compile a PreFigure source file
foo.xmlinto a diagram, use eitherprefig build foo.xml prefig build -f tactile foo.xml
where the second command builds a tactile version. In either case, the output image will appear inoutput/foo.svgwhile annotations read by a screen reader are inoutput/foo.xml. If PreFigure is called from within PreTeXt, then the annotations will appear infoo-annotations.xml. - view
-
Once an image is built, it may be viewed in a web browser with
prefig view foo
If the diagram contains annotations, this will provide a means of exploring the diagram and annotations using thediagcesslibrary. To view the diagram without annotations, useprefig view -i footo ignore the annotations.The view command offers some flexibility since the PreFigure source and the SVG output appear in different directories. For instance, if the PreFigure source appears in, say,examples/tangent.xml, we can useprefig build examples/tangent.xml prefig view tangent
PreFigure looks fortangent.svgin the current directory or some subdirectory. Alternatively, you could sayprefig view examples/tangent.xml
-
To make a PDF from a diagram that has already been built, use
prefig pdf foo
Including the-bflag will cause the diagram to be built first:prefig pdf -b foo.Use ofprefig pdfassumes thatrsvg-convertis installed, which it provided in a codespace. The use ofrsvg-convertensures that tactile diagrams are well suited for embossing. There are options for choosing the resolution of the resulting PDF, but tactile diagrams should always be converted with a resolution of 72 dpi, which is the default. - png
- To make a PNG from a diagram that has already been built, use
prefig png foo
Including the-bflag will cause the diagram to be built first:prefig pdf -b foo. - validate
- The PreFigure schema defines the structure of PreFigure source. To validate a PreFigure XML source file against the schema, use
prefig validate foo.xml
. - init
- It is not essential to do this, but if PreFigure is installed locally, you may want to begin with
prefig init, which has the effect of installing some MathJax libraries (PreFigure will try to install these later when needed) as well as the Braille29 font, which is required to create tactile diagrams for embossing. - new
- You may initialize a new PreFigure project with
prefig new. This copies a simple publication file and the diagcess library files into the current directory. PreFigure work done within this directory and any subdirectories will be able to find these when needed. - examples
- If you would like to explore the set of included examples, use
prefig examplesto copy the set of examples into the current directory.

