How to Configure DruTeX


How to install and configure Drupal's TeX implementation, DruTeX. We localize DruTeX files within their site directories (rather than in a global Drupal-wide directory) so sites are self-contained.


Install and Configure PEAR Wiki Filter

  1. Download and unpack the PEAR Wiki filter module in the sites/all/ directory.
  2. Site Building -> Modules -> Enable the PEAR Wiki filter module.

Install and Configure DruTeX

  1. Download and unpack the DruTeX module in the sites/all/ directory.
  2. Site Building -> Modules -> Enable the DruTeX module.
  3. User management -> Permissions -> Grant authenticated users and above rights to access DruTeX stuff.
  4. Localize the DruTeX module settings:
    Site Config -> DruTeX Settings ->
       Temporary directory: sites/
       Conversion method: custom
       Conversion Method (Custom): [fully-qualify the paths to the latex and dvipng binaries]
  5. Create a DruTeX input format:
    Site Config -> Input Formats -> Add Input Format ->
       Name: DruTeX
       Roles: [authenticated user and above]
       Filters: DruTeX, PEAR Wiki Filter
       Save Configuration
  6. Configure the DruTeX input format:
    Site Config -> Input Formats -> DruTeX -> Configure
       Configure tab->
          PEAR Wiki filter
             Path of PEAR packages: /usr/local/www/drupal6/sites/all/modules/pearwiki_filter/
             Format: MediaWiki
                Allow HTML? [unchecked]
                Ignore tags: equation equations math tex
                Use wiki links? [checked]
                Replacement for Spaces: -
                Base path for wikilinks: /wiki
                Use wikitools? [checked]
                Base path for images: sites/
                Use image module? [checked]
          DruTeX Submodules:
             LaTeX Renderer
             LaTeX to HTML
             PDF Generator
             Line break converter
          DruTeX :: Base Settings
             Temporary directory: /tmp
             Image directory: sites/
             Image URL: sites/
          DruTeX :: LaTeX Renderer
             Conversion Method: custom
             Conversion Method (Custom): [fully qualify latex and dvipng binary pathnames]
          DruTeX :: PDF Generator
             Conversion Command: [fully qualify pdflatex binary pathname]
       Rearrange Tab ->
          PEAR Wiki Filter
  7. Teach DruTeX to understand MediaWiki-style <math> tags. Add this rule to, around line 114:
      /*  environment */
      $E[] = (object) array(
          'pattern' => '@]*)?>(.+?)@se',
          'replacement' => "'$1' . drutex_render('$ $2 $', 'format')",
          'weight' => -3


  3. DruTeX Documentation
  4. <math> mediawiki tag support
  5. Is there a way to reset all png images?