.. -*- coding: utf-8 -*- .. role:: sref(numref) .. role:: xref(numref) .. Copyright (C) 2019, Wolfgang Scherer, .. .. This file is part of Documentation Standard. .. .. Permission is granted to copy, distribute and/or modify this document .. under the terms of the GNU Free Documentation License, Version 1.3 .. or any later version published by the Free Software Foundation; .. with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. .. A copy of the license is included in the section entitled "GNU .. Free Documentation License". .. inline comments (with du_comment_role) .. role:: rem(comment) .. role:: html(raw) :format: html .. role:: shx(code) :language: sh .. rst-class:: xnarrow xmedium large xhuge xultra ###################################################### :rem:`|||:sec:|||`\ Figures ###################################################### .. >>CODD See `the components of a doctoral dissertation and their order `_ .. >>CODD Dedication .. >>CODD Epigraph .. >>CODD Abstract .. compound:: For best results, figures, tables and code blocks should get captions and they should be referenced with and ``:xref:`` for figures/tables/code-blocks (`:sref:` for sections). ``:xref:`` and ``:sref:`` are defined as ``:numref:``, when appropriate, otherwise as ``:ref:``. Do not use the ``image`` directive to keep figures in place. Label prefixes allow using the same caption for different entities, e.g., listing and figure (see :sref:`sec:Directive figure`). Emacs support functions for generating labels and their shortcuts are shown in :xref:`tab:Emacs support functions for generating labels`. .. _`tab:Emacs support functions for generating labels`: .. table:: Emacs support functions for generating labels +------------------+-----------------------------------+ | shortcut | command | +==================+===================================+ | :kbd:`C-c r l s` | :kbd:`M-x sdx-make-section-label` | +------------------+-----------------------------------+ | :kbd:`C-c r l f` | :kbd:`M-x sdx-make-figure-label` | +------------------+-----------------------------------+ | :kbd:`C-c r l t` | :kbd:`M-x sdx-make-table-label` | +------------------+-----------------------------------+ | :kbd:`C-c r l l` | :kbd:`M-x sdx-make-listing-label` | +------------------+-----------------------------------+ | :kbd:`C-c r l c` | :kbd:`M-x sdx-make-caption-label` | +------------------+-----------------------------------+ | :kbd:`C-c r l r` | :kbd:`M-x sdx-make-figctr-label` | +------------------+-----------------------------------+ .. \|:here:| .. >>CODD Introduction .. >>CODD Chapter .. _`sec:Figures with numbers`: ================================================== :rem:`|||:sec:|||`\ Figures with numbers ================================================== Sphinx allows certain entities to be referenced by number (see :xref:`fig:Numeric references example`). .. _`fig:Numeric references example`: .. figctr:: Numeric references example .. code-block:: rst See :xref:`fig:UML test` in :sref:`sec:Directive uml`. renders as: See :xref:`fig:UML test` in :sref:`sec:Directive uml`. This requires the option :data:`numfig` to be set to `True` in :file:`conf.py` as shown in :xref:`lst:option numfig in fileconfpy`. .. _`lst:option numfig in fileconfpy`: .. code-block:: python :caption: option `numfig` in :file:`conf.py` :linenos: numfig = True numfig_format = { 'section': 'section {number}, {name}', 'figure': 'figure %s', 'table': 'table %s', 'code-block': 'listing %s', } The supported entities are: - **section** labels. - Directive **figure** with filename as arguments, first paragraph in body as title, other pragraphs as legend (see :sref:`sec:Directive figure`). - Directive **table** with title (caption) as arguments, body must contain a table (see :sref:`sec:Directive table`). - Directive **code-block** with option `:caption:` (see :sref:`sec:Directive code-block`). - Directive **uml** with option `:caption:` in `figure` namespace (see :sref:`sec:Directive uml`). - Directives **graphviz**, **dot** with option `:caption:` in `figure` namespace (see :sref:`sec:Directives graphviz dot`). - Directive **figctr** with title (caption) as arguments in `figure` namespace. Body contains arbitrary material (see :sref:`sec:Directive figctr`). .. _`sec:Directive figure`: -------------------------------------------------- :rem:`||:sec:||`\ Directive `figure` -------------------------------------------------- As documented in `reStructuredText Directives, figure`_. See :xref:`lst:Figure example Magrittes Pipe`) and :xref:`fig:Figure example Magrittes Pipe`). - **always** use **fig:** prefix for label .. _`lst:Figure example Magrittes Pipe`: .. code-block:: rest :caption: Figure example Magritte's Pipe :linenos: .. _`fig:Figure example Magrittes Pipe`: .. figure:: _static/MagrittePipe.jpg Figure example Magritte's Pipe .. _`fig:Figure example Magrittes Pipe`: .. figure:: _static/MagrittePipe.jpg Figure example Magritte's Pipe .. _`reStructuredText Directives, figure`: http://docutils.sourceforge.net/docs/ref/rst/directives.html#figure .. _`sec:Directive table`: -------------------------------------------------- :rem:`||:sec:||`\ Directive `table` -------------------------------------------------- The body must contain a table, however, a single table cell (rectangle) is sufficient (see :xref:`lst:table directive with single table cell rectangle` and :xref:`tab:single table cell rectangle`). - **always** use **tab:** prefix for label .. _`lst:table directive with single table cell rectangle`: .. code-block:: rest :caption: ``table`` directive with single table cell (rectangle) :linenos: .. _`tab:single table cell rectangle`: .. table:: single table cell (rectangle) +-----------------------+ | .. code-block:: text | | | | code-block without | | caption inside a | | single table cell | +-----------------------+ .. _`tab:single table cell rectangle`: .. table:: single table cell (rectangle) +-----------------------+ | .. code-block:: text | | | | code-block without | | caption inside a | | single table cell | +-----------------------+ .. _`sec:Directive code-block`: -------------------------------------------------- :rem:`||:sec:||`\ Directive `code-block` -------------------------------------------------- `code-block` directives with a `:caption:` option can be referenced by number, e.g., *"See :xref:`lst:Definition of a general code-block listing`"*: renders as |cb-ref|. .. |cb-ref| replace:: "See :xref:`lst:Definition of a general code-block listing`" - **always** use **lst:** prefix for label - **always** specify language - **always** use option `:linenos:` .. _`lst:Definition of a general code-block listing`: .. code-block:: rest :caption: Definition of a general code-block listing :linenos: .. _`lst: