4

Can someone explain to me this command right above the document command step by step:

\documentclass{article}

\usepackage{amssymb,amsmath}
\usepackage{xypic}
\usepackage[czech]{babel}
\newcommand{\pullbackcorner}[1][dl]{\save*!/#1-1pc/#1:(1,-1)@^{|-}\restore}

\begin{document}
      $$
  \xymatrix@=3pc{
    & & D \\
    B \ar[r]\ar@/^/[rru]^{h} & P \ar[ru] \pullbackcorner & \\
    A \ar [u]^f \ar[r]_g & C \ar[u]\ar@/_/[ruu]_{k} &
  }
  $$
\end{document}

It works as it should but I do not follow HOW.

Alan Munn
  • 218,180
user2925716
  • 1,940

1 Answers1

8

There's quite a bit to unpack in this command, but much of it is just regular XY syntax, which is quite tough to follow unless you use it a lot (which I don't).

Perhaps the part you don't understand is the \save ... \restore part, which is really crucial to understanding how the command works the way it does. So I'll start with a very simple example and we'll build things up piece by piece.

As a historical note, the original source of the macro itself seems to be lost, but there's an early reference to it (acknowledging an unknown source) in the archives of the XY mailing list: https://tug.org/pipermail/xy-pic/2001-July/000015.html.

The * operator

The basic part of the command uses the * operator to place arbitrary text. To see how this works, let's use * to place a red X in the diagram:

\[
  \xymatrix@=3pc{
    & & D \\
    B \ar[r]\ar@/^/[rru]^{h} & P \ar[ru] *{\color{red} X} & \\
    A \ar [u]^f \ar[r]_g & C \ar[u]\ar@/_/[ruu]_{k} &
  }
\]

output of fragment

Since this * code is at the end of an \ar command, it places the text at the end of the arrow, which ends up right on top of the D. Since this is for illustrative purposes, we don't care about that.

\save and \restore

Now let's do the same thing, but instead wrap the * code in {\save ... \restore}:

\[
  \xymatrix@=3pc{
    & & D \\
    B \ar[r]\ar@/^/[rru]^{h} & P \ar[ru] \save*{\color{red} X}\restore & \\
    A \ar [u]^f \ar[r]_g & C \ar[u]\ar@/_/[ruu]_{k} &
  }
\]

Now the X is right on top of the P. This is what \save and \restore do. They allow objects to be added relative to the current position. In this case the current position is P not the end point of the arrow.

output of fragment

Positioning parameters

So this is the basics of what the \pullbackcorner command does. It places a arbitrary text (in this case the corner symbol) relative to the current position rather than at the end of the path. So we can now unpack the rest of the command:

