TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

In ConTeXt, a tabular environment evidently does not behave a centered context. e.g.:

        \NC item one \NC item two \NC\NR
        \NC item three \NC item four \NC\NR

will still result in the table being up against the left side of the page. One answer here advises using \midaligned {} around tables to center them, but this technique seems to throw an error when applied to tabulars. What's the correct way to center a tabular block?

share|improve this question
up vote 4 down vote accepted

The low-level \vbox wrapping aside, there are two way to achieve centered tables relying on the user interface only: Floats and the frame parameter. Floats are more powerful but even with the abundance of placement options they might turn out to behave erratically. So the frame parameter that comes with tabulation-style tables might be the preferred choice in some situations.

%%% This is how you get a “tabular” environment in Context.
\definetabulation [tabular]
\setuptabulation  [tabular] [

%%% Used in solution 2. Note the *align* key.
\defineframedcontent [tabularframe] [frame=off, align=middle]

%%% The table goes into a buffer for later use.
\startbuffer [demotable]
      \NC item one   \NC item two  \NC\NR
      \NC item three \NC item four \NC\NR

\input knuth
%%% First solution: Floats.
%%% Use the “here” key to set the float location. Try “force” if it
%%% doesn’t behave.
\placetable[here]{Centered Table Floats}{\getbuffer[demotable]}

%%% Second solution: Frame.
%%% The second solution is even easier: As tabulations respect a
%%% (undocumented?) *frame* parameter, just hook your favorite
%%% *framedcontent* macro in there.
\setuptabulation [tabular] [frame=tabularframe]
\startalignment [middle]
  \input ward
  \input dawkins


centered tabulation

EDIT As Marco pointed out, the framed version will suppress page breaks. In case your tabulations get too long, you will have to resort to the first version (float, with the split option). Or you can just create a narrower environment that centers the table according to its width. In below listing this is done inside the macro \centertabulation which takes the table as an argument.



\definenarrower [tabulate_narrower]
\setupnarrower  [tabulate_narrower] [



\startalignment [middle]
  \input ward
  \input ward


Beware that this approach will misalign all horizontal rules in the table.

share|improve this answer
The frame prevents the tabular from being broken across pages. – Marco May 5 '12 at 14:47
I’d prefer floats with long tables. But I added an alternative that avoids floats anyways. – phg May 5 '12 at 16:58
It is better to use here,force to ensure that the floats don't float. – Aditya May 6 '12 at 1:06

Not sure if this is the canonical way to force centering, but the following should work

  \NC item one \NC item two \NC\NR
  \NC item three \NC item four \NC\NR

The \dontleavehmode command is often used with \startalignment, see e.g. Context help on Command/startalignment. The \vbox trick is something I found on Context mailing.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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