4

I need to place several figures with different aspect ratios in a row using ConTeXt. I also need their heights to be equal, but summary width of pictures to be \textwidth. Height of pictures must calculated authomatically, pictures must be glued exactly side-to-side.

like

-----------------------------
|pic1|   wide pic2   | pic3 |
----------------------------- 
|        \textwidth         |
|<------------------------->| 

How ?

1
  • There was a post with \startcombination solution, but it was deleted. This works just like I need if \setupcombination[distance=0mm] (no width=\textwidth) and \startcombination wrapped in \scale[width=\textwidth]{}.
    – s9gf4ult
    Commented Jan 14, 2014 at 15:39

2 Answers 2

3

You can use combination and (from comments) \scale. Note that if you add captions to each image, as in the below code, this text will be scaled as well.

enter image description here

\setupcombination[distance=0mm]
\starttext
\input knuth

\scale[width=\textwidth]{\startcombination[3*1]
{\externalfigure[example-image.pdf][height=3cm]}{text}
{\externalfigure[example-image-10x16.pdf][height=3cm]}{under}
{\externalfigure[example-image-16x10.pdf][height=3cm]}{image}
\stopcombination}

\input knuth

\stoptext
3
  • Pictures must be glued edge-to-edge. Their height must be calculated automatically, not manually.
    – s9gf4ult
    Commented Jan 14, 2014 at 15:02
  • This also scales the captions
    – Aditya
    Commented Jan 15, 2014 at 3:42
  • @Aditya Thanks for the note. (I actually meant to remove them, as the question doesn't mention captions, but I'll add a note about that in the answer.) Commented Jan 15, 2014 at 9:01
2

The solution can be achieved in two steps:

  1. Create a box in which the height of all the images is the same (does not matter what this height is)
  2. Scale the box so that its width equals textwidth.

Here is an example:

% Example images
\useexternalfigure[kitten1][http://placekitten.com/g/200/300][method=jpg]
\useexternalfigure[kitten2][http://placekitten.com/g/200/400][method=jpg]
\useexternalfigure[kitten3][http://placekitten.com/g/200/500][method=jpg]


\starttext

\subject{Images without any scaling}

\dontleavehmode
\externalfigure[kitten1]\externalfigure[kitten2]\externalfigure[kitten3]

\subject{Images scaled to textwidth}

\scale[width=\textwidth]
  {\externalfigure[kitten1][height=1cm]%
   \externalfigure[kitten2][height=1cm]%
   \externalfigure[kitten3][height=1cm]}

\stoptext

which gives

enter image description here

You must log in to answer this question.

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