Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sphinx latexpdf ignore parts of a file

Is it possible to have Sphinx ignore part of index.rst when building the pdf with latexpdf?

For example, my index.rst file contains (but does not begin with) the lines


.. image:: https://img.shields.io/....
  :target: https://pypi.org/....

.. image::  https://travis-ci.org/....
  :target: https://travis-ci.org/...

.. image:: https://coveralls.io/repos/github/....
  :target: https://coveralls.io/github/....

.. image::  https://readthedocs.org/.....
  :target: https://libensemble.readthedocs.org/....

These should appear in the html that is built, but not in the PDF. I didn't see anything here: https://www.sphinx-doc.org/en/master/latex.html

Is it possible to tell sphinx to ignore these lines?

like image 495
jmlarson Avatar asked Sep 17 '25 07:09

jmlarson


1 Answers

I think you could use only directive:

  • in index.rst
 .. only:: html

     .. image::  https://readthedocs.org/.....
     :target: https://libensemble.readthedocs.org/....
  • in Makefile
 htmldoc:

    make -e SPHINXOPTS="-t html" html
like image 101
aflp91 Avatar answered Sep 19 '25 14:09

aflp91