Skip to main content

The PreTeXt Guide

Section 37.1 Solution Manual

An author may include a <hint>, <answer>, and/or <solution> as part of each <exercise> or <project>. Some of these may be designed for the reader, while some may designed for the instructor. A separate conversion is available to make a PDF containing just these items.
To use the CLI, first create a small XSL file, called solution-manual.xsl, in the xsl folder at the root of your project, containing the following lines.
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet xmlns:xsl="" version="1.0">
    <xsl:import href="./core/pretext-solution-manual-latex.xsl"/>
Then add the following target in your project manifest.
<target name="solutions">
Then you can build the solution manual with the PreTeXt-CLI using pretext build solutions.
Or using xsltproc, execute
xsltproc -xinclude pretext-solution-manual-latex.xsl fauna.xml
with suitable paths in front of the stylesheet and the source file. The result will be a file like fauna.tex, which can be processed with a engine such as pdflatex. By default, the result will include all <statement>, <hint>, <answer>, and <solution> for every <exercise> or <project> anywhere in your <book>. Note that this conversion is explicitly designed only for <book>, so send a request for support for an <article>. Division headings (<chapter>, <section>, …) will be present, if and only if they have content. Page headers will help locate chapters and sections. Exercise numbers will be complete, to make it easier to locate individual problems. In other words, Exercise 3 from Exercises 5.6 will be labeled as 5.6.3, not just 3, as in the original text.
Any cross-reference that exists inside a solution will be honored and displayed faithfully. By that, we mean that if the author includes an <xref> as part of a solution to, say, Theorem 10.6, then that cross-reference will be rendered visibly as “Theorem 10.6” in the solution manual. However, it will not be live (clickable) since the target (the <theorem> itself) is not part of the solution manual. We have not, and do not expect to, determine if a cross-reference points to part of another exercise which is visible in the remainder of the solution manual and then elect to make it live/clickable. In other words, all cross-references are static, even if there is the possibility to be more dynamic for a select few. If this is a severe shortcoming, consider producing an Instructor’s Version (Chapter 36), enhanced with additional solutions, where all cross-references are live, and targets are more likely to be available.
A set of switches allows a publisher to control including <statement>, <hint>, <answer>, or <solution>–for inline exercises, divisional exercises, worksheet exercises, reading questions, projects, and tasks within exercises and projects. So there is a total of \(4\times 5 = 20\) yes/no switches, for \(2^{20} = 1\,048\,576\) supported scenarios. Start at Section 26.4 for more on these settings. The preamble is the same as for the full document, so besides being excessive, it should support any of the styling options.
In practice, you will discover that the conversion will reproduce all of your <frontmatter> and <backmatter> exactly as if it was part of the entire text itself. The reason for this is that you may actually want a little bit of front matter, perhaps some back matter, and maybe a new title page that makes it clear that you have created a solution manual. Best practice would be to have your project already organized so that each of your chapters is in its own file, and incorporated into your document via a top-level file using the <xi:include> mechanism. (Read about modularity in Section 5.3 if this is new to you.) So now make an additional top-level file for the solution manual, maybe with a new title, a new preface, and acknowledgements of any help creating exercises and solutions. Be sure to include all of the main matter, even if you know some parts may not have any <exercise>. You want numbering to be correct for your cross-references and this means having all the content available to be counted, even if it is not visible in the end product. This new top-level file is really the only overhead involved in getting a quality, reliable solution manual together.
The philosophy behind this conversion is that a publisher may wish to create a different range of solutions for instructors, for limited distribution in ways that students are unlikely to find. Thus, we have tried to produce a functional document by default, without too much attention to making a beautiful document. Of course, improvements and suggestions are always welcome, though here the priority will be ease-of-use.


This conversion illustrates some advantages of including all the content of your project in one source document, and then selecting a subset of that content for different audiences. The advantage of authoring <hint>, <answer>, and <solution> in close proximity to the <statement> should mean a higher probability that changes to one part of an exercise will be reflected in the other parts. And with standard processing tools, and provided switches, an author and publisher can easily decide which parts to show, and when.
By including all of your project’s content in one monolithic source document, it is possible to confidently reference supporting parts of the main text via cross-references from solutions. When a new edition is released, any variations in numbering will automatically be reflected in a new solution manual, created with no additional editing or proofreading.
You have attempted of activities on this page.