Similar to this: How to set color dashed vertical rule between images
I want to place a dashed line between two subfigures. I have been able to get it working with a \vrule, but anything I do with the dashed lines stops at the base of the figures rather than extending through the subcaptions. I am using the subcaption package for the figures.
Here is the code so far:
\documentclass{article}
\usepackage{subcaption,graphicx}
\usepackage{tikz}
\usepackage{caption}
\usepackage{subcaption}
\usepackage[multidot]{grffile}
\usepackage{calc}
\begin{document}
\begin{figure}
\centering
\subcaptionbox{This is the first subcaption
\label{fig:solid1}}
{\includegraphics[width=0.2\textwidth]{example-image-a}}
\hspace{2pt}
\unskip\vrule
\hspace{2pt}
\subcaptionbox{Get your second subcaptions here
\label{fig:solid2}}
{\includegraphics[width=0.2\textwidth]{example-image-a}}
\caption{This separator has the right height, but isn't dashed.}
\label{fig:solid}
\end{figure}
\begin{figure}
\centering
\def\testBox{\subcaptionbox{This is the first subcaption
\label{fig:dash1}}
{\includegraphics[width=0.2\textwidth]{example-image-b}}}
\newlength\figHeight
\setlength\figHeight{\heightof{\testBox}}
\testBox
\hspace{3pt}
\tikz{\drawdensely dashed, thick -- (0,0);}
\hspace{1pt}
\subcaptionbox{Get your second subcaptions here
\label{fig:dash2}}
{\includegraphics[width=0.2\textwidth]{example-image-b}}
\caption{This separator is dashed, but is too short.}
\label{fig:dashes}
\end{figure}
\end{document}
Also, why do I need to have different \hspace distances to center the dashed line?




\vruleinstead of a solid, dashed rule? – Werner Oct 18 '23 at 01:06