Skip to main content

The PreTeXt Guide

Subsection 5.2.1 Installing PreTeXt

Before you can install PreTeXt locally, make sure you have the following software on your computer, or else install it using instructions easily searched for online.
  • Python, version 3.8.5 or later. In a terminal, type python --version to ensure you are already set up. On MacOS or Linux, your command for python might be called python3, so also try python3 --version.
  • To produce a pdf, or to generate tikz images from source, you need . Try xelatex --version to see if you already have this.
  • Any text editor. Visual Studio Code 2  is an excellent choice (and has an extension, PreTeXt-tools 3 , with specific language support), but other editors such as SublimeText, atom, emacs, vi, etc. can also be used. See Appendix D.
Now we can install PreTeXt. Open a terminal and type the following:
$ pip install pretext
If this fails, try:
$ python -m pip install pretext
(or, if python3 worked above, do python3 -m pip install pretext.)
The python -m helps in case Python is on your PATH but pip is not. This is a useful fix for the rest of the commands listed for the PreTeXt-CLI.
To verify that the CLI is installed, type pretext --version (or python -m pretext --version) and you should get back a number (1.4.2, for example).
For quick hints about what you can do, the CLI has built-in help. You can access this by entering pretext --help or pretext build --help (replacing build with new or view or generate etc.).

Upgrading.

This documentation will assume you have version 1.0 or later of the CLI. You can upgrade the CLI to the most recent version through PIP using the command:
$ pip install pretext --upgrade
If you want to experiment with bleeding-edge features, you can install a nightly development version of the CLI by running:
$ pip install pretext --upgrade --pre
If you ever want to downgrade to previous version, you can do that with pip as well. For example, to install version 1.1.0:
$ pip install pretext=="1.1.0"

Best Practice 5.2.1.1.

If you installed the PreTeXt-CLI before version 1.0, you need to manually uninstall the package pretextbook (which is what the CLI was called during early development). Run pip uninstall pretextbook and then pip install pretext te get caught up.
code.visualstudio.com
marketplace.visualstudio.com/items?itemName=oscarlevin.pretext-tools