2

With this code

\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}

I obtain the following diagrams

enter image description here

As you can find, the labels of the second diagram have been "reflected" with respect to the given arrows. I would like to remedy this, however, I don't know how to do so.

Thanks in advance for your help.

PS: I would like to give a working sample of code, but I don't know which packages are required for this to compile.

1

There are many ways you can swap labels. Here are three of them:

  1. You can swap the labels with every arrow/.append style={swap}.
  2. You can swap individual labels by adding [swap] to the arrows.
  3. If you use the quotes syntax, swapping the labels is as simple as adding a prime.

Example codes:

\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}

enter image description here

  • Sorry, I didn't notice that you edited your answer a quite ago. This answer is satisfactory, thanks. – Akerbeltz Nov 9 at 23:36
  • @Akerbeltz Yes, I first misread the question, sorry. – Schrödinger's cat Nov 9 at 23:37
  • Actually no, your answer was good enough, but afterwards I had the need to do the reflections manually. Good that you actually saw that possibility coming. – Akerbeltz Nov 10 at 0:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.