Formatting numbers in Lua

9 September, 2019 (5 minute read). Category: Formatting. Tags: luatex, programming.

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

15 April, 2019 (5 minute read). Category: Design. Tags: tables, forms, metapost, fontawesome, coverpage, tutorial.

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

11 April, 2019 (3 minute read). Category: Installation. Tags: setuptex, context standalone, luametatex.

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

24 March, 2019 (2 minute read). Category: Visualization. Tags: backgrounds, framed.

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

21 October, 2018 (4 minute read). Category: Tikz. Tags: tikz, luatex, efficiency.

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 >

Externalizing Metapost graphics

8 October, 2018 (3 minute read). Category: Metapost. Tags: externalizing graphics, metapost, efficiency.

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: 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. Sometimes, it is desirable to have separate graphics, for example to include them in third party programs (think XHTML export).

Read more >

Making visaully attractive posters in ConTeXt

25 August, 2018 (3 minute read). Category: Design. Tags: poster, metapost, backgrounds.

Posters are not or rather were not too common in my research field, so I have never really had a need to create posters. But this is now changing and every now and then, we have to make a poster presentation. I have looked at the different options available for creating posters (see, for example, this TeX.SE post) but I find all of them to be boring. Given that poster sessions are crammed, it is important to create a poster that is visually distinct.

Read more >

Drawing Metapost animations

15 July, 2018 (2 minute read). Category: Metapost. Tags: metapost, animation.

The animation module provides a nice interface for using FieldStacks to create a JavaScript controlled animations in ConTeXt.1 For example, the following code will show step-1.pdf, step-2.pdf, step-3.pdf, and step-4.pdf files one by one:

\usemodule[animation]

\startanimation[menu=yes]
  {\useexternalfigure[step-1.pdf]}
  {\useexternalfigure[step-2.pdf]}
  {\useexternalfigure[step-3.pdf]}
  {\useexternalfigure[step-4.pdf]}
\stopanimation

Sometimes, I use animation to give the illusion of motion. For example, to show a particle moving along a trajectory (drawn using Metapost). In principle, it is possible to use the animation module to draw such animations (e.g., see Wolfgang’s reply in on ntg-context mailing list), but the interface gets a bit cumbersome. In this post, I show a helper macro to simplify drawing such animations.

Read more >
< Previous Page Next Page >