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: Visualization. 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 >

Interfacing LuaTeX with Julia

27 December, 2017 (4 minute read). Category: FFI. Tags: julia.

One cool feature of LuaTeX is ability to interface with external libraries using Lua’s Foreign Function Interface (FFI). An extreme example of this is Luigi Scarso’s LuaTeX lunatic, which provides a two way bridge between Python and LuaTeX. Not being a Python fan, I never looked into the implementation details, in spite of Luigi’s impressive examples.

Recently, Henri Menke posted an interesting example that shows how to use a function from GNU Scientific Library (GSL) to inteface with pgfplots. This got me interested in looking into Lua’s FFI in detail. After a bit of trial and error, I finally figured out how to interface LuaTeX with my current favorite programming language: Julia.

Read more >

Using Font Awesome

26 November, 2017 (2 minute read). Category: Fonts, Macros. Tags: font awesome, symbols.

Font Awesome is a font that provides pictographic icons and is commonly used to display icons for email, editing tasks, popular social media website, etc. It is easy to use Font Awesome in ConTeXt: the font ships with ConTeXt Standalone and ConTeXt includes a symbolset to easily access the icons using names rather than icon numbers.

To use FontAwesome icons in ConTeXt, simply load the symbolset fontawesome using

\usesymbols[fontawesome]

and then any icon is accessible using

\symbol[fontawesome][...]

where ... is the name of the icon is listed in the Font Awesome icon list.

Read more >

Comibined characters in Math

15 October, 2017 (3 minute read). Category: Mathematics. Tags: asciimath.

There is a new feature in ConTeXt that replaces some ascii math (I am using this term informally. The symbols do not match the asciimath symbol list). It is enabled by default and replaces a combination of characters by a glyph. For example,

A function $f$ is an increasing function
  \startformula
    x <= y  ===> f(x) <= f(y)
  \stopformula

gives

Example of combined characters

Read more >

Typesetting differential equations

18 September, 2017 (4 minute read). Category: Macros. Tags: luatex, programming, separating content and presentation.

This semester I am teaching a course involving linear differential equations, so I have typeset many differential equations that look like this:

Simple example

Believe me, writing such equations by hand gets tedious very quickly. So, I wanted a macro \LDE (for Linear Differential Equation), so that I could just type

\LDE{1, -3, 2}{2, 1}

and get the above result. This post describes how to write such a macro using LuaTeX + ConTeXt.

Read more >

Frame with solid left line

18 August, 2017 (1 minute read). Category: Visualization. Tags: backgrounds, framed.

Adding a solid line of the left side of a frame, block quote, etc. creates a simple, clean, and attractive visual effect that I like.

Simple example

I don’t know when I first came across this style, but it is used commonly on the Internet to show blockquotes. So, how do we get this style with ConTeXT?

Read more >
Next Page >