Skip to main content
\( \newcommand{\lt}{<} \newcommand{\gt}{>} \newcommand{\amp}{&} \)

AppendixFWindows Subsystem for Linux

With Windows 10 you can install the Windows Subsystem for Linux (WSL). This is basically Ubuntu Linux (one of the most popular versions of Linux) integrated into Windows 10 in a way that command-line Linux programs can be executed easily. News and announcements can be fouund at ( Michael Doob reports on 2017-06-02 that this works quite well for the programs necessary to author with PreTeXt, and provides the following help.

Installing WSL

If you have the “Anniversary Edition” of Windows 10 (later than August 2016), then installing WSL is not difficult. Just follow the (reasonably straightforward) instructions given by Microsoft at the address

Upon completion of the installation, you should

  • be able to use the bash command from the PowerShell window,

  • have your own WSL userid (distinct from Windows),

  • have your own WSL password (distinct from Windows).

A little background about using about the command line
  • You type in commands (terminated by the Enter key) and the operating system responds. For example, if you type in date, the operating system responds with (what it considers to be) the date. Using the command line is an ongoing conversation between you and the operating system.

  • The sudo command: when a command starts with sudo, the rest of the command is executed with administrative privileges. This is needed, for example, to install software or update the operating system. You must give your password when you run sudo (although you get a little window of time after the first usage when it is not necessary to do so).

  • The sudo apt-get update command: this is used to resynchronize the local listing of installed packages with those in the official repository.

  • The sudo apt-get upgrade command: this is used to bring all the local software up to date with those in the official repository.

Run sudo apt-get update followed by sudo apt-get upgrade with a new system to bring it up to date. It is a good idea to repeat this frequently to have the latest software on your computer.

Installing software

The default configuration of WSL does not have the software needed for creating documents with PreTeXt. There are a few commands to be run before you can get started.

  • The program git is used to download the PreTeXt software onto your local computer. It is installed with the command sudo apt-get install git.

  • The program xsltproc is used to create your readable documents. It is installed with the command sudo apt-get install xsltproc.

After these are installed, you are ready to set up PreTeXt.

Putting PreTeXt on your computer

Here are the steps necessary to get the PreTeXt software onto your computer:

  • Make a new directory mkdir mathbook

  • Make your own clone of the PreTeXt repository git clone

  • Move to the new directory cd mathbook

  • Initialize the new directory with git pull

This last command synchronizes your files with those in the official repository. You should run it frequently to keep your files up to date.

The simplest example

Here is a brief description of the use of WSL to create readable files. You, as the author, create the xml file. The system will contain an appropriate xsl file that translates your xml file to something readable.

Several editors come with WSL by default including nano, pico, vi, and vim. Here are the steps to follow:

  1. Type the command cd to align yourself in your home directory.

  2. Use one of the editors to create a file called hw.xml (you could use the command nano hw.xml), and add the following text:

                <?xml version="1.0" encoding="UTF-8" ?>
                    <article xml:id="hw">
                    <p>Hello, World!</p>
  3. Run the command xsltproc mathbook/xsl/mathbook-html.xsl hw.xml Upon completion, your should have a file called hw.html.

  4. Now the tricky part: you want to view the hw.html file in a browser, but the usual Windows programs cannot see the files created within WSL. So we have to copy them to a place where they are visible. Fortunately, this is pretty easy to do. To put hw.html on your desktop, use the command cp hw.html /mnt/c/Users/username/Desktop (note that “username” must be replaced by your Windows user name). Once the file is on the desktop, a double click will open it in a browser.

The edit-xsltproc-view cycle just given may seem daunting at first blush. Some things that can help:

  • Pressing the up arrow when at the command line displays the previously executed commands. Hitting the enter key while such a command is displayed executes it. This saves a lot of retyping.

  • It is possible to define aliases to shorten commands. Your local Linux guru can show how this is done.

  • It is possible to define scripts to shorten multiple commands. Your local Linux guru can show how this is done.