103 lines
2.0 KiB
Plaintext
103 lines
2.0 KiB
Plaintext
markup
|
|
========
|
|
|
|
exercices
|
|
---------
|
|
|
|
|
|
.. ifconfig:: exercice
|
|
|
|
**Exercice** :
|
|
|
|
.. ifconfig:: correction
|
|
|
|
**Correction** :
|
|
|
|
|
|
sphinx
|
|
-----------
|
|
|
|
.. function:: spam(eggs)
|
|
ham(eggs)
|
|
|
|
Spam or ham the foo.
|
|
|
|
The function :func:`spam` does a similar thing
|
|
|
|
|
|
http://www.sphinx-doc.org/en/stable/markup/code.html
|
|
|
|
http://www.sphinx-doc.org/en/stable/domains.html
|
|
|
|
latex
|
|
--------------
|
|
|
|
s'il faut mettre du latex :
|
|
|
|
https://www.jujens.eu/posts/2014/Aug/13/rapport-rst-sphinx/
|
|
|
|
(pour le preamble)
|
|
|
|
|
|
.. role:: latex(raw)
|
|
:format: latex
|
|
|
|
----
|
|
|
|
sudo apt-get install texlive-full
|
|
|
|
|
|
You need to remove
|
|
|
|
\usepackage{algorithmicx}
|
|
|
|
and use the following in your preamble:
|
|
|
|
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
|
|
\usepackage{algpseudocode}% http://ctan.org/pkg/algorithmicx
|
|
|
|
|
|
.. raw:: latex
|
|
|
|
\begin{algorithm}
|
|
\caption{My algorithm}\label{euclid}
|
|
\begin{algorithmic}[1]
|
|
\Procedure{MyProcedure}{}
|
|
\State $\textit{stringlen} \gets \text{length of }\textit{string}$
|
|
\State $i \gets \textit{patlen}$
|
|
\BState \emph{top}:
|
|
\If {$i > \textit{stringlen}$} \Return false
|
|
\EndIf
|
|
\State $j \gets \textit{patlen}$
|
|
\BState \emph{loop}:
|
|
\If {$\textit{string}(i) = \textit{path}(j)$}
|
|
\State $j \gets j-1$.
|
|
\State $i \gets i-1$.
|
|
\State \textbf{goto} \emph{loop}.
|
|
\State \textbf{close};
|
|
\EndIf
|
|
\State $i \gets
|
|
i+\max(\textit{delta}_1(\textit{string}(i)),\textit{delta}_2(j))$.
|
|
\State \textbf{goto} \emph{top}.
|
|
\EndProcedure
|
|
\end{algorithmic}
|
|
\end{algorithm}
|
|
|
|
|
|
.. raw:: latex
|
|
|
|
\begin{algorithm}
|
|
\caption{Euclid's algorithm}\label{euclid}
|
|
\begin{algorithmic}[1]
|
|
\Procedure{Euclid}{$a,b$}\Comment{The g.c.d. of a and b}
|
|
\State $r\gets a\bmod b$
|
|
\While{$r\not=0$}\Comment{We have the answer if r is 0}
|
|
\State $a\gets b$
|
|
\State $b\gets r$
|
|
\State $r\gets a\bmod b$
|
|
\EndWhile\label{euclidendwhile}
|
|
\State \textbf{return} $b$\Comment{The gcd is b}
|
|
\EndProcedure
|
|
\end{algorithmic}
|
|
\end{algorithm}
|