Section 1.4 Installation and use
PreFigure may be used in two different ways.
- 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.
1
github.com/davidaustinm/prefigure-codespace
- 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.
2
github.com/davidaustinm/prefigure
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.xml
into 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.svg
while 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 thediagcess
library. To view the diagram without annotations, useprefig view -i foo
to 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.svg
in 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-b
flag will cause the diagram to be built first:prefig pdf -b foo
.Use ofprefig pdf
assumes thatrsvg-convert
is installed, which it provided in a codespace. The use ofrsvg-convert
ensures 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-b
flag 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 examples
to copy the set of examples into the current directory.