1

Below is an excerpt from Anton Geraschenko's stack notes.

How can I typeset the triangle of arrows? I thought of using underset somehow but I don't get a long enough arrow and the spacing doesn't work, not to mention I don't know how to produce the small diagonal arrows.

enter image description here

Arrow
  • 501
  • Please show what you've tried (MWE). This seems like one of those typical "one can crack it with the TikZ sledgehammer" problems. – TeXnician Oct 19 '17 at 17:39

2 Answers2

2

Stack notes? Did someone mention stack?

\documentclass{article}
\usepackage{stackengine,amsmath,graphicx}
\stackMath
\newcommand\triar[3]{%
  \vcenter{\hbox{$%
  #1%
  \setbox0=\hbox{$\rightarrow#3\leftarrow$\kern-4pt}%
  \stackunder[0pt]{\xrightarrow{\kern\wd0}}%
    {%
      \rotatebox[origin=r]{-20}{$\rightarrow$}%
      \raisebox{-2pt}{$#3$}%
      \rotatebox[origin=l]{+20}{$\leftarrow$}%
    }%
  #2%
  $}}%
}
\begin{document}
whose objects are $\mathcal{P}$ morphisms to $Y$, with 
\(
\left\{\triar{X_i}{X}{Y}\right\}
\)\medskip

but not this: 
\(
\left\{\triar{X_i}{X}{Y_\text{long middle element}}\right\}
\)
\end{document}

enter image description here

  • Thanks! Funny how 'stack' popped up in a different context :) – Arrow Oct 19 '17 at 18:21
  • @Arrow Yup. Around here, I am Mr. Stack-it. – Steven B. Segletes Oct 19 '17 at 18:22
  • Or maybe Friar Stack-it? :o) – Bernard Oct 19 '17 at 18:41
  • @Bernard Wouldn't that be Friar Stuck? I'm that too, all too often. – Steven B. Segletes Oct 19 '17 at 18:46
  • Welcome to TeX Stuck Exchange then! – Bernard Oct 19 '17 at 18:47
  • Dear @StevenB.Segletes Mr Stack-it, could you include a similar macro for small vertical maps? That is, something smaller than a \smallmatrix with three rows? – Arrow May 24 '19 at 15:39
  • @Arrow Can you provide a web pointer to what you mean by "small vertical maps"? – Steven B. Segletes May 24 '19 at 15:41
  • @StevenB.Segletes I want to typeset arrows of the form \begin{smallmatrix}X\\ \downarrow\\ Y \end{smallmatrix} often inline, or as subscripts. For this purpose, the diagram generated by the above code is too big. For instance I want to write something like \mathrm{T}\left(\begin{smallmatrix}X\\ \downarrow\\ Y \end{smallmatrix}\right) without having the vertical diagram so tall. Perhaps it's possible to shrink it nicely? – Arrow May 24 '19 at 15:47
  • @Arrow To force it to fall within \baselineskip size, for inline use, \usepackage{scalerel}. Then, define \newcommand\vertmap[2]{{ \scalerel*{\left(\begin{smallmatrix}#1\\\downarrow\\#2\end{smallmatrix}\right)}{ \strut} }} and use as Here is \(\mathrm{T}\vertmap{X}{Y}\) inline. – Steven B. Segletes May 24 '19 at 16:02
  • @StevenB.Segletes amazing, thank you! If it's alright, I have two more requests: 1) is it possible to make the scaling factor explicit in the code, so I could play with it? 2) is it possible to include an argument for a label to the right of the vertical arrow, in a way that will still keep the arrow centered? – Arrow May 24 '19 at 16:06
  • @Arrow As to your first question, \newcommand\vertmap[3][1]{{ \scalerel*{\left(\begin{smallmatrix}#2\\\downarrow\\#3\end{smallmatrix}\right)}{ #1} }} \newcommand\bigstrut{\rule[-2pt]{0pt}{10pt}} Here is \(\mathrm{T}\vertmap{X}{Y}\) inline and \(\mathrm{T}\vertmap[\bigstrut]{X}{Y}\). You can play with the dimensions of \bigstrut. – Steven B. Segletes May 24 '19 at 16:12
  • @Arrow As to the 2nd question, 1) is the label inside the parens? 2) is it OK if the label is the same size as the map from/to labels? – Steven B. Segletes May 24 '19 at 16:16
  • Dear @StevenB.Segletes, the parentheses are not necessary. The label is right next to the arrow, on the right. (Like a rotated \overset.) I am not sure I understood your second question. – Arrow May 24 '19 at 16:17
  • @Arrow Something like this? \newcommand\vertmap[4][1]{{\scalerel*{\left(\begin{smallmatrix}#2\\\downarrow\smash{\rlap{\kern.3pt\raisebox{.3ex}{\rotatebox[origin=c]{-90}{$\scriptscriptstyle#4$}}}}\\#3\end{smallmatrix}\right)}{#1}}} \newcommand\bigstrut{\rule[-2pt]{0pt}{10pt}} Here is \(\mathrm{T}\vertmap{X}{Y}{}\) inline and \(\mathrm{T}\vertmap[\bigstrut]{X}{Y}{\alpha}\). – Steven B. Segletes May 24 '19 at 16:43
  • @StevenB.Segletes Yes! Infinite thanks!! – Arrow May 24 '19 at 16:45
2

With tikz-cd:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}

\newcommand{\tricd}[3]{% \begin{tikzcd}[ baseline={([yshift=-axis_height]mycd)}, ampersand replacement=&, every matrix/.append style={ name=mycd, nodes={inner sep=0pt, outer sep=2pt} }, row sep=0pt, column sep=12pt ] #1\ar[rr]\ar[to=mycd-2-2.west]&&#2\ar[to=mycd-2-2.east]\ &#3 \end{tikzcd}% }

\begin{document} whose objects are $\mathcal{P}$ morphisms to $Y$, with ( \left{\tricd{X_i}{X}{Y}\right} )\medskip

but not this: ( \left{\tricd{X_i}{X}{Y_\text{long middle element}}\right} ) \end{document}

enter image description here

P.S. = thanks to Qrrbrbirlbel for their solution to the vertical alignment problem.

CarLaTeX
  • 62,716