2
\documentclass[10pt]{article}
\usepackage{fancyhdr,graphicx,lastpage}
\usepackage[all]{xy}
\usepackage{listings}
\usepackage{latexsym}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{makeidx}
\makeindex  

\usepackage[a4paper,hmargin=2.5cm,vmargin=2.5cm]{geometry}
\renewcommand{\rmdefault}{ptm}
\renewcommand{\bfdefault}{b}
\usepackage[scaled=0.92]{helvet}
\usepackage{courier}
\normalfont % in case the EC fonts aren't available
\usepackage[T1]{fontenc}
\usepackage{etoolbox}
\makeatletter

\begin{document}
Given categories $\mathbb{A}$ and $\mathbb{B}$ consider the natural transformations:
$\xymatrix{\mathbb{A}\ar@<2ex>[r]^F^{\alpha} \ar[r]_G \ar@<-2ex>[r]_H^{\beta}&\mathbb{B}}$ 
\end{document}$

Please help me typeset this arrow diagram in xymatrix. This is vertical composition of two natural transformations.

Vertical Composition of two natural transformations1

2 Answers2

1

I know you requested a solution with xy, but you may want to consider a tikz-cd solution.

enter image description here

Here is the code:

\documentclass{article}

\usepackage{amsfonts} \usepackage{tikz-cd}

\begin{document}

[\begin{tikzcd}[row sep=.3cm, column sep=3cm] \phantom{\mathbb{A}}\arrow[r, "F" description, ""{name=top, below}] & \phantom{\mathbb{B}}\ \mathbb{A}\arrow[r,"G" description, ""{name=midtop, above}, ""{name=midbot, below}] & \mathbb{B}\ \phantom{\mathbb{A}}\arrow[r, "H" description, ""{name=bot}] & \phantom{\mathbb{B}} \arrow[from=top,to=midtop,"\alpha"] \arrow[from=midbot,to=bot,"\beta"] \end{tikzcd}]

\end{document}

The idea is to name the space above and below the center labels so that the vertical arrows can be placed correctly. The \phantom symbols are used to keep the horizontal arrows the same length.

You can adjust the spacing to your liking by changing row sep and column sep values.

Sandy G
  • 42,558
0

Updated 1: Using an hacky.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}
\usepackage[all,cmtip]{xy}

\begin{document} \xymatrix@R=.8pc@C=8pc{ \mathbb{A} \ar[r]|G \ar@<-4ex>[r]H \ar@<4ex>[r]^F{\mkern9.8mu\big\downarrow \alpha} \ar@<10.5ex>[d]^{\beta} &\mathbb{B}\ & } \end{document}

enter image description here


I'm not very able with the explanations but it not necessary to use double dollars $ with \xymatrix as from my example, that is similar to the original image. My code it is very simple because I'm not an expert (for my low level to understand the documentations) and you can see the minimal differences.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}

\usepackage[all]{xy}

\begin{document}

\xymatrix@1@C=6pc{ \ar[r]^F \ar@<7.9ex>[d]^{\alpha}&\ \mathbb{A} \ar[r]|G \ar@<7.9ex>[d]^{\beta}& \mathbb{B}\ \ar[r]_H & }

\end{document}

enter image description here

Here there is a different approaches for the rows R and the columns C.

\documentclass[a4paper,12pt]{article}
\usepackage{amsmath,amssymb}

\usepackage[all]{xy}

\begin{document} xymatrix@R=1pc@C=5pc{ \ar[r]^F \ar@<7.2ex>[d]^{\alpha}&\ \mathbb{A} \ar[r]|G \ar@<7.2ex>[d]^{\beta}& \mathbb{B} \ \ar[r]_H & } \end{document}

enter image description here

Sebastiano
  • 54,118
  • Sebastiano thank you, this is exactly what i wanted. My problem was adding the arrows pointing down. However, i see that you used 6 nodes in total. Just for the fun of it, is it possible to have achieved it using only two nodes? – Sifiso Masuku Aug 15 '20 at 12:27
  • 1
    I just noticed that in your solution the arrow G is shorter than the other two. – Sifiso Masuku Aug 15 '20 at 12:32
  • @SifisoMasuku I'm glad to help you. I'm thinking but peraphs it is impossible. It is true but with a lot of sincerity I think that is the label G that is above the first vertical arrow. Peraphs I will must shift the arrow....also to have 4 nodes in the total. – Sebastiano Aug 15 '20 at 12:32
  • @SifisoMasuku I have done an updating. – Sebastiano Aug 15 '20 at 16:43
  • 1
    This is excellent, well done. Thank you very much. – Sifiso Masuku Aug 15 '20 at 17:48
  • where did you learn about \mkern so quickly and how does it work? – Sifiso Masuku Aug 15 '20 at 17:55
  • @SifisoMasuku \mkern is a mathematical command to shift a symbol: https://tex.stackexchange.com/questions/112287/difference-between-mskip-and-mkern – Sebastiano Aug 15 '20 at 19:09