I have thought of asking 3 different questions, but then they are all about the same package, and about fiddling with arrows, so they are all related, so I thought I'd go with one. Here we go. My code:
\documentclass[a4paper]{report}
\usepackage{amsmath,amssymb,amsfonts,newtxmath,newtxtext,tikz-cd,graphicx}
\usetikzlibrary{decorations.markings,decorations.pathreplacing,positioning,cd}
\begin{document}
\[\begin{tikzcd}
a \ar[r,leftarrow] \ar[d,rightarrow,red] & id \ar[r,rightarrow,red] & b \ar[d,rightarrow] \\
ab \ar[d,rightarrow] & & ba \ar[d,rightarrow,red] \\
aba \ar[loop left,blue,no head] \ar[rrr,bend left=24,blue,xshift=-5.5ex,yshift=-.4ex,no head] \ar[rrr,bend right=22,blue,xshift=-5.5ex,yshift=.4ex,no head] & & bab \ar[loop right,blue,phantom,"\scalebox{.3}{\bfseries)}",xshift=-2.6ex,yshift=-.5ex] & {\color{white}a}
\end{tikzcd}\]
\[\begin{tikzcd}
G \ar[d,thick, start anchor=center, end anchor=center, xshift=-.5em, decorate,decoration={brace,amplitude=4pt,mirror},"abel"'] \ar[d,no head] \\
N \\
G' \ar[d,dashed,no head] \\
\left\langle\mathcal{C}_1\right\rangle \ar[d,no head] \\
1
\end{tikzcd}\]
\[\begin{tikzcd}
& & 3 \ar[loop below,red,"b"] \ar[dr,green,"c"] \\
V \ar[loop,blue,"a",out=160,in=110] \ar[loop,green,"c",out=-110,in=-160] \ar[r,red,"b"] & 2 \ar[ur,blue,"a"] \ar[dr,green,"c"'] & {} & 5 \ar[r,red,"b"] & 6 \ar[loop,blue,"a",out=70,in=20] \ar[loop,green,out=-70,in=-20] \\
& & 4 \ar[loop above,red,"b"] \ar[ur,blue,"a"]
\end{tikzcd}\]
\end{document}
Result:
Problems:
- What I want is to circle the two entries on the bottommost row; for the moment, I have a loop left, two no-head arrows pointing one cell too far (well, I would point them rr but I changed them to rrr to get them as they are), and a micro-parenthesis which is almost invisible; is there a way to get any kind of shape (possibly not a rectangle, I'd prefer something more curved, an oval, or a blob, but a rectangle will do if something curved is not feasible) to surround those entries?
- "abel" (standing for "abelian", meaning the quotient of the two entries is abelian) is too close to the brace, and the brace has that extra little stroke; how do I remove the stroke and move "abel" further left?
- Those loops are too squashed; I specified
in
andout
angles correctly, but I want to take those arrows and "stretch" them in the direction orthogonal to them; more precisely, right now to obtain them one would have to take aloop above
orloop below
as the ones in the middle of the diagram, squash them vertically until they have almost zero height, then rotate them; how can I get those loops to look like what I described but without the squashing?
Edit: Here is something close to what I want for 3, in particular the loops for V should be more slanted than this, like mirroring those for 6:
Update:
Problems 2 and 3 are fixed, as my answer states. Problem 1 has a touch of bizarre to it. I copy-pasted both answers' solutions into a file and compiled it, and they worked. Then I copy-pasted the solutions for diagram 1 into my old MWE. Here is what happened to LaRiFaRi's fix:
And here is Gonzalo's:
Gonzalo's actually has extra strangeness, in that on the first compilation it was identical to LaRiFaRi's, then I moved it vertically and the ellipse moved erratically, then I compiled it a few times and I saw it again like LaRiFaRi's, then I compiled it once more and the ellipse was gone, as you see above. So what is going on? And what are the [alias…]
for?
Update 2: I thought I had irremediably lost the possibility to retrieve those compilations' effects, but then I remembered I take a lot of screenshots when fiddling with LaTeX, so here are a few:
I tried a couple of fiddles, but to no avail:
Notice how Gonzalo's solution fixed the ellipse's placement as I fiddled with LaRiFaRi's.
Update 3: More bizarreness. Here is the code:
\documentclass[a4paper]{report}
\usepackage{amsmath,amssymb,amsfonts,newtxmath,newtxtext,tikz-cd,graphicx}
\usetikzlibrary{decorations.markings,decorations.pathreplacing,positioning,cd,fit,shapes.geometric}
\DeclareMathOperator{\id}{id}
\begin{document}
Gonzalo docet:
\[
\begin{tikzcd}[remember picture,overlay]
a
\ar[r,leftarrow]
\ar[d,rightarrow,red]
&
id
\ar[r,rightarrow,red]
&
b
\ar[d,rightarrow]
\\
ab
\ar[d,rightarrow]
&
&
ba
\ar[d,rightarrow,red]
\\
aba
&
&
bab
\end{tikzcd}
\tikz[remember picture,overlay]{
\node[ellipse,inner xsep=0pt,draw,blue,fit={(tikz@f@1-3-1) (tikz@f@1-3-3)}] {};
}
\]
\vspace{2cm}
\[
\begin{tikzcd}
G
\ar[d,thick, start anchor=center, end anchor=center,no head, xshift=-.5em,decorate,decoration={brace,amplitude=4pt,mirror},"\text{\normalsize abel}" left=5pt]
\ar[d,no head]
\\
N
\\
G'
\ar[d,dashed,no head]
\\
\left\langle\mathcal{C}_1\right\rangle
\ar[d,no head]
\\
1
\end{tikzcd}
\]
\[
\begin{tikzcd}
&
&
3
\ar[loop below,red,"b"] \ar[dr,green,"c"]
\\
V
\ar[loop above,blue,"a",out=155,in=105,looseness=7]
\ar[loop below,green,"c",out=-105,in=-155,looseness=7]
\ar[r,red,"b"]
&
2
\ar[ur,blue,"a"]
\ar[dr,green,"c"']
&
{}
&
5
\ar[r,red,"b"]
&
6
\ar[loop,blue,"a",out=75,in=25,looseness=7]
\ar[loop,green,out=-25,in=-75,looseness=7]
\\
&
&
4
\ar[loop above,red,"b"]
\ar[ur,blue,"a"]
\end{tikzcd}
\]
LaRiFaRi docet:
\[\begin{tikzcd}[execute at end picture={\node[ellipse,draw,blue,fit={(tikz@f@1-3-1) (tikz@f@1-3-3)}]{};}]
a \arrow[red]{d} & \id \arrow{l}\arrow[red]{r} & b \arrow{d} \\
ab \arrow{d} & & ba \arrow[red]{d} \\
|[alias=X]|aba & & |[alias=Y]|bab
\end{tikzcd}\]
\[\begin{tikzcd}[every arrow/.append style=dash]
G \ar[thick, start anchor=center, end anchor=center, xshift=-.5em, decorate,decoration={brace,amplitude=4pt,mirror}]{d}[left= 4pt]{\text{abel}} \arrow{d} \\
N \\
G' \ar[d,dashed] \\
\left\langle\mathcal{C}_1\right\rangle \arrow{d} \\
1
\end{tikzcd}\]
\[\begin{tikzcd}
& & 3 \ar[loop below,red,"b"] \ar[dr,green,"c"] \\
V \ar[loop,distance=20pt,blue,"a",out=160,in=110] \ar[loop,distance=20pt,green,"c",out=-110,in=-160] \ar[r,red,"b"] & 2 \ar[ur,blue,"a"] \ar[dr,green,"c"'] & {} & 5 \ar[r,red,"b"] & 6 \ar[loop,distance=20pt,blue,"a",out=70,in=20] \ar[loop,distance=20pt,green,out=-70,in=-20] \\
& & 4 \ar[loop above,red,"b"] \ar[ur,blue,"a"]
\end{tikzcd}\]
\end{document}
First few runs it compiled identically to:
After fiddling with the screenshots from the other update (n. 2), I test it again and:
And I'm like WTF??
alias
gives an alias to the node. In this case it allows you to usefit={(X)(Y)}
instead offit={(tikz@f@1-3-1) (tikz@f@1-3-3)}
.remember picture, overlay
, which allows you to refer to node names outside thetikzpicture
where they were defined. This is how Gonzalo drew the ellipse. If you for example remove Gonzalo's code from that example, LaRiFaRi's work fine. If you usefit={(X)(Y)}
in LaRiFaRi's code, as I mentioned in my previous comment, both work fine.|[alias=A]
in Gonzalo's solution, The result isUse of \tikz@fig@scan@at doesn't match its definition
. How do I get aliases in Gonzalo's solution? In other words, why is that error coming up and how can I fix it? @TorbjørnT.|
as well.