vertical-alignmenttikzsubfigure

how to align vertically a tikzcd diagram and a tikzpicture side-by-side?


I use subcaption package to align two subfigures. I used for both subfigures the t-option for vertical alignment but the to figures do not align properlyL the top of the first figure is at the same vertical position as the bottom of the second figure. I want both to be aligned in the middle.

Here is a minimal reproducible example:

\documentclass[a4paper,11pt]{report}
\usepackage{subcaption}
\usepackage{tikz}
\usetikzlibrary{cd}
%
\begin{document}
This is the first line
\begin{center}
\begin{figure}[h!tb]
\begin{subfigure}[t]{0.4\textwidth}
\centering
\begin{tikzcd}
R \ar[r,leftarrow,"f"] \ar[rd,leftarrow, "f\circ x^{-1}"']  &U \ar[r,leftarrow,"\gamma"] \ar[d,"x"] &R \ar[dl, "        x       \circ\gamma"]\\
& R^d
\end{tikzcd}
\end{subfigure}
\centering  
\begin{subfigure}[t]{0.4\textwidth}
\centering
\begin{tikzpicture}
\node at (1,1.4){$R^2$};
\draw[->] (0,0)node{$\bullet$}--(2,0)node[below]{$q^1$-axis};
\draw[->] (0,0)--(0,1.5)node[left]{$q^2$-axis};
\end{tikzpicture}
\end{subfigure}
\caption{This is a test}
\end{figure}
\end{center}
This is the last line.
\end{document}

Solution

  • \documentclass[a4paper,11pt]{report}
    \usepackage{subcaption}
    \usepackage{tikz}
    \usetikzlibrary{cd}
    %
    \begin{document}
    This is the first line
    %\begin{center}
    \begin{figure}[htb]
    \centering
    \begin{subfigure}[T]{0.4\textwidth}
    \centering
    \begin{tikzcd}
    R \ar[r,leftarrow,"f"] \ar[rd,leftarrow, "f\circ x^{-1}"']  &U \ar[r,leftarrow,"\gamma"] \ar[d,"x"] &R \ar[dl, "        x       \circ\gamma"]\\
    & R^d
    \end{tikzcd}
    \end{subfigure}
    \centering  
    \begin{subfigure}[T]{0.4\textwidth}
    \centering
    \begin{tikzpicture}
    \node at (1,1.4){$R^2$};
    \draw[->] (0,0)node{$\bullet$}--(2,0)node[below]{$q^1$-axis};
    \draw[->] (0,0)--(0,1.5)node[left]{$q^2$-axis};
    \end{tikzpicture}
    \end{subfigure}
    \caption{This is a test}
    \end{figure}
    
    %\end{center}
    This is the last line.
    \end{document}
    

    enter image description here