Programming

I create free and open-source software with scientific and technical applications. One of my objectives is making it easier to write scientific and technical documents. I like to include executable code in my documents, so that things like plots and tables can be generated automatically. Documents can write themselves – at least in part. You may be familiar with this approach from software like Jupyter notebooks, Sweave, knitr, or Org-mode Babel. My own contribution is PythonTeX, which focuses on superior integration of Python (and other languages) in LaTeX documents. I am currently working on similar software that will initially focus on Pandoc Markdown.

I use Python and LaTeX daily. LaTeX is not just for writing – I have extensive experience with macro programming in LaTeX and plain TeX. Before I started using Python in 2010, I primarily worked with MATLAB, C++, and Perl. At times, I have also used Bash, Fortran, HTML + CSS, JavaScript, Julia, Mathematica, Octave, Ruby, and Rust.

  • PythonTeX allows Python code in LaTeX documents to be executed. The results are included in the original document. Unlike some similar software, PythonTeX is not a preprocessor. Code is passed to Python only after being processed by LaTeX. As a result, it is possible to write LaTeX macros that internally run Python code. PythonTeX also provides support for Ruby, Julia, Octave, Sage, Bash, and Rust. This was my first real programming project both in Python and in LaTeX, starting in 2011.

  • BespON is my experiment in creating a configuration language similar to YAML or TOML. It is designed for lossless round-tripping: a configuration file can be loaded, programatically modified, and then saved while retaining all original layout and comments. BespON provides concise syntax for deeply nested data structures and supports inheritance, aliases, and circular references. The pure Python performance is surprisingly good – I haven't yet tried any serious optimizations. I plan to use BespON in several upcoming projects.

  • unicodetools is a library I wrote for working with the Unicode Character Database. In creating BespON, I needed regular expressions based on code point properties, and wanted to use the latest version of Unicode even under older versions of Python.

Typography

listings and minted are the two major LaTeX packages for typesetting computer code with syntax highlighting. I have been maintaining and developing minted since 2013. PythonTeX and minted both use Pygments for syntax highlighting, so there is some overlap. I have made many improvements to minted (and PythonTeX) code typesetting. Several of these are implemented in my fvextra LaTeX package.

  • fvextra builds on the existing fancyvrb package that is commonly used for working with verbatim text. minted and PythonTeX can typeset code comments as LaTeX rather than as raw text. This is particularly useful when comments contain LaTeX math. fvextra fixes a number of existing issues with math embedded in a verbatim context, so that math within code can be typeset exactly like math anywhere else in a LaTeX document. Other fvextra features include improved line numbering options and the ability to highlight individual lines of code or line ranges.

  • The most important feature of fvextra is probably automatic line breaking for long lines of code, with automatic indentation to the correct level. Previously, such line breaking was only available in the listings package. fvextra provides fine-grained control over break locations: breaks can be enabled anywhere, at spaces, or only before or after specified characters. If breaks are allowed before or after a specified character, it is possible to group runs of identical characters. Breaks can also be disabled within a programming language's tokens, so that for example there are not breaks in the middle of strings. I implemented line breaking in pure LaTeX and TeX; no Python is involved.

Physics

I teach undergraduate physics at all levels. I frequently use PythonTeX to generate randomized assignments for my students (typically with automatically generated solutions for me). RandAssign is a Python package I created to automate this process. I also incorporate Python programming in my upper-division classes, especially Mechanics and Mathematical Methods for Physics. Programming exercises are common during class and as part of homework, typically using Jupyter notebooks.