|
|
|
|
|
|
|
|
|
|
Old days (1985-2005): LaTeX for BW paper output, but now
|
|
and later want to collect the pieces into a larger document, maybe some book, or one big web document, is that at all feasible?
Probably not, but I have a solution :-)
equation*
, equation
, align*
, align
+
eqnarray
, split
, alignat
, ... (numerous!)equation*
, equation
, align*
, align
equation*
, equation
, align*
, align
equation*
, equation
, align*
equation*
, equation
, eqnarray*
, align*
(but no labels)
subfigure
)Conclusion: Highly non-trivial to translate a LaTeX document into something based on HTML and vice versa.
TITLE: Some Title
AUTHOR: name1 at institution1, with more info & institution2
AUTHOR: name2 email:name2@web.com at institution
DATE: today
# A table of contents is optional:
TOC: on
Title and authors must have all information on a single line!
__Abstract.__
Here goes the abstract...
__Summary.__
Here goes the summary...
=
signs:
======= This is an H1/chapter heading =======
===== This is an H2/section heading =====
===== This is an H3/subsection heading =====
=== This is an H4/paragraph heading ===
__This is a paragraph heading.__
* Bullet list items start with `*`
and may span several lines
* *Emphasized words* are possible
* _Boldface words_ are also possible
* color{red}{colored words} too
* `inline verbatim code` is featured
o and sublists with enumerated items starting with `o`
o items are just indented as you would do in email
*
and may span several linesinline verbatim code
is featured
o
# Insert index items in the source
idx{key word1} idx{key word2}
# Label
===== Some section =====
label{this:section}
# Make reference
As we saw in Section ref{this:section}, references, index
items and labels follow a syntax similar to LaTeX
but without backslashes.
# Make reference to equations
See \eqref{eq1}-\eqref{myeq}.
# Make hyperlink
"some link text": "https://github.com/doconce/doconce"
# Hyperlink with complete URL as link text
URL: "https://github.com/doconce/doconce"
Figure with HTML and LaTeX info, and caption, all on one line:
FIGURE: [figdir/myfig, width=300 frac=1.2] My caption. label{fig1}
# This figure will be 300 pixels wide in HTML and span 1.2 times
# the linewidth in LaTeX.
MOVIE: [https://www.youtube.com/embed/P8VcZzgdfSc, width=420 height=315]
...where $a=\int_{\Omega}fdx$ is an integral.
!bt
and !et
tags,
the rest is plain LaTeX:
!bt
\begin{align}
\frac{\partial u}{\partial t} &= \nabla^2 u,
label{a:eq}\\
\nabla\cdot\pmb{v} & = 0
label{b:eq}
\end{align}
!et
$$
\begin{align}
\frac{\partial u}{\partial t} &= \nabla^2 u,
\tag{1}\\
\nabla\cdot\pmb{v} & = 0
\tag{2}
\end{align}
$$
!bc
and !ec
tags:
!bc pycod
def solver(I, a, T, dt, theta):
"""Solve u'=-a*u, u(0)=I, for t in (0,T] with steps of dt."""
dt = float(dt) # avoid integer division
N = int(round(T/dt)) # no of time intervals
T = N*dt # adjust T to fit time step dt
u = zeros(N+1) # array of u[n] values
t = linspace(0, T, N+1) # time mesh
u[0] = I # assign initial condition
for n in range(0, N): # n=0,1,...,N-1
u[n+1] = (1 - (1-theta)*a*dt)/(1 + theta*dt*a)*u[n]
return u, t
!ec
def solver(I, a, T, dt, theta):
"""Solve u'=-a*u, u(0)=I, for t in (0,T] with steps of dt."""
dt = float(dt) # avoid integer division
N = int(round(T/dt)) # no of time intervals
T = N*dt # adjust T to fit time step dt
u = zeros(N+1) # array of u[n] values
t = linspace(0, T, N+1) # time mesh
u[0] = I # assign initial condition
for n in range(0, N): # n=0,1,...,N-1
u[n+1] = (1 - (1-theta)*a*dt)/(1 + theta*dt*a)*u[n]
return u, t
The !bc
command can be followed by a specification of the computer
language: pycod
for Python code snippet, pypro
for complete Python
program, fcod
for Fortran snippet, fpro
for Fortran program, and so
forth (c
for C, cpp
for C++, sh
for Unix shells, m
for Matlab).
!bc pyoptpro
or a file *.pyopt
, the code applies the
Online Python Tutor for displaying
program flow and state of variables:
===== Problem: Flip a Coin =====
label{demo:ex:1}
files = flip_coin.py, flip_coin.pdf
solutions = mysol.txt, mysol_flip_coin.py
keywords = random numbers; Monte Carlo simulation
!bsubex
Make a program that simulates flipping a coin $N$ times.
!bhint
Use `r = random.random()` and define head as `r <= 0.5`.
!ehint
!esubex
!bsubex
Compute the probability of getting heads.
!bans
A short answer: 0.5.
!eans
!bsol
A full solution to this subexercise can go here.
!esol
!esubex
!bsubex
Make another program that computes the probability
of getting at least three heads out of 5 throws.
!esubex
r = random.random()
and define head as r <= 0.5
.
b)
Compute the probability of getting heads.
Answer.
A short answer: 0.5.
Solution.
A full solution to this subexercise can go here.
c)
Make another program that computes the probability
of getting at least three heads out of 5 throws.
Filenames: flip_coin.py
, flip_coin.pdf
.
!split
===== Headline =====
* Key point 1
* Key point 2
* Key point 3 takes very much more text to explain because
this point is really comprehensive, and although long
bullet points are not recommended in general, we need
it here for demonstration purposes
FIGURE: [../doc/src/slides/fig/teacher1, width=100]
Key equation:
!bt
\[ -\nabla^2 u = f \quad\hbox{in }\Omega \]
!et
And maybe a final comment?
!split
===== Next slide... =====
$$ -\nabla^2 u = f \quad\hbox{in }\Omega $$
!bslidecell MN
and !eslidecell
tags. Below is an example with a bullet list to the left and
a figure to the right (two cells, numbered 00 and 01).
!split
===== Headline =====
!bslidecell 00
!bpop
* Key point 1
* Key point 2
* Key point 3 takes very much more text to explain because
this point is really comprehensive, and although long
bullet points are not recommended in general, we need
it here for demonstration purposes
!epop
!bpop
!bt
\[ -\nabla^2 u = f \quad\hbox{in }\Omega \]
!et
!epop
!eslidecell
!bslidecell 01
FIGURE: [../doc/src/slides/fig/broken_pen_and_paper, width=400, frac=0.8]
!eslidecell
!split
===== Next slide... =====
|
|