Bart Kastermans Computing Page

About: This page contains some LaTeX snippets (more to come).

xdvirc | LaTeX makefile | LaTeX snippets | Emacs | Lecture List Script

Hardware.

Math Circle.

MIX.

While reading The art of computer programming, Vol. 1 I decided to get some experience with writing code for the mythical MIX machine. The following are the results of this.

Before I could put this code up on the page here I write a so called brush for Syntax Highlighter for MIX. This is available here.

.xdvirc

The following two lines ensure (for me) that xdvi starts up with the right scaling of the page, and it updates automatically when the dvi file changes (b/c I run LaTeX again).
xdvi.shrinkFactor:  6
xdvi.watchFile: 1

Current Makefile

# Makefile for LaTeX files
#
# \author Bart Kastermans, www.bartk.nl
#

TEXFILE = ahmadTriple.tex
# number of seconds to wait between successive updates with watch
PATIENCE = 1
HOSTNAME = $(shell hostname)
SHELL = /bin/sh
LATEX_OPTIONS ?= "--src-specials"

# Use a different goal depending on which computer I am on
OFFICE = kasterma-pc
ifeq ($(HOSTNAME), $(OFFICE))
	GOAL = $(subst tex,dvi, $(TEXFILE))
else
	GOAL = $(subst tex,pdf, $(TEXFILE))
endif

# phony rules, targets are not names of created files
.PHONY: clean default view watch

default: $(GOAL)

%.dvi: %.tex
	latex $(LATEX_OPTIONS) $<
	bibtex $(subst tex,aux, $<)
	latex $(LATEX_OPTIONS) $<
	latex $(LATEX_OPTIONS) $<

%.pdf: %.tex
	pdflatex $(LATEX_OPTIONS) $<
	bibtex $(subst tex,aux, $<)
	pdflatex $(LATEX_OPTIONS) $<
	pdflatex $(LATEX_OPTIONS) $<

view: $(GOAL)
ifeq ($(HOSTNAME), $(OFFICE))
	xdvi -watchfile 1 $(subst tex,dvi, $(TEXFILE)) &
else
	open $(subst tex,pdf, $(TEXFILE)) &
endif

watch:
	while true; do \
		make LATEX_OPTIONS="--src-specials -interaction=nonstopmode"; \
		sleep $(PATIENCE); \
		clear; \
	done

clean:
# before deleting files, check that the original tex file is around
# if <filename>.tex is around, but you are attached to <filename>.aux
# or similar you are getting what you deserve.
	@if test -e $(TEXFILE); then \
		echo removing files derived from $(TEXFILE); \
		rm -f $(subst .tex,.dvi, $(TEXFILE)); \
		rm -f $(subst .tex,.aux, $(TEXFILE)); \
		rm -f $(subst .tex,.log, $(TEXFILE)); \
		rm -f $(subst .tex,.pdf, $(TEXFILE)); \
		rm -f $(subst .tex,.tex~,$(TEXFILE)); \
		rm -f $(subst .tex,.out, $(TEXFILE)); \
	else \
		echo the file $(TEXFILE) does not exist; \
	fi

Snippets.

\usepackage {amsmath, amssymb, amsthm}
% DeclareMathOperator without the repetition
\newcommand {\DMO} [1]
            {\expandafter\DeclareMathOperator\csname #1\endcsname
              {#1}}
% unified quick way to defining new axioms
\newcommand {\newaxiom} [1]
            {\expandafter\newcommand\csname #1\endcsname
              {\ensuremath {\mathsf {#1}}}}
\theoremstyle{definition}
\newtheorem{definition}[theorem]{Definition}
\newenvironment{definitions}
  {  \begin{definition}
        \renewcommand{\theenumi}
        {(\roman{enumi})}
        \begin{enumerate}}
  {\end{enumerate}
   \end{definition}}
\newcommand{\separate}{%
\begin{center}
  \begin{picture}(100,5)
    \thicklines
    \put(0,0){\line(1,0){100}}
    \put(0,5){\line(1,0){100}}
  \end{picture}
\end{center}
}
\DeclareRobustCommand{\edit}[1]{%
   \ifmmode
      \mathbf{\blacktriangleright #1 \blacktriangleleft }%
   \else
      \textbf{$\blacktriangleright$ #1 $\blacktriangleleft$ }%
   \fi
}
\bibliographystyle{plain}
\bibliography{FILENAME}

Emacs

Site dependent configuration in .emacs

If you use different computers (in my case one running Debian in my office and a macbook otherwise) you might want different configurations for your emacs. The following gives an example of how to achieve this.
(setq hostname (shell-command-to-string "hostname"))

(setq TeX-PDF-mode t)

(cond
 ((string-match "vv519" hostname)
  (setq TeX-PDF-mode nil)
  (setq TeX-Omega-mode t)))

A Lecture List Script

On my teaching page (www.bartk.nl/teach.php) I like to provide a list of topics covered during different lectures and a list of current assignments. To not have to edit html every time I give a lecture or assign homework I have written a little script.

For when my page changes from the current version, here is a screenshot of what it looks like right now picture of teaching page.

Screenshot Teaching Page
Screenshot Teaching Page

in this page I have the following php code

<?php include ("lectlistfile.html") ?>

the script writes and uploades the file lectlistfile.html quickly. It can be found on my bitbucket page and in the blog post I wrote about it.