TransWikia.com

Label an arrow with tikz-cd

TeX - LaTeX Asked on June 29, 2021

I would like to include a pentagon symbol with the letter "S" inside the Leftrightarrow between the two mappings in line 1 and 2 – means as a description in tikzcd.

enter image description here

I have included

documentclass [a4paper,german,twoside,openright,11pt]{book}
usepackage[utf8]{inputenc}
usepackage[T1]{fontenc}
usepackage[ngerman]{babel}
usepackage{hyphenat}
hyphenation{Mathe-matik wieder-gewinnen}
%----------------------------------------------------------------
usepackage{lipsum}
usepackage[pdftex]{graphicx} % Einbindung von Grafiken (pdf, png, jpg)
usepackage{float}            % bietet Option [H] für bombenfestes Verankern
usepackage[ngerman]{babel}   % Silbentrennung nach der neuen deutschen Rechtschreibung, z.B.: Sys-tem
usepackage{amstext}          % für Klartext via text{} in Formeln
usepackage{amsmath}
usepackage{amsfonts}
usepackage{csquotes}         % für komplexere Formeln (Mengensymbole ...)
usepackage{amssymb}          % für komplexere Formeln (Mengensymbole ...)
usepackage{pifont}% http://ctan.org/pkg/pifont
usepackage{bm}               % bold math, für bm{}
usepackage{enumerate}        % verbessert Aufzählungen
usepackage[bottom]{footmisc} % Fussnoten am Seitenende
usepackage{array}            % für Tabellen: bindet tabular-Umgebung ein
usepackage{algorithm}        % für Algorithmen
usepackage{algorithmic}      % für Algorithmen
usepackage{pdfpages}         % für die Einbindung kompletter pdf-*Seiten*
usepackage[right]{eurosym}   % Eurosymbol          % farbiger Text
usepackage[hyphens]{url}     % für url{http://www}, Option hyp erlaubt auch Umbruch nach "-"
usepackage{makeidx}          % Package zur Indexerstellung
usepackage{multicol}         % zur Indexerstellung in zwei Spalten
usepackage{wasysym}
usepackage{fancyhdr}
usepackage[style=authoryear-icomp, mergedate=basic]{biblatex}  ExecuteBibliographyOptions{firstinits=true,maxnames=2}

setlength{bibitemsep}{10pt}
setlength{bibhang}{1.2cm}

DeclareNameAlias{sortname}{last-first}

AtBeginBibliography{%
  renewcommand*{multinamedelim}{addsemicolonspace}%
  renewcommand*{finalnamedelim}{addsemicolonspace}%
}

DefineBibliographyStrings{ngerman}{%
  andothers = {etaddspace aladddotspace},%
  andmore = {etaddspace aladddotspace},%
}

usepackage{xpatch}
xpretobibmacro{author}{mkbibboldbgroup}{}{}
xapptobibmacro{author}{egroup}{}{}
xpretobibmacro{bbx:editor}{mkbibboldbgroup}{}{}
xapptobibmacro{bbx:editor}{egroup}{}{}

renewcommand*{labelnamepunct}{mkbibbold{addcolonspace}}

addbibresource{Dissertation.bib}  
usepackage{nomencl}
usepackage{longtable}
usepackage{bussproofs}
usepackage{stackrel}
usepackage{wasysym}
usepackage{epigraph}
usepackage[linktocpage ]{hyperref}
pagestyle{fancy}
usepackage[toc,page]{appendix}

usepackage{tikz}
usepackage{tkz-euclide}
usepackage{amsthm}
usepackage{wrapfig}
theoremstyle{definition}
newtheorem{theorem}{Theorem}[section]
newtheorem{definition}{Definition}[section]

renewcommand{headrulewidth}{0.4pt} % Headerlinie setzen
renewcommand{footrulewidth}{0.4pt} % Footerlinie setzen
fancyhf{}
fancyhead[RO]{scshape nouppercase rightmark}
fancyhead[LE]{scshape nouppercase leftmark}
fancyfoot[RO,LE]{thepage} 

usetikzlibrary{cd, shapes.geometric}

newcommand*pent[1]{tikz[baseline=(char.base)]{
            node[shape=regular polygon,draw,inner sep=1pt] (char) {#1};}}

setlength{epigraphwidth}{.8textwidth}
newcommand{cmark}{ding{51}}%
newcommand{xmark}{ding{53}}%

renewcommand{indexname}{Personen- und Sachverzeichnis}

The code is

begin{tikzcd}
X arrow{r}[name=A, description]{pi} & X/_{sim}  
V arrow{r}[name=B, description]{pi} & V/_{sim} arrow[Leftrightarrow,to path=(A) -- (B)]{}
end{tikzcd}

Any ideas?

3 Answers

As egreg noted, the problem seems to be how to draw the "S" inside a pentagon. Another solution, that is easily generalizable to other shapes is with tikz library shapes.geometric as in the following example

documentclass{article}

usepackage{tikz}
usetikzlibrary{cd, shapes.geometric}

newcommand*pent[1]{tikz[baseline=(char.base)]{
            node[shape=regular polygon,draw,inner sep=1pt] (char) {#1};}}

begin{document}

begin{tikzcd}
X arrow{r}[name=A, description]{pi} & X/_{sim}  
V arrow{r}[name=B, description]{pi} & V/_{sim} 
arrow[Leftrightarrow,from=A,to=B,"pent{S}"description]
end{tikzcd}
end{document}

Correct answer by Luis Turcio on June 29, 2021

The only problem seems to draw the pentagon with the inscribed letter.

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

newcommand{Penta}[1]{%
  mbox{%
    vphantom{largepentagon}%
    ooalign{%
      largepentagoncr
      hidewidthraisebox{0.3ex}{$scriptscriptstyle #1$}hidewidthcr}%
  }%
}

begin{document}

[
begin{tikzcd}
Xarrow[r, "pi" description, ""{name=top, below}] & X/{sim}
Varrow[r, "pi" description, ""{name=bottom, above}] & V/{sim}
arrow[Leftrightarrow, from=top, to=bottom, "Penta{S}" description]
end{tikzcd}
]

end{document}

enter image description here

Code for the vertical arrow taken from the now deleted answer by Sandy G

Answered by egreg on June 29, 2021

Similar to Luis Turcio's answer but avoiding to nest tikzpictures. You can just pass a list of options, such as the shape and so on, to the edge label.

arrow[Leftrightarrow,from=A,to=B,
    "S"{description,regular polygon,draw=white,double=black,double distance=0.4pt,inner sep=1pt}]

enter image description here

documentclass{article}

usepackage{tikz}
usetikzlibrary{cd, shapes.geometric}

begin{document}

begin{tikzcd}
X arrow{r}[name=A, description]{pi} & X/_{sim}  
V arrow{r}[name=B, description]{pi} & V/_{sim} 
arrow[Leftrightarrow,from=A,to=B,
    "S"{description,regular polygon,draw=white,double=black,double distance=0.4pt,inner sep=1pt}]
end{tikzcd}
end{document}

Answered by user234180 on June 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP