2

I want to create an overview of definitions/theorems using a graph. As you can see the "Def" and "Thm 38" labels from (b) to (a) are not on the path. How can I fix this. Any other improvements would also be welcome.

\documentclass[tikz, border=20]{standalone}

\usepackage{contour}

\pgfdeclarelayer{foreground}
\pgfsetlayers{main,foreground}

\pgfmathsetmacro{\R}{7}

\contourlength{1.2pt}
\begin{document}
    \begin{tikzpicture}
        \tikzset{note/.style={draw, circle, minimum size=2cm, align=center, font=\sffamily\small}}
        \tikzset{edge/.style={->, >=latex, thick}}
        \tikzset{textcontour/.style={midway, sloped, font=\sffamily\footnotesize}}

        \node[note] (a) at (-30:\R) {Rewrite\\basis};
        \node[note] (b) at (-150:\R) {Prebasis};
        \node[note] (c) at (-210:\R) {Signature\\basis};
        \node[note] (d) at (-270:\R) {Pivot\\basis};
        \node[note] (e) at (-330:\R) {Gröbner\\basis};
        
        \draw[edge] (d) -- (e) node[textcontour] {\contour{white}{Def}};
        \draw[edge] (d) -- (c) node[textcontour] {\contour{white}{Def}};
        \draw[edge] (c) -- (e) node[textcontour] {\contour{white}{Lemma 18 ($\natural$)}};

        \draw[edge, bend right=20] (b) to (a) node[textcontour, above] {\contour{white}{Def}};
        \draw[edge, bend left=20] (b) to (a) node[textcontour, below] {\contour{white}{Thm 38}};

        \draw[edge] (a) -- (c) node[textcontour] {\contour{white}{Cor 31}};
        \draw[edge] (b) -- (c) node[textcontour] {\contour{white}{Prop 40}};

    \end{tikzpicture}
\end{document}

The graph currently looks like this. enter image description here

1 Answer 1

3

As pure tikz picture:

\documentclass[border=20]{standalone}

\usepackage{tikz}
\usetikzlibrary{arrows.meta,    % for arrows
                quotes}         % for edge labels

\pgfmathsetmacro{\R}{7}
\begin{document}
    \begin{tikzpicture}[
      note/.style = {circle,  draw,  minimum size=17mm, align=center, font=\sffamily\small},
every edge/.style = {-Latex, draw, thick},
every edge quotes/.append style = {fill=white, font=\footnotesize, anchor=center},
                        ]
    \begin{scope}[nodes=note]
\node (a) at (-30:\R)  {Rewrite\\basis};
\node (b) at (-150:\R) {Prebasis};
\node (c) at (-210:\R) {Signature\\basis};
\node (d) at (-270:\R) {Pivot\\basis};
\node (e) at (-330:\R) {Gröbner\\basis};
    \end{scope}
\draw   (d) edge ["Def"] (e)
        (d) edge ["Def"] (c)
        (c) edge ["$\natural$)"] (e)
%
        (b) edge ["Def",    bend right=20]  (a)
        (b) edge ["Thm 38", bend  left=20]  (a) 
%
        (a) edge ["Cor 31"] (c) 
        (b) edge ["Prop 40"] (c);
    \end{tikzpicture}
\end{document}

As you can see, code is shorter, to my opinion more consistent and gives desired result.

enter image description here Addendum:
I the case when you like to have aligned edge labels with edge, that you need to add instruction sloped do every edge quotes style definition. For example (using smaller \R:

\documentclass[border=20]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,    % for arrows
                quotes}         % for edge labels

\pgfmathsetmacro{\R}{7}
\begin{document}
    \begin{tikzpicture}[
      note/.style = {circle,  draw,  minimum size=17mm, align=center, font=\sffamily\small},
every edge/.style = {-Latex, draw, thick},
every edge quotes/.append style = {fill=white, font=\footnotesize, 
                                   anchor=center, sloped}, % <---
                        ]
    \begin{scope}[nodes=note]
\node (a) at (-30:\R)  {Rewrite\\basis};
\node (b) at (-150:\R) {Prebasis};
\node (c) at (-210:\R) {Signature\\basis};
\node (d) at (-270:\R) {Pivot\\basis};
\node (e) at (-330:\R) {Gröbner\\basis};
    \end{scope}
\draw   (d) edge ["Def"] (e)
        (d) edge ["Def"] (c)
        (c) edge ["$\natural$)"] (e)
%
        (b) edge ["Def",    bend right=20]  (a)
        (b) edge ["Thm 38", bend  left=20]  (a) 
%
        (a) edge ["Cor 31"] (c) 
        (b) edge ["Prop 40"] (c);
    \end{tikzpicture}
\end{document}

enter image description here

2
  • Thank you so much!
    – HelloWorld
    Commented May 27 at 15:00
  • 1
    @HelloWorld, you are welcome. Now I have added also a solution where edges' labels are aligned with them.
    – Zarko
    Commented May 27 at 17:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .