如何使用 tikz-cd 和任何框架環境繪製函子圖

如何使用 tikz-cd 和任何框架環境繪製函子圖

我想用 tikzcd 和任何框架環境(例如 itembox)繪製一個類似於圖像中的圖表。在此輸入影像描述

對我來說,使用 tikz 既複雜又麻煩,我寧願避免它。我想用tikz-cd。 (用 tikz-cd 繪圖很容易,因為我們可以使用這個工具。https://tikzcd.yichuanshen.de/

我認為這個圖是使用 itembox (ascmac.sty) 和 minipage 繪製的。我嘗試過,但沒有得到想要的結果。

任何意見,將不勝感激。

後記:我們深感抱歉。我嘗試輸出以下程式碼。這不是期望的輸出。 在此輸入影像描述

\begin{minipage}[b]{0.30\linewidth}
\begin{itembox}[l]{$C$}
    \begin{center}
        \begin{tikzcd}[ampersand replacement=\&]
             \& a \arrow[rd,"g"] \&  \\
            b \arrow[ru, "f"] \arrow[rr,"g\circ f"] \&  \& c \\
        \end{tikzcd}
    \end{center}
\end{itembox}
\end{minipage}
\begin{minipage}[b]{0.10\linewidth}
    $\overset{F}{\longrightarrow}$
\end{minipage}
\begin{minipage}[b]{0.30\linewidth}
\begin{itembox}[l]{$D$}
    \begin{center}
        \begin{tikzcd}[ampersand replacement=\&]
             \& F(a) \arrow[rd,"F(g)"] \&  \\
            F(b) \arrow[ru, "F(f)"] \arrow[rr,"F(g\circ f)"] \&  \& F(c) \\
        \end{tikzcd}
    \end{center}
\end{itembox}
\end{minipage}

答案1

  • 對齊輸入中的小頁c而不是b底部,以使箭頭位於中心

  • 要給盒子固定大小,請在其中使用另一組迷你頁


\documentclass{article}
\usepackage{mathtools}
\usepackage{ascmac}
\usepackage{tikz-cd}

\begin{document}

\noindent\begin{minipage}[c]{0.45\linewidth}
\begin{itembox}[l]{$C$}
  \begin{minipage}[c][.6\linewidth]{\linewidth}
    \centering
        \begin{tikzcd}[ampersand replacement=\&]
             \& a \arrow[rd,"g"] \&  \\
            b \arrow[ru, "f"] \arrow[rr,"g\circ f"] \&  \& c \\
        \end{tikzcd}
     \end{minipage}     
\end{itembox}
\end{minipage}%
\begin{minipage}[b]{0.10\linewidth}
    \centering
    $\overset{F}{\longrightarrow}$
\end{minipage}%
\begin{minipage}[c]{0.45\linewidth}
\begin{itembox}[l]{$D$}
   \begin{minipage}[c][.6\linewidth]{\linewidth}
    \centering
        \begin{tikzcd}[ampersand replacement=\&]
             \& F(a) \arrow[rd,"F(g)"] \&  \\
            F(b) \arrow[ru, "F(f)"] \arrow[rr,"F(g\circ f)"] \&  \& F(c) \\
        \end{tikzcd}
     \end{minipage}
\end{itembox}%
\end{minipage}

\end{document}

在此輸入影像描述

相關內容