How to vertically align and scale images within a tabularx environment

by 3kstc   Last Updated September 12, 2019 03:23 AM

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}{@{}[email protected]{}}
    \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:

enter image description here

Ideal Output:

enter image description here

Question:

How does one:

  • vertically align an image within the above MWE
  • scale an image within the above MWE


Answers 1


See if the following solution is acceptable to you:

\documentclass{report}
\usepackage{tabularx}
\usepackage[export]{adjustbox}
\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}

enter image description here

Zarko
Zarko
September 12, 2019 02:56 AM

Related Questions



replace includeGraphics with inline-image

Updated February 07, 2019 16:23 PM


Graphicx Displays File Path, not Image

Updated May 24, 2017 18:23 PM