Authors: | Hans Petter Langtangen (hpl at simula.no) |
---|---|
Date: | Aug 19, 2016 |
This note tells why and how you can use DocOnce to ease the writing of scientific books with much mathematics and computer code.
Scientific books are very often written in LaTeX, but LaTeX is primarily suited for PDF output on paper. Today, your readers will be using different devices like tablet and phones for reading, and to address these media you need to write HTML. DocOnce lets you write in a syntax that is as simple as you use in email, and can then automatically translate that syntax to highly professional LaTeX or HTML for output (it can produce other formats too). So, the writing itself is easier since you avoid a lot of LaTeX or HTML tags, and the output is more versatile. We refer to the DocOnce tutorial and the web page for more arguments!
doc/src
and start writing the first chapter! (replace why.do.txt
)bash make.sh
, see my-book-4print.pdf
(this is the standard Springer book layout, the svmono
class adapted to
DocOnce)bash make_html.sh
, see my-book.html
Let us demonstrate emphasize text, bold text, inline monospace font
,
and of course computer code that we can copy from a part of a file
using regular expressions:
def f(x):
return 42*x
It is a big advantage to copy computer code directly into the book, but you can also write it as part of the text, this time the FORTRAN equivalent:
subroutine f(x)
real*8 x
f = 42*x
return
end
Mathematics is written in plain LaTeX inside a begin-end tex environment:
Remember to use simple LaTeX: just the equation
, equation*
, \[ ... \]
,
align
, align*
, alignat
, or alignat*
environments!
Inline mathematics makes use of dollar signs: \(f(x)=42x\).
As LaTeX writer, remember that white space counts in DocOnce syntax! Be extra careful with indentation of lists.
Also remember that DocOnce avoids backslash in label, ref and cite, e.g., in references like [Ref1].