# Would a table by any other name be as useful

Karl Berry recently blogged about creating the following in TeX:

A 6×6 grid of pictures, with a big picture of size 2×2 in the middle. All pictures should be surrounded by a border.

Karl said that he tried pdfpages package but, in the end, used low-level \halign. Ouch! Use \halign. I don’t know how many people who start with LaTeX or ConTeXt actually know the syntax of \halign. But what I find shocking is that Karl’s next best choice was pdfpages, a package to combine pdf pages. Is the state of affairs with LaTeX tables so bad?

I tried to achieve that same layout in ConTeXt, and it was really simple.

    % Placeholders for figures
\useexternalfigure[photo] [cow]   [width=2cm, height=1.5cm]
\useexternalfigure[center][cow]   [width=4cm, height=3cm]

\setupTABLE[each][each][framecolor=lightred, rulethickness=3bp, frame=on, strut=off]

\starttext

\startTEXpage
\bTABLE
\bTR
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\eTR
\bTR
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\eTR
\bTR
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD[nr=2,nc=2] \externalfigure[center]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\eTR
\bTR
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\eTR
\bTR
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\eTR
\bTR
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\bTD \externalfigure[photo]\eTD
\eTR
\eTABLE
\stopTEXpage

\stoptext


Notice the [nr=2,nr=2] for the middle cell. This tells ConTeXt that the middle cell spans 2 rows and 2 columns. And thats it!

For another, more extreme, example see Willi Egger’s My Way on drawing type cases (wooden cases with boxes for storing letter types) used in hand typesetting.

Edit: In a follow-up post, Will Robertson said that he does not like the verbose syntax of ConTeXt tables. Neither do I. As a matter of fact, ConTeXt has multiple table implementations. The oldest table macros, \starttable ... \stoptable were just a wrapper around the TaBlE macros by Michael Wichura. The syntax of this macro is:

\starttable
\NC .... \NC .... \NC .... \NC \NR
\NC .... \NC .... \NC .... \NC \NR
\NC .... \NC .... \NC .... \NC \NR
\stoptable


But this mechanism is not as powerful as natural tables (that is what the mechanism that I posted is called). There is, however, a wrapper around natural tables that uses the syntax of the old table macros but provides most of the functionality of natural tables:

\startTABLE
\NC .... \NC .... \NC .... \NC \NR
\NC .... \NC .... \NC .... \NC \NR
\NC .... \NC .... \NC .... \NC \NR
\stopTABLE


This is meant for simple tables. Therefore, the \NC macro does not accept optional arguments. As a result, we cannot use this simpler interface to get the above result. Unless, of course, we cheat. Note the definition of \TC (tablular cell) below and the deliberate use of \1 and \9 to make the code appear less verbose

\setupTABLE[each][each][frame=on, rulethickness=3bp, rulecolor=lightred]
\def\TC{\eTD \dobTD}

\def\1{\externalfigure[cow][width=2cm, height=1.5cm]}
\def\9{\externalfigure[cow][width=4cm, height=3cm]}

\starttext

\startTABLE
\NC \1 \NC \1 \NC \1 \NC \1     \NC \1 \NC \1 \NC \NR
\NC \1 \NC \1 \NC \1 \NC \1     \NC \1 \NC \1 \NC \NR
\NC \1 \NC \1 \TC[nc=2,nr=2] \9 \NC \1 \NC \1 \NC \NR
\NC \1 \NC \1                   \NC \1 \NC \1 \NC \NR
\NC \1 \NC \1 \NC \1 \NC \1     \NC \1 \NC \1 \NC \NR
\NC \1 \NC \1 \NC \1 \NC \1     \NC \1 \NC \1 \NC \NR
\stopTABLE

\stoptext


# Searching for packages in TeXLive

I recently bought a new ACER netbook which comes preinstalled with Windows 7.  It has been almost four years since I used a windows laptop, so I thought that I will give windows a shot before trying out a linux distro on this guy.

The first difficult question was which TeX distribution to use: MikTeX or TeXlive. In the past I had used MikTeX and was extremely happy with it. However, this time around I decided to check out TeXlive (TL), partly buoyed by my good experience with TL in linux.

Installation, setup, etc was a breeze. I think that I selected the basic setup during installation, and when I tried to compile one of my latex files a few packages were missing–mathtools, calcrsfs, dsfonts. In linux, I usually also install the texlive-math-extras bundle and do not need to worry about math packages. However, in windows, I could not find any such package. So, I tried to install these packages by hand.

TeXlive comes with a nice package manager called tlmgr (Of course, as we are talking about TeX software texlive-manager it had to be abbreviated to tlmgr). This allows one to search the CTAN database for packages. For example, I tried


C:\texlive\2009\bin\win32>tlmgr.bat search --global mathtools
tlmgr: package repository http://mirror.its.uidaho.edu/pub/tex-archive/systems/texlive/tlnet
mh - The MH bundle

which told me that I had to install the mh package to get mathtools.sty. Installing the package is also easy. To install the mh bundle, I just had to say


C:\texlive\2009\bin\win32>tlmgr.bat install mh
tlmgr: package repository http://mirror.its.uidaho.edu/pub/tex-archive/systems/texlive/tlnet
[1/1, ??:??/??:??] install: mh [2129k]
tlmgr: package log updated at C:/texlive/2009/texmf-var/web2c/tlmgr.log
running mktexlsr ...
done running mktexlsr.


Easy. Well almost. Things were not so simple when I tried to install dsfont


C:\texlive\2009\bin\win32>tlmgr.bat search --global dsfont
tlmgr: package repository http://mirror.its.uidaho.edu/pub/tex-archive/systems/texlive/tlnet


I guess the empty output means nothing was found. I was confused. I knew that dsfont in part of TL because I use it in linux. So where was it lurking.

Searching CTAN gave me a hint. dsfont is part of the doublestroke package. Ah! Installing packages went smoothly from then on.

So, the next time you cannot find a package in TL, try searching CTAN.