博学
审问
慎思
明辨
笃行

Suos
Cultores
Scientia
Coronat

Education
Research
Service*

Gaming with LaTeX: PDF-based Tic-tac-toe

Why aren’t there games written in LaTeX? In this post, I am exploring ways to include an (rather weak) AI in a PDF-based tic-tac-toe game, with the help of LaTeX. The results can be found in the folloing repo:

https://github.com/xziyue/tictactoe-pdf

LaTeX3: Programming in LaTeX with Ease

Many people view LaTeX as a typesetting language and overlook the importance of programming in document generation process. As a matter of fact, many large and structural documents can benefit from a programming backend, which enhances layout standardization, symbol coherence, editing speed and many other aspects. Despite the fact the standard LaTeX (LaTeX2e) is already Turing complete, which means it is capable of solving any programming task, the design of many programming interfaces is highly inconsistent due to compatibility considerations. This makes programming with LaTeX2e very challenging and tedious, even for seasoned computer programmers.

To make programming in LaTeX easier, the LaTeX3 interface is introduced, which aims to provide modern-programming-language-like syntax and library for LaTeX programmers. Unfortunately, there is little material regarding this wonderful language. When I started learning it, I had to go through its complex technical manual, which is time-consuming. Therefore, I decide to write a LaTeX3 tutorial that is easy-to-understand for generic programmers.

The Accuracy of l3fp: a Series of Test Cases

I was reading LaTeX3’s documentation for \dim_to_fp:n, where I encountered the following description:

Expands to an internal floating point number equal to the value of the <dimexpr> in pt. Since dimension expressions are evaluated much faster than their floating point equivalent, \dim_to_fp:n can be used to speed up parts of a computation where a low precision and a smaller range are acceptable.

At first, I was confused by the subject of this paragraph and thought the precision of l3fp is not ideal. Because many data processing packages (e.g. datatool) rely on l3fp to do floating point arithmetic, I had this idea of testing l3fp’s accuracy against IEEE 754 double precision floating point arithmetic. The result shows that the error of l3fp is very small compared to IEEE 754 and is negligible in everyday applications. However, the trigonometry functions of l3fp seems to be significantly less precise compared to other operations.

LuaTeX: Mimicking File System Input

In LaTeX, verbatim environments are extremely tricky. Different verbatim environments are based on distinct LaTeX magic, which makes their behavior inconsistent. The only realiable way to use a verbatim environment is to write them in the TeX source as-is, for any attempt to construct such environments programmatically usually fails. In existing packages, such problems are avoided by saving the constructed environments into files first and then use \input command to read them as TeX source files. I really dislike this solution as it induces significant I/O overhead (despite the fact that other I/O bottleneck may be more dominant). In this post, I provide a LuaTeX-based method that allows \input from Lua strings.

(This post corresponds to my question on TeX.SE.)

Introduction to LuaTeX

LuaTeX is a TeX engine which integrates Lua as its scripting language. The combination of an editing language and programming language allows us to generate beautiful structural documents.

LuaTeX is usually included in TeXLive and MikTeX distributions.

LaTeX Binary Search Tree

Recently, I have been exploring the essence of LaTeX. The discovery of LaTeX3 really uncovers the potential of LaTeX as a “generic” programming language. Although with LuaTeX, writing complicated data structure and algorithms in pure TeX seems to be a waste of time, I still find my effort somehow meaningful in a way: at this point, I haven’t really studied programming languages and compilers formally, but playing with TeX really allows me to feel the fine line between text and program. We are able to do amazing things with TeX (which is Turing complete), but accompanied by fact that the foundation of TeX is based on text substitution and some support for numerical evaluation, I am stunned by its simplicity and universality. Text is program, program is text, it is the perfect concord.

LaTeX3 Quick Reference Guide

As I am getting more and more familiar with LaTeX, my personal need of writing complicated LaTeX packages continue to increase. However, I am totally blown away by the complexity of expansion control in tradition LaTeX. Fortunately, the LaTeX3 project provides a way to write large scale LaTeX programs with much simpler expansion control and more systemic naming conventions. This post serves as a quick guide to introduce one to LaTeX3.

LaTeX is turing complete! If you know how to control expansions, you can pretty much do everything with LaTeX (tough the efficiency is awful).

CIS-375 Help Session Note 5 (Spring 2020)

Scire ad trascendere - Learn to transcend.

Topics covered:

  • Mathematical induction
  • Strong induction

Connecting a Linux Computer to SU Network

Since I am working with Linux, which is considered to be “insecure” by Syracuse University’s ITS, there is no official approach to connect to SU’s network with VPN. Fortunately, if you have an OSX or Windows machine around, which are capable of using SU’s VPN, we can set up a NAT rule to allow Linux computers in the same LAN to access SU hosts.

CIS-375 Help Session Note 4 (Spring 2020)

Scire ad trascendere - Learn to transcend.

Topics covered:

  • Functions

Please always pay attention to Blackboard announcements and your mailbox. Prof. Lee and I are trying different approaches to make sure this course can go on as usual. You do not want to miss major changes in course format or policies.


View more posts→