7

I want to make a tikz-cd diagram (for simplicity, let's just make it one vertical arrow, though I actually am working with a square) which also says that some objects are subsets of other sets, or subgroups of other groups. However, with all solutions I came up with, I end up with either weird spacing or weird arrow placement (two can be found in the MWE). Is there a correct (preferably non-hacky) way to do it?

MWE:

\documentclass{article}

\usepackage{tikz-cd}
\begin{document}
\begin{tikzcd}
A&\supseteq&B\ar[d]\\
&&G&\leq&H
\end{tikzcd}

\begin{tikzcd}
A\supseteq B\ar[d]&\\
G\leq H
\end{tikzcd}
\end{document

Edit: Unfortunately, the proposed solutions do not really solve my problem. I would also like to include bigger diagrams (my actual use case is a square diagram, but ideally, one should be able to do that for more exotic ones as well). More importantly, none of the solutions seems to work right in case when one item in the diagram has a significantly longer label (as is true in my use case).

Here is an amended MWE:

\documentclass{article}

    \usepackage{tikz-cd}
    \begin{document}
    \begin{tikzcd}
    A&\supseteq&C\ar[d]\ar[dr]\ar[r]&\textrm{SomewhatLongLabel}\ar[d]&\leq&\textrm{AlsoQuiteLong}\\
    &&F&G&\leq&H
    \end{tikzcd}

\end{document}

(Bonus points if you can somehow fit an arrow from A to F in a nice way, but I don't need it, for now.)

7

You can use code from this answer by LaRiFaRi

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

\tikzset{
  symbol/.style={
    draw=none,
    every to/.append style={
      edge node={node [sloped, allow upside down, auto=false]{$#1$}}}
  }
}

\begin{document}

\begin{tikzcd}[column sep=.7em]
A \arrow[r,symbol=\supseteq] &B \arrow[d] \\
& G \arrow[r,symbol=\leq] & H
\end{tikzcd}

\end{document}

enter image description here

| improve this answer | |
1

You can control the spacing between rows/colums with:

  • [row sep=..., column sep=...] as options of the tikzcd environment, for all the rows/columns
  • with [...] after \\ or &, respectively for a single row or column.

You can see both cases here:

\documentclass{article} 
\usepackage{tikz-cd} 
\begin{document}
Try this way:\vspace{3ex}

\begin{tikzcd}[column sep=-4pt,row sep=10pt]
A&\supseteq&B\ar[d]\\ 
G&\leq&H 
\end{tikzcd} 

\vspace{3ex}Or this way:\vspace{3ex}

\begin{tikzcd}
A&[-28pt]\supseteq&[-28pt]B\ar[d]\\[-7pt] 
G&\leq&H 
\end{tikzcd} 
\end{document}

enter image description here

| improve this answer | |
1

Here is a solution. I added another simple solution with pstricks code inside an ordinary align* environment:

\documentclass{article}
\usepackage{amsmath}
\usepackage{pst-node}
\usepackage{auto-pst-pdf}% for compilation with pdflatex
\usepackage{tikz-cd}

\begin{document}

\begin{tikzcd}[column sep=-0.5em, row sep=0.8em]
A&\supseteq&B\ar[d]\\
G&\leq&H
\end{tikzcd}
\bigskip

\begin{postscript}
\begin{align*}
A & \supseteq \Rnode{B}{B}&\\[2ex]
G & \leq \Rnode{H}{H}
\ncline[linewidth=0.4pt, arrows =->, arrowinset=0.12, nodesep=0.6ex]{B}{H}
\end{align*}
\end{postscript}

\end{document} 

enter image description here

Edit:

Here is possibility for your updated mwe:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz-cd}
\usepackage[usestackEOL]{stackengine}

\begin{document}

\begin{tikzcd}
A\drar\rar[phantom,"\supseteq" ]&C\dar\ar[dr]\rar&\Centerstack[l]{Somewhat \\LongLabel}\ar[d]\ar[r, phantom, "\leq"]&\textrm{AlsoQuiteLong}\\
&F&G&H
\end{tikzcd}

\end{document} 

enter image description here

| improve this answer | |
  • Thanks, but I would like a solution that would also work for larger diagrams. The single vertical line was just an example. – tomasz Oct 3 '17 at 15:28
  • @tomasz: In this case explain exactly what you want. Pstricks commands inserted in LaTeX code can do rather sophisticated things in a simple way. If you want to see a short outline of what can be done in this respect, please take a look at my answer to this recent question. – Bernard Oct 3 '17 at 15:42
  • I edited the question. – tomasz Oct 3 '17 at 15:43
  • @tomasz: I propose a code for you new mwe. Is it more or less this you want? – Bernard Oct 3 '17 at 16:36
  • Not really, no. The point is, I want the spacing to the right of the long item be good, as well as the one below. You did not include the inequality between G and H. – tomasz Oct 4 '17 at 10:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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