0

I want some nicely formated tabular thing in TeX. What are my options. Having no documentation unlike in TeX I am lost.

3
  • Maybe you'll find something here or here. Dec 30 '17 at 11:55
  • 1
    “Nicely formatted” depends on the data. Can you please show an example of what you need to show?
    – egreg
    Dec 30 '17 at 11:57
  • If you are using TeX, I hope you at least have the TeXbook by Knuth. Dec 30 '17 at 15:23
7

The question is a bit broad as asked, but I'll do my best to provide a reasonable answer. If you're doing anything sophisticated in TeX, I recommend you read Knuth's The TeXbook. The relevant text here is Chapter 22: Alignment, pages 235-249.


You're probably looking for \halign, which is a “tabular thing.” It stands for “horizontal alignment.” The example below creates a table showing the number of internet users in different countries (from www.internetworldstats.com).

\halign{\strut\hfil#\hfil\quad&\hfil#\hfil\quad&\hfil#\cr
   Rank&Country&Internet Users\cr
   \noalign{\hrule}
   1&China&1388232693\cr
   2&India&1342512706\cr
   3&United States&326474013\cr}

Internet Users in Countries Code Product

The structure of an \halign is similar to that of a tabular environment in LaTeX, which makes sense because the tabular environment is built on \halign. The first line of the \halign is called the preamble and defines templates for each cell. Data is entered by rows. Each cell is separated by &, and each row is ended by \cr. The data from each row is inserted into the template and aligned. The placeholder character in each template is #.

I won't go into too much more detail. Check out The TeXbook or the link that Phelype mentioned in the comments. They're both good resources.

\halign is powerful but fairly bare bones. There are a number of plain TeX packages on CTAN that make things nearly as simple as tabular. Check out stables (which I like) and tap (which I haven't used). I'm pretty picky, so I usually roll my own solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.