Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
test-org
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stéphane Del Pino
test-org
Commits
01364732
Commit
01364732
authored
5 years ago
by
Stéphane Del Pino
Browse files
Options
Downloads
Patches
Plain Diff
exemple initial
parents
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test.org
+172
-0
172 additions, 0 deletions
test.org
with
172 additions
and
0 deletions
test.org
0 → 100644
+
172
−
0
View file @
01364732
#+SETUPFILE: https://fniessen.github.io/org-html-themes/setup/theme-bigblow.setup
#+STARTUP: org-pretty-entities entitiespretty
#+PROPERTY: header-args :comments yes
#+OPTIONS: h:3 num:t toc:3
#+TITLE: Exemple de document interactif
#+OPTIONS: author:nil date:nil
#+OPTIONS: tex:t
#+LANGUAGE: fr
#+LATEX_HEADER: \usepackage[hmargin=2.5cm,vmargin=1.5cm]{geometry}
#+LATEX_COMPILER: pdflatex --shell-escape
#+LATEX_HEADER_EXTRA: \usepackage{amsmath}
#+LATEX_HEADER_EXTRA: \usepackage{amsthm}
#+LATEX_HEADER_EXTRA: \usepackage{amssymb}
#+LATEX_HEADER_EXTRA: \BeforeBeginEnvironment{minted}{\begin{mdframed}}
#+LATEX_HEADER_EXTRA: \AfterEndEnvironment{minted}{\end{mdframed}}
L'utilisation reste très basique, mais cela donne un aperçu de ce
qu'on peut faire.
Pour changer le style de rendu ~html~, on peut simplement remplacer
~readtheorg~ par ~bigblow~.
* Bases
D'abord, on peut juste afficher un bloc de code sans l'évaluer
#+BEGIN_SRC python :exports code :eval no
import math
#+END_SRC
On peut aussi Afficher le code puis le résultat de son exécution
#+BEGIN_SRC bash :exports both :results output :wrap EXAMPLE
echo "Hello world"
#+END_SRC
#+RESULTS:
#+BEGIN_EXAMPLE
Hello world
#+END_EXAMPLE
Et évidemment n'afficher que le résultat. Ici, on utilise un script
python pour approcher (bien mal) la valeur de $\pi$.
#+BEGIN_SRC python :exports results :results output
import math
sum = 0
for i in range(1,1000):
sum += 1./(i*i)
pi = math.sqrt(6*sum)
print ("pi ~ ", pi)
#+END_SRC
#+RESULTS:
: pi ~ 3.14063710098594
* Équations
Il est possible d'écrire des maths normalement dans le texte ($\partial u - \Delta
u = f$), mais aussi d'afficher les sources LaTeX et la compilation
associée
#+BEGIN_SRC latex :exports both :results raw drawer
\begin{equation*}
\frac{\pi^2}{6}=\sum_{n=1}^{\infty}\frac{1}{n^2}
\end{equation*}
#+END_SRC
#+RESULTS:
:RESULTS:
\begin{equation*}
\frac{\pi^2}{6}=\sum_{n=1}^{\infty}\frac{1}{n^2}
\end{equation*}
:END:
On peut aussi n'afficher que les sources LaTeX
#+BEGIN_SRC latex :exports code
\begin{equation*}
\frac{\pi^2}{6}=\sum_{n=1}^{\infty}\frac{1}{n^2}
\end{equation*}
#+END_SRC
#+RESULTS:
#+BEGIN_EXPORT latex
\begin{equation*}
\frac{\pi^2}{6}=\sum_{n=1}^{\infty}\frac{1}{n^2}
\end{equation*}
#+END_EXPORT
Ou d'utiliser un bloc de sources comme pour d'autres langages et
n'afficher que le résultat.
#+BEGIN_SRC latex :exports results :results raw drawer
Soit $u_0 \in \mathbb{N}^*$,
\begin{equation*}
\forall n\ge 1\quad
u_n=
\begin{cases}
\frac{u_n}{2},&\mbox{si }\frac{u_n}{2}\in\mathbb{N},\\
3 u_n+1,&\mbox{sinon.}
\end{cases}
\end{equation*}
#+END_SRC
#+RESULTS:
:RESULTS:
Soit $u_0 \in \mathbb{N}^*$,
\begin{equation*}
\forall n\ge 1\quad
u_n=
\begin{cases}
\frac{u_n}{2},&\mbox{si }\frac{u_n}{2}\in\mathbb{N},\\
3 u_n+1,&\mbox{sinon.}
\end{cases}
\end{equation*}
:END:
* Python
** Exécution Python
On trace une courbe, qu'on stocke dans un fichier, et on écrit les
sorties textes
#+BEGIN_SRC python :exports both :results output
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(-5,5,100)
print ("déclare une figure")
fig = plt.figure()
print ("trace la fonction sinus")
plt.plot(x,np.sin(x))
filename = 'sin.png'
fig.tight_layout()
print ("sauve la fonction dans le fichier,", filename)
plt.savefig(filename)
print ("fin")
#+END_SRC
#+RESULTS:
: déclare une figure
: trace la fonction sinus
: sauve la fonction dans le fichier, sin.png
: fin
Et voici la figure obtenue (elle est stockée dans un fichier)
[[file:sin.png]]
** Exemple de code python non exécuté
#+BEGIN_SRC python :exports both :eval no
print("x=",(both))
#+END_SRC
#+RESULTS:
# Local Variables:
# ispell-local-dictionary: "francais"
# End:
* gnuplot
#+BEGIN_SRC gnuplot :exports both :file courbe.png
reset
set grid
plot [0:2] sin(x**x)**2*exp(x)
#+END_SRC
#+RESULTS:
[[file:courbe.png]]
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment