Examples of use of LaTeX for docs.
LaTeX - http://www.latex-project.org/
typically you just need to make a .tex file and run latex (creates .dvi files and dvipdf or smth like that, or directly pdflatex
vilo@mac:~/W$ mkdir latex
vilo@mac:~/W$ cd latex/
vilo@mac:~/W/latex$ cat > hw.tex
\documentclass{article}
\title{Cartesian closed categories and the price of eggs}
\author{Jane Doe}
\date{September 1994}
\begin{document}
\maketitle
Hello world!
\end{document}
vilo@mac:~/W/latex$
vilo@mac:~/W/latex$ pdflatex hw
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014/MacPorts 2014_1) (preloaded format=pdflatex)
...
Output written on hw.pdf (1 page, 31718 bytes).
Transcript written on hw.log.
vilo@mac:~/W/latex$ ll
total 88
drwxr-xr-x+ 6 vilo staff 204 14 veebr 12:06 .
drwxr-xr-x+ 36 vilo staff 1224 14 veebr 12:05 ..
-rw-r--r--+ 1 vilo staff 8 14 veebr 12:06 hw.aux
-rw-r--r--+ 1 vilo staff 2814 14 veebr 12:06 hw.log
-rw-r--r--+ 1 vilo staff 31718 14 veebr 12:06 hw.pdf
-rw-r--r--+ 1 vilo staff 184 14 veebr 12:06 hw.tex
vilo@mac:~/W/latex$
This has created a hw.pdf file for you.
You can include images from files, etc. You can write code that "generates" latex for several images, etc.