使用此代码
\begin{tabular}{cc}
\begin{tikzcd}
& B \arrow{dr}{g} \\
A \arrow{ur}{f} \arrow{rr}{h} && C
\end{tikzcd} &
\begin{tikzcd}
& \text{Hom}(B,G) \arrow{dl}{\widetilde f}\\
\text{Hom}(A,G) && \text{Hom}(C,G) \arrow{ll}{\widetilde h} \arrow{ul}{\widetilde g}
\end{tikzcd}
\end{tabular}
我得到以下图表
正如您所发现的,第二张图的标签已相对于给定的箭头“反射”。我想补救这个问题,但我不知道该怎么做。
在此先感谢您的帮助。
附言:我想提供一个可行的代码示例,但我不知道编译它需要哪些包。
答案1
交换标签的方法有很多种。以下是其中三种:
- 您可以用 交换标签
every arrow/.append style={swap}
。 - 您可以通过添加
[swap]
箭头来交换单个标签。 - 如果使用
quotes
语法,交换标签就像添加素数一样简单。
示例代码:
\documentclass{article}
\usepackage{tikz-cd}
\usepackage{amsmath}
\begin{document}
%
\begin{figure}[htb]
\centering\begin{tabular}{cc}
\begin{tikzcd}
& B \arrow{dr}{g} \\
A \arrow{ur}{f} \arrow{rr}{h} && C
\end{tikzcd} &
\begin{tikzcd}[every arrow/.append style={swap}]
& \text{Hom}(B,G) \arrow{dl}{\widetilde f}\\
\text{Hom}(A,G) && \text{Hom}(C,G) \arrow{ll}{\widetilde h} \arrow{ul}{\widetilde g}
\end{tikzcd}
\end{tabular}
\caption{All labels swapped at once with the key \texttt{every arrow/.append
style=\{swap\}}.}
\end{figure}
%
\begin{figure}[htb]
\centering\begin{tabular}{cc}
\begin{tikzcd}
& B \arrow{dr}{g} \\
A \arrow{ur}{f} \arrow{rr}{h} && C
\end{tikzcd} &
\begin{tikzcd}
& \text{Hom}(B,G) \arrow[swap]{dl}{\widetilde f}\\
\text{Hom}(A,G) && \text{Hom}(C,G) \arrow[swap]{ll}{\widetilde h} \arrow[swap]{ul}{\widetilde g}
\end{tikzcd}
\end{tabular}
\caption{Individual labels swapped by adding \texttt{[swap]} to the arrows.}
\end{figure}
%
\begin{figure}[htb]
\centering\begin{tabular}{cc}
\begin{tikzcd}
& B \arrow{dr}{g} \\
A \arrow{ur}{f} \arrow{rr}{h} && C
\end{tikzcd} &
\begin{tikzcd}
& \text{Hom}(B,G) \arrow[dl,"\widetilde f"']\\
\text{Hom}(A,G) && \text{Hom}(C,G)
\arrow[ll,"\widetilde h"']
\arrow[ul,"\widetilde g"']
\end{tikzcd}
\end{tabular}
\caption{Labels can be swapped with the \texttt{quotes} syntax by adding a
prime.}
\end{figure}
\end{document}