2. Content and layout#
2.1. Paragraphs#
In RST, paragraphs are simply blocks of text separated by a line break.
To facilitate proofreading and quickly visualize the changes made in a document, It is recommended not to write lines of more than a hundred characters. However, the automatic conversion of documents from the ODT format did not respect this instruction.
Avoid putting « in code_aster » or « in aster » in documentation. We can well imagine that it is in code_aster, since we are in the code_aster documentation! In this regard, Christophe- MMN .Durand case law, we say « code_aster » not « LE code_aster »).
The « document versions » tables (in particular in the R docs) are removed. The history of the versions is naturally supported by the Git repository system. It is therefore useless to complete this table which will be deleted when the documents are validated.
As much as possible, avoid putting data entry extracts into the documentation. Indeed, these snippets are not modified if the syntax evolves and they become syntactically incorrect. Data inputs are put into test cases.
For numeric values, always put a number after the decimal point
(1.0
and not 1.
) because 1.
refers to the start of a numbered list.
2.2. Formatting#
The purpose of RST is precisely to do a minimum of formatting to keep documentation homogeneous and legible even in plain text. The RST file itself can be read.
Use:
an asterisk:
*text*
for an text in italics,two asterisks:
**text**
for bold text,serious accents:
``text``
for asnippet of code
.
Formatting using html code is not allowed.
- note
You write keywords normally: MODELE. It is not necessary to write « MODELE ».
The command paragraph is généré automatiquement. In the command documentation, do not repeat the syntax in the description of each keyword. It’s redundant and sometimes a step up to date.
For code blocks, we use:
.. _d8.00.01-myfunction:
.. code-block: python
:caption: Python code example
def myfunction (x):
"" "Example function" ""
Return x + 1
This results in:
def myfunction (x):
"" "Example function" ""
Return x + 1
You can use « :caption:``. The legend is then displayed, the block is numbered and you can thus refer to it by displaying this number.
See an example of Python code example or Code source 2.1.
is obtained with:
See an example of :ref:`d8.00.01-myfunction` or :numref:`d8.00.01-myfunction`.
2.3. Equations#
The equations are entered in LaTeX format.
There are a lot of online editors:
The `Hostmath`_ < https://www.hostmath.com/> site.
- < https://fr.overleaf.com/learn>* The LaTeX documentation provided by `Overleaf`_ is one of
more complete
- < http://detexify.kirelabs.org/classify.html>* The `Detexify`_ site is very practical:
You draw your symbol with the mouse and it finds you the LaTeX command Correspondent
Equations can be separated or*inline* in the text.
The heat equation is:
Equations :eq:`eq-chaleur` and :eq:`eq-fourier` are taken from
document :ref:`r5.02.01 <r5.02.01>`:
.. _d8.00.01-eq-heat:
.. math:
:label: eq-heat
-\ text {div} (-\ lambda\nabla T (r, t))) + s (r, t) =\ rho {C} _ {p}\ frac {\ partial T (r, t)} {\ partial t}
.. math:
:label: eq-fourier
q (r, t) =-\ lambda\nabla T (r, t)
with :math:`\lambda` the thermal conductivity, :math:`\rho {C}_{p}` the heat
volume at constant pressure.
This results in:
Equations eq-chaleur
and (2.2) are taken from
document r5.02.01:
: label: eq-heat
-text {div} (-lambdanabla T (r, t))) + s (r, t) =rho {C} _ {p}frac {partial T (r, t)} {partial t}
with \(\lambda\) the thermal conductivity, \(\rho {C}_{p}\) the heat volume at constant pressure.
It is useful to add the reference « .. _d8.00.01-eq-heat: « to insert a link to an equation from another page or document.
2.4. General rules for the typography of equations#
LaTeX is not a WYSIWYG editor, the fundamental concept (like RST) is to separate the background from the shape. So don’t do manual formatting (adding spaces, returning to the line, etc.).
It is certain that RST and the HTML generator include theamsmath``` packages and their cousins. These packages were developed by the American Mathematical Society, which gives access to « standardized » characters and methods in the community (including French ones).
It is not necessary to number all the equations.
Giving font formatting guidelines should be avoided. For example, « mathbim {=} » is useless.
If you need text in an equation, use the « text {tagada} » environment. It is important for the management of spaces (note the presence of spaces) and characters accented.
To add spaces to an equation (in increasing order of spacing): « , », « quad » and
\ quad
. Avoid unbreakable spaces in math mode (like ~
) it constrains the algorithm too much
LaTeX rendering. The formatting guidelines in math mode are in the form of environments
dedicated (array
for example).
Get in the habit of using « lbracerbrace`` or »left (andright) « , so the height of
brackets may be adjusted if you change the content.
Do not use /
for division, but « frac ». For example, « frac {1} {3} » rather than
1/3
.
For Greek letters (and mathematical symbols in general) in bold, « mathbf {sigma} » ne won’t work, you have to « boldsymbol {sigma} ».
Compare: \(\boldsymbol{\sigma}\) (with « boldsymbol ») and \(\mathbf{\sigma}\) (with »boldsymbol ») mathbf).
For (small) deformations, the « varepsilon » symbol (\(\varepsilon\)) is more consistent to the habits of mechanics as « epsilon » (\(\epsilon\)).
the « cdot » directive is for the dot product only, don’t use it outside of this
specific context. Likewise, it is recommended not to put .
(multiplicative point) between
scalars for example, if you want it to be cleaner (especially between letters)
Greek characters (which are in italics), you can insert a space like « , ».
To write a set of equations, here is an example of syntax:
.. math:
\ left\ {\ begin {array} {ll}
eq1 &\ text {for this value}\\
eq2 &\ text {for the other value}
\ end {array}\ right.
This results in:
- left{begin {array} {ll}
eq1 &text {for this value}\ eq2 &text {for the other value} end {array}right.
Mathematical operators should be declared as follows:
.. math:
\ declaremaThoperator {\ dist} {dist}
For example, don’t write ``mathit {dist} « . Compare the result:
- declareMathOperator {dist} {dist}
disttext {with operator declaration}mathit {dist}text {with dedicated formatting}
The vertical bars are defined by « green » and »Green », do not use « parallel » and ``mid ». Compare the result:
- left{begin {array} {ll}
text {Vertical barmid:}mid &text {Vertical bargreen:}green\ text {Double vertical barparallel:}parallel &text {Double vertical barGreen:}Green\ end {array}right.
In particular, these vertical bars make it possible to designate the standards:
« Greenunderline {x}Green`` gives \(\Vert \underline{x} \Vert\)
\ parallel\ underline {x}\ parallel
results in \(\parallel \underline{x} \parallel\)
And absolute values:
« green {x}green`` gives \(\vert {x} \vert\) « mid {x}mid`` gives \(\mid {x} \mid\)
2.5. Equation style sheet#
It is recommended to use the equation style sheet, which groups the notations together. the most frequent in mechanics, which makes it possible to have a certain homogeneity in the documentation.
To do this, include RST at the top of each file (on the 2nd line just after the main reference for example):
.. include:../../../../../../.. /_cache/math_styles.rest
Thus, standardized notations can be used to:
vector |
\(\vector{u}\) |
vector {u} |
matrix |
\(\tensTwo{A}\) |
TensTwo {A} |
Euclidean norm |
\(\normEucl{\vector{v}}\) |
normeUCL {vector {v}} |
Example:
- Important
Do not modify this style file on your own initiative, if you want to enrich it or change it, ask the person responsible for the reference documentation.
2.6. Figures#
.. figure:../../../.. /man_r/r5/r5.03.01/Pictures/object_69.svg
:name: d8.00.01-fig-newton
:width: 30%
Newton diagram
This results in:
The figure
directive allows you to define a « Newton diagram » legend,
contrary to the image
directive.
The option « :name:`` defines a reference that is typically used.
Link to figure :ref:`d8.00.01-fig-newton` or :numref:`d8.00.01-fig-newton`.
This results in:
Link to figure d8.00.01-fig-newton or d8.00.01-fig-newton
.
2.6.1. Image adapted to the light/dark theme#
By default, the image is automatically adjusted to best fit the theme. A white background is added and the brightness is reduced:

You can choose one image for the light background and one for the dark background
using the :class: only-light
or :class: only-dark
attribute.
We display one or the other of the images according to the theme:

: class: only-light

: class: only-dark
If we consider that the image should be displayed as it is, without adjustment,
Whatever the theme, we use :class: dark-light
(these are the two previous images without adjustment):


2.7. Bulleted lists, numbered#
Example:
* A first element
* A second
* With a sub-level
* The third and final element.
This results in:
A first element
A second
With a sub-level
The third and final element.
With automatic numbering:
#. A first element
#. A second
#. The third and final item.
This results in:
A first element
A second
The third and final item.
2.8. notes#
To add a remark, simply do:
note
It is necessary to specify this or that.
This results in:
- note
It is necessary to specify this or that.
2.9. Different types of tables#
2.9.1. Simple chart#
For small tables, you can use the simplest form:
.. _d8.00.01-tab-simp:
.. table:: Material parameters of steel
:widths: auto
===== ===== =====
Parameter Value
===== ===== =====
E 2.1e9
:math:`\nu` 0.3
===== ===== =====
This results in:
The presence of the title in the table automatically numbers it. To refer to it, we use:
See :ref:`d8.00.01-tab-simp` or :numref:`d8.00.01-tab-simp`.
This results in:
See d8.00.01-tab-simp or d8.00.01-tab-simp
.
2.9.2. CSV table#
As soon as the table is more complicated, the CSV format is preferred:
.. csv-table:: Material parameters of steel
:header: "Parameter", "Value"
:widths: 50, 50
E, 2.1e9
:math:`\nu`, 0.3
":math:`\lambda`, :math:`\mu` ", "being 'known' as :math:`\frac{E \nu}{(1+\nu)(1-2\nu)}`,
That is 1.21e9
and :math:`\frac{E}{2(1+\nu)}`, which is 0.81e9"
- Note
Double quotes `` »``allow you to delimit the content of columns (mandatory) when a comma is in the content of the cell).
You can go back the line (between
"
) and skip a line to start a new paragraph.
This results in:
Parameter |
Value |
---|---|
|
50 |
E |
2.1e9 |
\(\nu\) |
0.3 |
\(\lambda\), \(\mu\) |
|
2.9.3. Tables in lists#
You can also use this format using two levels of bulleted lists:
.. list-table:: Material parameters of steel
:widths: 50, 50
:header-rows: 1
* - Parameter
- Value
* - E
- 2.1e9
* - :math:`\nu`
- 0.3
* - :math:`\lambda`, :math:`\mu`
- being 'known' as :math:`\frac{E \nu}{(1+\nu)(1-2\nu)}`,
That is 1.21e9
and :math:`\frac{E}{2(1+\nu)}`, which is 0.81e9
This results in:
- : widths: 50, 50
- header-rows:
1
Parameter
Value
E
2.1e9
\(\nu\)
0.3
\(\lambda\), \(\mu\)
being “known” as \(\frac{E \nu}{(1+\nu)(1-2\nu)}\), That is 1.21e9
and \(\frac{E}{2(1+\nu)}\), which is 0.81e9