Literate programming tool using Markdown (since version 0.1) or LaTeX (since version 0.4) as markup languages and Tcl as programming language. Tcl code can be embedded directly in the text using single backticks or as code blocks using triple backticks. A good example is the extensive tutorial for the tmdoc::tmdoc package at

Usage: Intermixed Markdown or LaTeX markup and Tcl code in a tmd or .tnw file that can converted to Markdown/LaTeX using the tmdoc command line application. Afterwards the Markdown document can converted to other documentation formats like HTML, PDF or Unix manual pages for instance using the pandoc or pdflatex/xelatex command line tool.

tclsh tmdoc.tcl docu.tmd >
# afterwards Markdown can be converted to HTML or PDF for instance using pandoc
pandoc -i -s --highlight-style pygments -c dgw.css  -o docu.html
# processing a LaTeX command with backticked embedded Tcl code
tclsh tmdoc.tcl docu.tnw --outfile docu.tex
pdflatex docu.tex 

Code chunks:

Are starting after three backticks and a {tcl} indication of the programming language. Here an example:

```{tcl echo=false}
set x 1
puts $x

Further short Tcl code can be embedded directly within the text using single backticks:

The curent date and time is: `tcl clock format [clock seconds] -format "%Y-%m-%d %H:%M"`

Should embed the current date and time in the text.

The manual states as well support for images created from Tcl for instance using commands from gdtcl or the canvas widget. For more information have a look at the tutorial and the manual pages

You can as well embed other programming languages like R if you use the knitr tool:

So this is possible:

    Here some R code:

    print("Hello R World!")

    Now same document Tcl code:

    puts "Hello Tcl World";

If you mix R and Tcl you must first run tmdoc and afterwards knitr . My Makefile for another tutorial looks like this:

        tclkit tmdoc.tcl ../t3-tut.tmd > t3-tut.rmd
        echo "library(knitr);knitr::knit('t3-tut.rmd',output='');" | R --slave
        pandoc -i -s --highlight-style pygments -c ../dgw.css  -o t3-tut.html

You can not start knitr first, as it can't handle Tcl commands.


  • 2020-02-19: 0.1 first release
  • 2020-02-21: 0.2 release
    • puts -nonewline fix in the output
    • outfile and tangle options
    • manual page ready
  • 2020-02-23: 0.3 release
    • fix for puts into channels
  • 2020-11-08: 0.4 release
    • LaTeX support
    • project moved to github

See also:


Please discuss here ...

DDG 2020-02-19: Please note, that this is a work in progress. I am open for suggestions. But tmdoc should basically have a reasonable subset of the functionality of R's Sweave and R markdown

DDG 2020-11-09: With version 0.4 LaTeX support was added. Project now as well on Github.