3

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 ?

  • 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 Jan 14 '14 at 15:39
2

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
  • Pictures must be glued edge-to-edge. Their height must be calculated automatically, not manually. – s9gf4ult Jan 14 '14 at 15:02
  • This also scales the captions – Aditya Jan 15 '14 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.) – Torbjørn T. Jan 15 '14 at 9:01
1

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

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.