# How to vertically align and scale images within a tabularx environment

How does one scale the images and also vertically centre align the images.

Relevant Research:

I have looked at the following links to better understand and try out their recommendations:

MWE:

\documentclass{report}
\usepackage{pifont}
\usepackage{float}
\usepackage[x11names]{xcolor}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{tabularx}
\renewcommand{\tabularxcolumn}[1]{>{\small\centering\arraybackslash}p{#1}}
\makeatother
\newcommand*\bigrightArrow[1][0pt]{\color{black!40}\raisebox{#1}{\scalebox{2.4}[3.6]{\ding{225}}}}
\makeatletter
\begin{document}

Some text \textbf{above} the image.
\begin{figure}[H]
\centering
\begin{tabularx}{\textwidth}{@{}XcXcX@{}}
\subcaptionbox{text 1}{\includegraphics[width=\linewidth]{example-image-a}}
&
\bigrightArrow[20pt]
&
\subcaptionbox{text 2}{\includegraphics[width=\linewidth]{example-image-b}}
&
\bigrightArrow[20pt]
&
\subcaptionbox{text 3}{\includegraphics[width=\linewidth]{example-image-c}}
\\
\end{tabularx}
\end{figure}
Some text \textbf{underneath} the image.
\end{document}


Current Output:

Ideal Output:

Question:

How does one:

• vertically align an image within the above MWE
• scale an image within the above MWE
• Are you sure you want to use tabularx with 3 X type columns? They will then be of equal width but your desired screen shot seems to indicate the last one should be smaller.
– user194703
Sep 12 '19 at 2:37
• Finally found a solution {\includegraphics[width=\linewidth]} becomes {\includegraphics[width=0.8\linewidth] which further scales down.... couldn't do the vertical alignment - but it's good enough for the time being. Sep 12 '19 at 2:42
• There are dedicated packages like floatrow or makecell for that.
– user194703
Sep 12 '19 at 2:50

See if the following solution is acceptable to you:

\documentclass{report}
\usepackage{tabularx}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{arrows.meta}
\newcommand\bigrightArrow{
\tikz[baseline=-3pt]
{
\draw[line width=12pt,-{Triangle[length=16pt, width=24pt]}, gray]
(0,0) -- ++ (32pt,0);
}
}

\begin{document}
Some text \textbf{above} the image.
\begin{figure}[htb]
\centering
% with width of X column is defined image size
\begin{tabularx}{\linewidth}{@{} >{\hsize=1.2\hsize}X c
>{\hsize=1.2\hsize}X c
>{\hsize=0.6\hsize}X
@{}}
\includegraphics[width=\hsize, valign=c]{example-image-a}
& \bigrightArrow
& \includegraphics[width=\hsize, valign=c]{example-image-b}
& \bigrightArrow
& \includegraphics[width=\hsize, valign=c]{example-image-c}          \\
\subcaptionbox{text 1}{\rule{\hsize}{0pt}}
&&  \subcaptionbox{text 2}{\rule{\hsize}{0pt}}
&&  \subcaptionbox{text 3}{\rule{\hsize}{0pt}}
\end{tabularx}
\end{figure}
Some text \textbf{underneath} the image.
\end{document}


There's no need for tabularx here.

The following uses \hfills to spread the content across the page in the same way tabularx does. In order to vertically align different sized images, you can capture the differing elements inside boxes (\bigbox and \smallbox below) from which you can extract their respective heights. This allows you to raise them into position so they are vertically centred.

\documentclass{article}
\usepackage{graphicx,pifont,xcolor}
\usepackage{subcaption}

\newcommand*\bigrightArrow[1][0pt]
{\color{black!40}\raisebox{#1}{\scalebox{2.4}[3.6]{\ding{225}}}}

\newsavebox{\smallbox}% A box to store a small(er) image
\newsavebox{\bigbox}% A box to store a large(r) image

\begin{document}

Some text \textbf{above} the image.
\begin{figure}[!h]

\mbox{}\hfill
\subcaptionbox{text 1}{\includegraphics[width=.2\linewidth]{example-image-a}}\hfill
\bigrightArrow[13pt]\hfill
\subcaptionbox{text 2}{\includegraphics[width=.2\linewidth]{example-image-b}}\hfill
\bigrightArrow[13pt]\hfill
\subcaptionbox{text 3}{\includegraphics[width=.2\linewidth]{example-image-c}}\hfill
\mbox{}%

\bigskip

\savebox{\bigbox}{\includegraphics[width=.2\linewidth]{example-image-a}}% Large(r) image
\savebox{\smallbox}{\includegraphics[width=.1\linewidth]{example-image-c}}% Small(er) image
\mbox{}\hfill
\subcaptionbox{text 1}{\includegraphics[width=.2\linewidth]{example-image-a}}\hfill
\bigrightArrow[13pt]\hfill
\subcaptionbox{text 2}{\includegraphics[width=.2\linewidth]{example-image-b}}\hfill
\bigrightArrow[13pt]\hfill
\subcaptionbox{text 3}{~~\raisebox{\dimexpr.5\ht\bigbox-.5\ht\smallbox}{\usebox{\smallbox}}~~}\hfill
\mbox{}%

\end{figure}

Some text \textbf{underneath} the image.

\end{document}