0

I want to position the below diagram more to the center of my page. It shows it to left of my page.

\begin{xy}
     (0,20)*+{A}="a"; 
    (20,20)*+{B}="b";
     (20, 0)*+{C}="c";
     {\ar         "a";"b"}?*!/_8pt/{f};
     {\ar    "a";"c"}?*!/^6pt/{h};
     {\ar "b";"c"}?*!/_8pt/{g};
\end{xy}
Leucippus
  • 1,636

1 Answers1

2

Depending on the context, you can enclose the diagram in \[...\] to have it behave as displayed math. You can change h to f\circ g in the label but you need to adjust the label spacing slightly.

enter image description here

\documentclass{article}

\usepackage[arrow,cmtip]{xy}

\begin{document} [ \begin{xy} (0,20)+{A}="a"; (20,20)+{B}="b"; (20, 0)+{C}="c"; {\ar "a";"b"}?!/_8pt/{f}; {\ar "a";"c"}?!/^12pt/{f\circ g}; {\ar "b";"c"}?!/_8pt/{g}; \end{xy} ]

\end{document}

However, you might consider switching to tikz-cd, which fixes many spacing issues in xy and has much more intuitive code, as well as having many more options.

The default for arrow labels is \scriptstyle, so you need labels = {font = \normalsize} to have the larger labels. Remove that bit of code for the default labels. But also, see @Qrrbrbirlbel's comment below.

enter image description here

\documentclass{article}

\usepackage{tikz-cd}

\begin{document}

[ \begin{tikzcd}[row sep=1.5cm, column sep=1.5cm, labels = {font = \normalsize}] A\arrow[r, "f"]\arrow[rd, "f\circ g"'] & B\arrow[d, "g"]\ & C \end{tikzcd} ]

\end{document}

Sandy G
  • 42,558
  • Just doing labels={font=} should be enough to remove the \scriptstyle. It uses the font key to change \everymath. – Qrrbrbirlbel Dec 03 '22 at 03:51
  • @Qrrbrbirlbel: Good point. Though for a beginner it might be better to include \normalsize to make it more obvious how to change, for example, to \footnotesize or \large. – Sandy G Dec 03 '22 at 04:32