将两个 tikz 图对齐成一行的优雅方法

将两个 tikz 图对齐成一行的优雅方法

我希望将两个 tikz 图放在同一行,使它们对齐,并以四分之一为中心,如下所示:

在此处输入图片描述

我现在知道的唯一方法是将 tikz 图放在一个公共方程中,然后手动添加空格,例如:

\[
\begin{tikzcd}
\ast\times X\arrow[r,"{(1,1_X)}"]\arrow[dr,swap,"\cong"] & G\times X\arrow[d,"\alpha"]\\
&X
\end{tikzcd}
%
\qquad\qquad
%
\begin{tikzcd}
G\times G\times X\arrow[r,"{(m,1_X)}"]\arrow[d,swap,"{(1_G,\alpha )}"] & G\times 
X\arrow[d,"\alpha"]\\
G\times X \arrow[r,"\alpha"]&X
\end{tikzcd}
\]

调整间距确实是浪费时间,所以我想知道是否有任何优雅的方法可以自动对齐图表。

提前致谢。

答案1

  • 在方程环境中不能有空行
  • 你说的居中是什么意思,这并不是完全不清楚。

以下简单的解决方案是否接近您所追求的?

在此处输入图片描述

(红线表示文字边框)

\documentclass{article}
\usepackage{tikz-cd}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}
\[
\begin{tikzcd}[column sep=large]
\ast\times X\arrow[r,"{(1,1_X)}"]\arrow[dr,swap,"\cong"] & G\times X\arrow[d,"\alpha"]\\
&X
\end{tikzcd}
%
\qquad
%
\begin{tikzcd}[column sep=large]
G\times G\times X\arrow[r,"{(m,1_X)}"]\arrow[d,swap,"{(1_G,\alpha )}"] & G\times
X\arrow[d,"\alpha"]\\
G\times X \arrow[r,"\alpha"]&X 
\end{tikzcd}
\]
\end{document}

附录: 看来 OP 正在寻找以下内容:

在此处输入图片描述

(红线表示文本边框,垂直黑线表示图像平分线的位置)

\documentclass{article}
\usepackage{tabularx}
    \newcolumntype{C}{>{\centering\arraybackslash}X}
\usepackage{tikz-cd}
%---------------- Show page layout. Don't use in a real document!
\usepackage{showframe}
\renewcommand\ShowFrameLinethickness{0.15pt}
\renewcommand*\ShowFrameColor{\color{red}}
%---------------------------------------------------------------%

\begin{document}

\noindent\begin{tabularx}{\linewidth}{ C | C } % in real document delete `|`
\begin{tikzcd}[column sep=large,
               ampersand replacement=\&]
\ast\times X\arrow[r,"{(1,1_X)}"]\arrow[dr,swap,"\cong"]
    \& G\times X\arrow[d,"\alpha"]\\
    \&   X
\end{tikzcd}
    &   \begin{tikzcd}[column sep=large,
               ampersand replacement=\&]
        G\times G\times X\arrow[r,"{(m,1_X)}"]\arrow[d,swap,"{(1_G,\alpha )}"]
        \&  G\times
            X\arrow[d,"\alpha"]\\
        G\times X \arrow[r,"\alpha"]
        \&  X
        \end{tikzcd}    \\
    \vline  & \vline  % in real document delete this code line
\end{tabularx}
\end{document}

相关内容