Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add guidelines for math usage in the documenation #1837

Merged
merged 3 commits into from
Feb 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions docs/Contributing/style-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ to alter is placed inside back-ticks.
:guilabel:`Next` button on the installer wizard.
* :literal:`:literal:` -- Literal is used when you want to note a text element in its raw form. This is
equivalent to using two back-ticks: ````text````.
* ``math`` and ``.. math::`` -- Used to insert mathematics, see `Formulas`_.
* :literal:`:menuselection:` -- Menu Selection is used to give the path of menu clicks such as
:menuselection:`Game --> Local Options`. To denote submenus, use a test arrow like this: :literal:`-->`
between the selection items.
Expand Down Expand Up @@ -225,3 +226,34 @@ Figure Numbers
The first line ``.. _Start Screen:`` is a label for the figure. The ``numfig`` feature of Sphinx will
automatically give the figure a number in the order they are found in the page. You can then provide a
link to the figure in your text with :literal:`:numfig:\`Label\``


Formulas
========

The Freeciv21 documentation supports inserting mathematics. This feature should be used sparingly, ideally
only on technical pages or in sections that less math-savvy users can skip. When math formulas are used on
non-technical pages (such as any one of the manuals), the reasoning should be relatively simple following
`elementary algebra <https://en.wikipedia.org/wiki/Elementary_algebra>`_. Contrary to ordinary math
textbooks, it is best to avoid single-letter symbols in the documentation. Full-text names should be used
instead, wrapping them with ``\text{}``:

.. math::
\text{happy} \ge \text{unhappy} + 2 \times \text{angry}.

There may be exceptions to this rule on primarily technical pages: quantities that exist as variables in the
code could be typeset in monospace with ``\texttt{}``, or defining a few symbols may come handy when writing
a long reasoning. The main guideline for formulas is to take your time to make them as readable as possible.

Formulas use the ``:math:`` role or the ``.. math::`` directive. These blocks support most of the LaTeX
`mathematics syntax <https://en.wikibooks.org/wiki/LaTeX/Mathematics>`_. The ``:math:`` role is used for inline
math in a paragraph. For instance, ``:math:`a+b=1``` becomes :math:`a+b=1`. The directive is used for longer
or more important formulas that come on their own line:

.. math::
a+b=1.

This is rendered using an ``align`` environment, so alignment directives (``&``) can be used.

.. warning::
When editing formulas, checking both the HTML and the PDF output is heavily recommended.