t-vim: A tale of two editors

Since I am looking at merging a few pull requests for t-vim, I thought that this will also be a good time to implement a simple feature that was on hold for a while: the ability to use the module with Neovim instead of vim.

Read more →

New escape mechanism for t-vim

The t-vim module has been on a maintenance only mode for while, so I am happy to announce a release which adds a new feature: a new method to escape to TeX using /BTEX and /ETEX tags.

Read more →

Formatting numbers in Lua

I often use Lua to generate solution for homework assignments. Ideally, I want the solution to look exactly how it would look if it were written by hand. But this can be tricker than it appears at first glance. In this post, I’ll explain the issue and how I solve it.

Read more →

Designing cover page for an exam

Our university has a specific style that courses need to use as a cover page for exams, shown below. They circulate a Word template at the beginning of each term. Since I typeset my exams in ConTeXt, I decided to translate this cover page template to ConTeXt as well. In this post, I’ll explain how I went about doing this translation.

Read more →

Seamlessly switching between different context versions

Recently, Hans announced the prerelease of a new version of ConTeXt called LuaMetapostTeX or LMTX for short. LMTX is supposed to a streamlined and stripped down version of LuaTeX where most of the backend code for writing PDF and images has been removed from the engine and is handled by macro package using Lua code. Some of the rationale for the change in discussed in this post and more details including the source code and documentation will be available when LMTX will be formally released in this year’s ConTeXt meeting. Currently just the binary is available for testing from Pragma Ade’s website. There is no change in user-facing code, so in principle, one can simply switch from ConTeXt MkIV to LMTX without making any change in the tex file.

In my tests so far, I could compile all my documents using LMTX without any noticeable difference. Nonetheless, I want to keep ConTeXt MkIV around for some critical projects like typesetting material for courses that I teach. In this post, I’ll explain my setup for using ConTeXt MkIV and LMTX in parallel.

Read more →

Frame With Solid Left Line Redux

As I had posted earlier, I like the visual effect of placing a solid line on the left side of a block:

Simple example

I use this for displaying short code snippets in the lecture notes of a course that I teach. Typically these are a few lines of Matlab code but recently I needed to post a bigger code snippet where the frame should break across the page. In principle, this should have been a simple change—replace the framed with a textbackground—but that did not work out of the box. This blog post explains a simple solution.

Read more →

Speeding up PGFPlots using LuaTeX

In the previous post, I compared the speed of Metapost and TikZ for drawing similar graphics and found that TikZ is three to five times slower than Metapost. Although TikZ is slower, it does provide a much higher level interface to drawing graphics and shifting to Metapost can take a lot of user time, which is often more valuable than computer time.

As an example, consider the PGFPlots package, which provides a high-level interface for drawing function plots. Although there is a Metapost package for drawing graphs, PGFPlots has more features and better documentation. In this post, I show that we can speed up plotting functions using PGFPlots by offloading the function computation to LuaTeX.

Read more →

Comparing the speed of Metapost and TikZ

As a frequent user of both Metapost and TikZ, I often observe that TikZ is considerably slower than Metapost. But what’s the actual difference in speed? Let’s consider basic operations: drawing straight lines and drawing circles.

Read more →

Externalizing Metapost graphics

TikZ has a library external that converts a TikZ picture to a separate PDF. The TikZ documentation provides three reasons of why external images are useful:

  1. Compiling large images takes a lot of time. However, most images do not change from run to run. So, it can save time to export finished images and include them as external figures.
  2. Sometimes, it is desirable to have separate graphics, for example to include them in third party programs (think XHTML export).
  3. It may be necessary to typeset a file in an environment where PGF or TikZ are not available.

The third and to a large extent the first point are moot for Metapost+ConTeXt. Metapost is integrated with LuaTeX, so there is no issue of Metapost not being available. Moreover, Metapost is extremely fast so compiling Metapost figures has very little overhead.

Read more →