H5P Guides

Mathematical expressions in H5Ps

On H5P.com LaTeX is enabled for all customers. Documentation for H5P.com authors.

The release on November 2, 2018, added the possibility to use mathematical expressions in H5P through LaTeX notation.

Setup

To enable this feature a new H5P library needs to be installed. Download it here, and upload it through the library admin page on your H5P enabled site.

Usage

Mathematical expressions can be added to all text fields in the H5P authoring tool. There are three different ways you can use to let H5P know this is LaTeX:

  • \( some LaTeX \) for inline LaTeX, commonly used as part of sentences within a text
  • \[ some LaTeX \] or optionally $$ some LaTeX $$ for block LaTeX, commonly used as a standalone formula that will be centered

Customizing

The MathDisplay library can be configured setting the environment variable H5P_MATHDISPLAY_CONFIG of your host system.

Example: Drupal 7

You can alter the default configuration of the MathDisplay library by adding something like this to the settings.php file within your /sites/YOUR_SITE folder, typically it's /sites/default.

$conf['h5p_library_config'] = array(
  "H5P.MathDisplay" => array(
    "renderer" => array(
      "mathjax" => array(
        "config" => array(
          "extensions" => array("tex2jax.js"),
          "jax" => array("input/TeX", "output/HTML-CSS"),
          "tex2jax" => array(
            // Important, otherwise MathJax will be rendered inside CKEditor
            "ignoreClass" => "ckeditor"
          ),
          "messageStyle" => "none"
        )
      )
    )
  )
);

 

Example: Drupal 8

You can alter the default configuration of the MathDisplay library by adding something like this to the settings.php file within your /sites/YOUR_SITE folder, typically it's /sites/default.

$config['h5p.settings']['h5p_library_config'] = array(
  'H5P.MathDisplay' => array(
    "renderer" => array(
      "mathjax" => array(
        "config" => array(
          "extensions" => array("tex2jax.js"),
          "jax" => array("input/TeX", "output/HTML-CSS"),
          "tex2jax" => array(
            // Important, otherwise MathJax will be rendered inside CKEditor
            "ignoreClass" => "ckeditor"
          ),
          "messageStyle" => "none"
        )
      )
    )
  )
);


Example: WordPress

You can alter the default configuration of the MathDisplay library by adding something like this to the wp-config.php file.

define('H5P_LIBRARY_CONFIG', array(
  "H5P.MathDisplay" => array(
    "renderer" => array(
      "mathjax" => array(
        "config" => array(
          "extensions" => array("tex2jax.js"),
          "jax" => array("input/TeX", "output/HTML-CSS"),
          "tex2jax" => array(
            // Important, otherwise MathJax will be rendered inside CKEditor
            "ignoreClass" => "ckeditor"
          ),
          "messageStyle" => "none"
        )
      )
    )
  )
));


Example: moodle

You can alter the default configuration of the MathDisplay library by adding something like this to the config.php file.

$CFG->mod_hvp_library_config = array(
  "H5P.MathDisplay" => array(
    "renderer" => array(
      "mathjax" => array(
        "config" => array(
          "extensions" => array("tex2jax.js"),
          "jax" => array("input/TeX", "output/HTML-CSS"),
          "tex2jax" => array(
            // Important, otherwise MathJax will be rendered inside CKEditor
            "ignoreClass" => "ckeditor"
          ),
          "messageStyle" => "none"
        )
      )
    )
  )
);