Skip to main content
Logo image

Section 1.4 Installation and use

PreFigure may be used in two different ways.
  1. PreFigure is available in a GitHub Codespace.
     1 
    github.com/davidaustinm/prefigure-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.
  2. 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 either
prefig 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 in output/foo.svg while annotations read by a screen reader are in output/foo.xml. If PreFigure is called from within PreTeXt, then the annotations will appear in foo-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 the diagcess library. To view the diagram without annotations, use prefig 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 use
prefig build examples/tangent.xml	  
prefig view tangent
	
PreFigure looks for tangent.svg in the current directory or some subdirectory. Alternatively, you could say
prefig view examples/tangent.xml
	
pdf
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 of prefig pdf assumes that rsvg-convert is installed, which it provided in a codespace. The use of rsvg-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.