Updated on 2025-11-20 GMT+08:00

Previewing Markdown, PDF, and Math Formula in JupyterLab

By defaults, this function is disabled. The preview function has cross-site scripting (XSS) security risks. To ensure system security, do not open untrusted files. Exercise caution when using these functions and ensure that the file source is reliable.

Enabling/Disabling the Preview Function

  1. Open the terminal of the notebook instance. For details, see Common Functions of JupyterLab.
  2. Run the commands below to enable or disable the preview function.
    • Enable the PDF file preview function.
      $CONDA_BIN/jupyter labextension enable @jupyterlab/pdf-extension
    • Disable the PDF file preview function.
      $CONDA_BIN/jupyter labextension disable @jupyterlab/pdf-extension
    • Enable the Markdown file preview function.
      $CONDA_BIN/jupyter labextension enable @jupyterlab/markdownviewer-extension:plugin
    • Disable the Markdown file preview function.
      $CONDA_BIN/jupyter labextension disable @jupyterlab/markdownviewer-extension:plugin
    • Enable the math formula preview function.
      $CONDA_BIN/jupyter labextension enable @jupyterlab/mathjax-extension:plugin
      $CONDA_BIN/jupyter labextension enable @jupyterlab/mathjax2-extension:plugin
    • Disable the math formula preview function.
      $CONDA_BIN/jupyter labextension disable @jupyterlab/mathjax-extension:plugin
      $CONDA_BIN/jupyter labextension disable @jupyterlab/mathjax2-extension:plugin
  3. After enabling or disabling the preview function, refresh the web page.