\newcommand{\pullbackcorner}[1][dl]{\save*!/#1-1pc/#1:(1,-1)@^{|-}\restore}

The \pullbackcorner is a macro that takes one optional argument (a direction specification) whose default is dl. This is the \newcommand{\pullbackcorner}[1][dl] part of the macro.

It then places the corner symbol @^{|-} (which is really not a symbol, but one of the many xy-pic arrowheads) 1pc away from from the current position in the dl direction /#1-1pc/ (where #1 will be dl by default), with an orientation set by the Cartesian coordinates #1:(1,-1), i.e., relative to #1 (by default dl) set the origin to (1,-1). Changing the 1pc value will move the corner closer or further away from the current position, and changing the (1,-1) values will change the orientation of the corner itself.

Here are a couple of more examples changing those values:

We can move the corner further away:

\renewcommand{\pullbackcorner}[1][dl]{\save*!/#1-3pc/#1:(1,-1)@^{|-}\restore}

\[
  \xymatrix@=3pc{
    & & D \\
    B \ar[r]\ar@/^/[rru]^{h} & P \ar[ru] \pullbackcorner & \\
    A \ar [u]^f \ar[r]_g & C \ar[u]\ar@/_/[ruu]_{k} &
  }
\]

output of fragment

We can rotate the corner:

\renewcommand{\pullbackcorner}[1][dl]{\save*!/#1-1pc/#1:(-1,1)@^{|-}\restore}

\[
  \xymatrix@=3pc{
    & & D \\
    B \ar[r]\ar@/^/[rru]^{h} & P \ar[ru] \pullbackcorner & \\
    A \ar [u]^f \ar[r]_g & C \ar[u]\ar@/_/[ruu]_{k} &
  }
\]

output of fragment

We can supply an optional argument to the macro to change the relative positioning of the corner (in this example, ul).

\[
  \xymatrix@=3pc{
    & & D \\
    B \ar[r]\ar@/^/[rru]^{h} & P \ar[ru] \pullbackcorner[ul] & \\
    A \ar [u]^f \ar[r]_g & C \ar[u]\ar@/_/[ruu]_{k} &
  }
\]

output of fragment

Alan Munn
  • 218,180
  • What a nice explanation! May I ask you yet in which context does $|-$ typeset that pushout sign? When I tried $$|-$$ it typesets completely other symbol. – user2925716 Jun 02 '19 at 18:26
  • This works: $$ \xymatrix@=10pc{ \pullbackcorner } $$ CAN I REMOVE this: \xymatrix@=10pc{ } ? – user2925716 Jun 02 '19 at 18:38
  • @user2925716 This is XY syntax, not a TeX symbol. It's basically an arrow tip. See section 2.3 of the XY guide. – Alan Munn Jun 02 '19 at 18:39
  • OK. What does the parameter =10pc do? – user2925716 Jun 02 '19 at 18:40
  • I'm not really sure what you're asking. The @=10pc sets the row and column spacing for the matrix. You shouldn't use the XY code just to get the symbol in other contexts. For that use one of the various \..corner symbols (e.g. amsmath \ulcorner etc.) And please stop using $$ :) – Alan Munn Jun 02 '19 at 18:44
  • @user2925716 BTW, what's the source of the original macro? I can find it in a document by Peter May at Chicago. Is that where you got it from? – Alan Munn Jun 02 '19 at 18:53
  • Oh, I'm so sticked to $$ , sorry! My original macro is from Shelah: https://arxiv.org/format/0903.3428 Please, how did you look up Peter's May name from the macro itself ? – user2925716 Jun 02 '19 at 19:00
  • @user2925716 I just googled and that was the only result. (It doesn't seem to be in the paper you link to, however.) – Alan Munn Jun 02 '19 at 19:08
  • I think I have far too many open documents. Is it here: https://arxiv.org/pdf/1904.05691.pdf on the page 13 ? For me Google says Na váš předmět vyhledávání - "\newcommand{\pullbackcorner}[1][dl]{\save*!/#1-1pc/#1:(1,-1)@^{|-}\restore}" - nebyl nalezen žádný odkaz.

    Návrhy:

    Ujistěte se, že všechna slova jsou napsána správně.
    Zkuste jiná klíčová slova.
    Zkuste obecnější klíčová slova.
    Zkuste použít méně klíčových slov.
    
    – user2925716 Jun 02 '19 at 19:14
  • @user2925716 The original source seems lost. The closest I could get was https://tug.org/pipermail/xy-pic/2001-July/000015.html (I googled "pullback", not the whole command.) – Alan Munn Jun 02 '19 at 19:29
  • It is NOT lost. See https://arxiv.org/e-print/1904.05691 and search for pullbackcorner. – user2925716 Jun 02 '19 at 19:33
  • @user2925716 What I mean is the original source of the macro. The link I gave is from 2001, and there the person says they don't know where the code comes from. – Alan Munn Jun 02 '19 at 19:38
  • That's interesting. I was sure they in https://arxiv.org/e-print/1904.05691 have created it by themselves. – user2925716 Jun 02 '19 at 19:41
  • @AlanMunn Wonderful explanation. Your answer is between my favorites. Also use you the MAC screen retina :-)? – Sebastiano Jun 02 '19 at 19:53