3

I'm working on some presentation slides in ConTeXt and I can't figure out how to achieve top/bottom/middle vertical alignment of multiline content across two columns. Further complicating the issue is that I am using global vertical alignment using a makeup (which seems to throw off columnset).

I have tried 3 things, all of which have some issues (example code below):

  1. paragraphs don't seem to have any alignment support (and using them for multiline content seems to abuse what they are meant for)
  2. placefigure combined with combination allows for different alignment options, but doesn't seem to support multiline content (I also tried adding a vbox, but that throws off the horizontal spacing)
  3. columnset makes document compilation freeze if placed within a makeup (and doesn't seem to support vertical alignment anyway)

Example code using a couple of tikz pictures. I would like the option to align the two columns vertically by top/bottom/middle:

%&context

% Loading tikz
\usemodule[tikz]
\usemodule[pgfplots]

% Define vertical centering
\definemakeup[Center]

\starttext

%------------------------------------------------------------------------
% Paragraph

\defineparagraphs[ParColumns][n=2]
\setupparagraphs[ParColumns][1][width=.5\textwidth]
% no way to define vertical alignment?

\startCentermakeup

  \startParColumns

    \starttikzpicture
      \node[draw, minimum height=1cm] (test1) {Left graphic};
    \stoptikzpicture

    \blank[small]

    Some descriptive text

  \nextParColumns

    \starttikzpicture
      \node[draw, minimum height=3cm] (test2) {Right graphic};
    \stoptikzpicture

  \stopParColumns

\stopCentermakeup

\stoptext

Using placefigure without vbox around left side content removes the linebreak between left graphic and text. Adding vbox around the content introduces a massive horizontal space.

%&context

% Loading tikz
\usemodule[tikz]
\usemodule[pgfplots]

% Define vertical centering
\definemakeup[Center]

\starttext

%------------------------------------------------------------------------
% Combinations

\startCentermakeup

\placefigure[here,none]{}{

  \startcombination[2*1, location=middle]

    {
    \starttikzpicture
      \node[draw, minimum height=1cm] (test1) {Left graphic};
    \stoptikzpicture

    \blank[small]

    Some descriptive text
    }{}

    {
    \starttikzpicture
      \node[draw, minimum height=3cm] (test2) {Right graphic};
    \stoptikzpicture

    }{}

  \stopcombination
}

\stopCentermakeup

\stoptext

This is what happens if I add vbox (with frame for clarity):

With vbox

  • I included tikz code because I'm currently working with some existing tikz graphics (and I don't know if tikz might be adding any issues of its own) – ssokolen Aug 23 '17 at 14:00
3

If you don't want content to flow from one column to another, you can use TABLEs and control the vertical alignment of columns using align key (low|high|lohi). Here is an example:

\setuppapersize[S5]

% Loading tikz
\usemodule[tikz]
\usemodule[pgfplots]

% Define vertical centering
\definemakeup[Center]

\startsetups columns
  \setupTABLE[row][1][width=0.5\textwidth, height=\textheight]
\stopsetups

\starttext

\startCentermakeup
  \startTABLE[setups=columns]
    \NC[align=low] 
        \starttikzpicture
          \node[draw, minimum height=1cm] (test1) {Left graphic};
        \stoptikzpicture

        \blank[small]

        Some descriptive text
    \NC[align=lohi]
        \starttikzpicture
          \node[draw, minimum height=3cm] (test2) {Right graphic};
        \stoptikzpicture

    \NC \NR
  \stopTABLE
\stopCentermakeup
\stoptext

which gives

enter image description here

If you want finer control, then you can use layers.

  • Thanks! I was hoping to avoid the extra markup of tables, but the \startsetups solution is quite nice. I don't think I saw it in the wiki. I also didn't know that you can use the \NC notation with TABLE rather than \bTD \eTD. – ssokolen Aug 23 '17 at 16:53
  • 3
    @ssokolen: See this blog post for my thoughts on formatting tables. – Aditya Aug 23 '17 at 17:14
  • That's really helpful -- I'll definitely be using that approach for future tables. – ssokolen Aug 23 '17 at 17:24

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.