4

I'm trying to display a set of images this way :

————————————————————
|  img1   |        |
|—————————|  img4  |
|img2|img3|        |
————————————————————

However I only get

———————————
|  img1   |
|—————————|
|img2|img3|
|—————————|
|  img4   |
———————————

Here is my code :

\placefigure[none]{}
\startcombination[2*1]
{
  \startcombination[1*2]
  {\externalfigure[img1]}{}
  {
    \startcombination[2*1]
    {\externalfigure[img2]}{}
    {\externalfigure[img3]}{}
    \stopcombination
  }{}
  \stopcombination
}{}
{\externalfigure[img4]}{}
\stopcombination

Did I miss anything ?

2 Answers 2

5

It is okay to use tables for such alignments. But, you should also get the right output with combinations. What version of context are you using. With 2015.09.13 MkIV, I get the following output:

enter image description here

One gets the impression that the layout is messed up, but that is not the case. If you add

\showboxes

the output is

enter image description here

which shows that the layout is correct, just that the the images are bottom aligned (the default option) rather than middle aligned). You can change that using the location=middle key, or use images of the right dimension.

Here is an example:

\useMPlibrary[dum]

\definecombination[grid][inbetween=,distance=0pt,before=,after=]

\starttext
\placefigure[none]{}
\startcombination[grid][2*1]
{
  \startcombination[grid][1*2]
  {\externalfigure[img1][width=8cm,height=3cm]}{}
  {\startcombination[grid][2*1]
    {\externalfigure[img2][width=4cm,height=3cm]}{}
    {\externalfigure[img3][width=4cm,height=3cm]}{}
    \stopcombination}{}
  \stopcombination}{}
{\externalfigure[img4][width=3cm,height=6cm]}{}
\stopcombination
\stoptext

which gives

enter image description here

And, of course, this is the perfect example to showcase the \placekitten macro:

\def\externalkitten[#1]%
  {\getparameters[kitten][width=10pt, height=10pt, #1]%
   \externalfigure
      [\ctxlua{context("http://placekitten.com/\letterpercent0.0f/\letterpercent0.0f",
                \withoutpt{\the\dimexpr\kittenwidth},
                \withoutpt{\the\dimexpr\kittenheight})}]
      [#1, method=jpg]}

\definecombination[grid][inbetween=,distance=0pt,before=,after=]

\starttext
\placefigure[none]{}
\startcombination[grid][2*1]
{
  \startcombination[grid][1*2]
  {\externalkitten[width=240pt,height=90pt]}{}
  {\startcombination[grid][2*1]
    {\externalkitten[width=110pt,height=90pt]}{}
    {\externalkitten[width=130pt,height=90pt]}{}
    \stopcombination}{}
  \stopcombination}{}
{\externalkitten[width=90pt,height=180pt]}{}
\stopcombination
\stoptext

which gives

enter image description here

2
  • Indeed my version seems quite old (context --version gives ConTeXt Process Management 0.60, current version: 2013.05.28 00:36) and the output is messed up with your example as well. Oct 20, 2015 at 18:57
  • It is usually a good idea to use an recent (2-3 month old) ConTeXt. Look at ConTeXt standalone on the wiki. It can be installed in parallel with Texlive and is easy to update.
    – Aditya
    Oct 20, 2015 at 19:00
3

Not sure it is the proper way to do that, but I achieved my goal using the following :

\startTABLE[frame=off]
  \NC[nx=2] \externalfigure[img1]
  \NC[ny=2] \externalfigure[img4]
  \NC\NR
  \NC \externalfigure[img2][width=2cm]
  \NC \externalfigure[img3][width=2cm]
  \NC\NR
\stopTABLE

[nx=2] and [ny=2] allow to merge cells (colspan and rowspan, respectively).

For the records, previous version, using the "old table syntax" :

\bTABLE[frame=off]
  \bTR
      \bTD[nx=2] \externalfigure[img1] \eTD
      \bTD[ny=2] \externalfigure[img4] \eTD
  \eTR
  \bTR
      \bTD \externalfigure[img2][width=2cm] \eTD
      \bTD \externalfigure[img3][width=2cm] \eTD
  \eTR
\eTABLE

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .