Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I'd like to produce a commutative diagram with mappings specified inside it, as follows:

Yoneda

My rankly amateur efforts so far have centered on tikzcd with extra columns and rows, as in

\usepackage{tikz-cd}
\begin{document}
\[ 
\begin{tikzcd}
Zap \arrow{rrr}{foo} 
    \arrow{ddd}{bar} & & & Zoom \arrow{ddd}{bar} \\
    & Foo \arrow[mapsto]{r}{\alpha}
      \arrow[mapsto]{d}{\beta}
    & Bar \arrow[mapsto]{d}{\gamma} & \\
& Baz \arrow[mapsto]{r}{\delta}
        & Bong & \\
Zip \arrow[anchor=north]{rrr}{foo} & & & Zop
\end{tikzcd}
\]
\end{document}

This is uglier than the figure above. What's a better way to do this?

EDIT:

The suggestion of Stephen Segletes below showed a gentleman who demands more of his commutative diagrams. I salute him, and commend to you the following magisterial display of elegance, beauty and power:

\documentclass[oneside,english]{amsart}
\usepackage{tikz-cd}
\usepackage{stackengine}[2013-09-11]
\usepackage{graphicx} 
\begin{document}
\[ 
\stackinset{l}{13ex}{b}{6ex}{%
\scalebox{.8}
{% 
\begin{tikzcd}[row sep=8ex, column sep = 8ex, ampersand replacement=\&]
1_C 
    \arrow[mapsto]{r}
    \arrow[mapsto]{d}
\& \vartheta_C1_C = x^{\vartheta} 
    \arrow[mapsto]{d}  \\
f 
    \arrow[mapsto]{r} 
\& \begin{array}{c}Ff\left(x^{\vartheta}\right)=\\\vartheta_D\left(f\right)\end{array}
\end{tikzcd}
} 
}{% 
\begin{tikzcd}[row sep = 20ex, column sep = 20ex, ampersand replacement=\&]
Hom\left(C,C\right) 
    \arrow{r}{\vartheta_C} 
    \arrow[swap]{d}{f}
\& FC 
    \arrow{d}{Ff}  \\
Hom\left(D,C\right) 
    \arrow[swap]{r}{\vartheta_D} 
\& FD
\end{tikzcd}
}
\]
\end{document}

This renders as raw beauty

share|improve this question
    
Welcome to TeX.SX! You can have a look at our starter guide to familiarize yourself further with our format. In particular, it is always best to provide a complete compilable sample document, rather than a code snippet. –  Andrew Swann Sep 17 '13 at 8:02
1  
I don't think you can get any better, because of the wide formula in the inner lower right corner. I'd make two smaller diagrams side by side. –  egreg Sep 17 '13 at 8:21

1 Answer 1

up vote 4 down vote accepted

Pardon me for not knowing tikz, so my diagram does not contain arrows, but lines. But the idea is here. Create two diagrams, and inset the one over the center of the other. In this case, I made the inner diagram smaller in tikz (size 2 vs. 4), but I also scaled it by 80% to show the fonts smaller on the inset.

\documentclass{article}
\usepackage{tikz-cd}
\usepackage{stackengine}[2013-09-11]
\usepackage{graphicx}
\begin{document}
\centering
\stackinset{c}{}{c}{}{%
\scalebox{.8}{%
\begin{tikzpicture}
\node (A) at (0,0) {$Foo$};
\node (B) at (2,0) {$Bar$};
\node (C) at (0,-2) {$Baz$};
\node (D) at (2,-2) {$Bong$};
\draw (A) edge node[above] {$\alpha$} (B);
\draw (C) edge node[below] {$\delta$} (D);
\draw (A) edge node[left] {$\beta$} (C);
\draw (B) edge node[right] {$\gamma$} (D);
\end{tikzpicture}
}
}{%
\begin{tikzpicture}
\node (A) at (0,0) {$Zap$};
\node (B) at (4,0) {$Zoom$};
\node (C) at (0,-4) {$Zip$};
\node (D) at (4,-4) {$Zap$};
\draw (A) edge node[above] {$foo$} (B);
\draw (C) edge node[below] {$foo$} (D);
\draw (A) edge node[left] {$bar$} (C);
\draw (B) edge node[right] {$bar$} (D);
\end{tikzpicture}
}
\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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