Chapter 5 Compiling a PTX file
Now is the time for the magic to happen! You will take a sample PTX file (extension
xml) and use it to create an HTML document and a PDF. (Note: XML is a deprecated file type; when you create PTX documents, your extension should be
First, navigate in your Git Bash shell to the folder containing the PTX or XML file you plan to work with. For our example, navigate to
~/mathbook/examples/hello-world, which contains the XML file
To compile to HTML: From the folder containing
~/xsltproc/xsltproc --xinclude ~/mathbook/xsl/mathbook-html.xsl hello-world.xml.
This will compile the XML file into an HTML file,
hello-world.html, in the same folder as
hello-world.xml. You can open it by navigating to the folder via the Windows desktop and opening it the way you’d open any HTML document on your machine.
To compile to PDF:
From the folder containing
hello-world.xml, type in the same command as you used to create the HTML document, replacing the
mathbook-latex.xsl; that is, enter
~/xsltproc/xsltproc --xinclude ~/mathbook/xsl/mathbook-latex.xsl hello-world.xml.
This will compile the XML file into a LaTeX file,
hello-world.tex, in the same folder as
From the same folder, enter the command
pdflatex hello-world.tex to create a PDF from the LaTeX file.
hello-world.pdf will appear in the folder. You can open it by navigating to the folder via the Windows desktop and opening it the way you’d open any PDF document on your machine.
You can generalize from this to compile any PTX (XML) file to HTML or PDF.