1

I want to use tikz to draw the following picture:enter image description here

. Is there any good way to add the arrow like that and how can we draw a circle from start point to end point.

1
  • 1
    Welcome to TeX.SX! On this site, a question should typically revolve around an abstract issue (e.g. "How do I get a double horizontal line in a table?") rather than a concrete application (e.g. "How do I make this table?"). Questions that look like "Please do this complicated thing for me" tend to get closed because they are either "off topic", "too broad", or "unclear". Please try to make your question clear and simple by giving a minimal working example (MWE): you'll stand a greater chance of getting help. Commented Apr 18, 2017 at 22:05

1 Answer 1

5

The information on how to place arrow tips midway can be found in several postings on this site. However, these usually miss the fine positioning of the arrow needed here because of the curvature, hence once more. The relevant part of the code below is

mark=at position 0.5 with {\arrow[xshift=2pt]{Latex[length=4pt]}}

with the following elements. 0.5 specifies the position of the arrow tip and may vary between 0 (start of path) and 1 (end of path). Latex specifies the type of arrow; see the tikz manual for the options offered by the library arrows.meta. [length=4pt] specifies details of the arrow type like its length; other options used below are open (to obtain an outlined arrow) and fill=white (to make the interior of the arrow cover the line below it). [xshift=2pt] specifies details regarding the positioning of the arrow tip; without this option the arrow is positioned with its tip, which looks misplaced on bent lines.

\documentclass[border=2mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{decorations.markings,arrows.meta}
\tikzset
  {midarrow/.style={decoration={markings,mark=at position 0.5 with
     {\arrow[xshift=2pt]{Latex[length=4pt,#1]}}},postaction={decorate}}
  }
\begin{document}
\begin{tikzpicture}
  \draw[midarrow] (0,0) -- (1,0);
  \draw[midarrow={open,fill=white}] (0,0) arc(-90:180:10pt);
\end{tikzpicture}
\end{document}

enter image description here


Recycling some ideas from another post, you can draw the graphs by defining a "language" of arcs and lines.

enter image description here

% arcs and lines
\documentclass{article}
\usepackage[margin=1.5cm]{geometry}
\pagestyle{empty}

\usepackage{tikz}
\usetikzlibrary{decorations.markings,arrows.meta}

\newcommand\ALloop[1]%
  {\ifx\relax#1%
   \else
     \ifcsname AL:#1\endcsname
       \csname AL:#1\endcsname
     \else
       \GenericError{(AL)}{AL Error: operator #1 undefined}{}{}%
     \fi
   \expandafter\ALloop
   \fi
  }

\newcommand\AL[1]%
  {\begin{tikzpicture}[thick,every node/.style={blob}]
   \coordinate(X) at (0,0);
   \ALloop#1\relax
   \end{tikzpicture}
  }

\def\ALs{12}% small radius
\pgfmathsetmacro\ALm{1.5*\ALs}% medium radius
\pgfmathsetmacro\ALl{2.25*\ALs}% large radius
\pgfmathsetmacro\ALh{3*\ALs}% huge radius
\pgfmathsetmacro\ALt{sqrt(3)*\ALh}% side of triangle
\pgfmathsetmacro\ALa{0.75*\ALs}% length of arrow
\pgfmathsetmacro\ALn{0.4*\ALs}% size of node

\tikzset
  {midarrow/.style={decoration={markings,mark=at position 0.5 with
     {\arrow[xshift=0.5*\ALa]{Latex[length=\ALa pt,#1]}}},postaction={decorate}},
   full/.style={midarrow},
   open/.style={midarrow={open,fill=white}},
   blob/.style={circle,draw,fill,minimum size=\ALn pt,inner sep=0pt,outer sep=0pt}
  }

\newcommand\arrowtype{full}
% \ARC{start angle}{delta angle clockwise}{radius}
\newcommand\ARC [3]{\draw[\arrowtype] (X) arc(#1:#1-#2:#3) node{} coordinate (X);}
% \LINE{angle}{length}
\newcommand\LINE[2]{\draw[\arrowtype] (X) -- +(#1:#2) coordinate (X);}

\newcommand\ALdef[1]{\expandafter\def\csname AL:#1\endcsname}
\ALdef{a}{\ARC{ 30}{360}{\ALs pt}}
\ALdef{b}{\ARC{150}{360}{\ALs pt}}
\ALdef{c}{\ARC{270}{360}{\ALs pt}}
\ALdef{d}{\ARC{  0}{360}{\ALm pt}}
\ALdef{e}{\ARC{180}{360}{\ALm pt}}
\ALdef{f}{\ARC{  0}{180}{\ALl pt}}
\ALdef{g}{\ARC{180}{180}{\ALl pt}}
\ALdef{h}{\ARC{ 30}{120}{\ALh pt}}
\ALdef{i}{\ARC{150}{120}{\ALh pt}}
\ALdef{j}{\ARC{270}{120}{\ALh pt}}
\ALdef{k}{\ARC{210}{-120}{\ALh pt}}
\ALdef{0}{\LINE{  0}{\ALt pt}}
\ALdef{1}{\LINE{ 60}{\ALt pt}}
\ALdef{2}{\LINE{120}{\ALt pt}}
\ALdef{3}{\LINE{180}{\ALt pt}}
\ALdef{4}{\LINE{240}{\ALt pt}}
\ALdef{5}{\LINE{300}{\ALt pt}}
\ALdef{F}{\def\arrowtype{full}}
\ALdef{O}{\def\arrowtype{open}}

\begin{document}
\renewcommand\arraystretch{5}
\section*{The operators}

\begin{tabular}[t]{ll}
\verb"\AL{a}" & \AL{a}\\
\verb"\AL{b}" & \AL{b}\\
\verb"\AL{c}" & \AL{c}\\
\verb"\AL{d}" & \AL{d}\\
\verb"\AL{e}" & \AL{e}\\
\verb"\AL{f}" & \AL{f}\\
\verb"\AL{g}" & \AL{g}\\
\verb"\AL{h}" & \AL{h}\\
\verb"\AL{i}" & \AL{i}\\
\verb"\AL{j}" & \AL{j}\\
\verb"\AL{k}" & \AL{k}
\end{tabular}
\quad
\begin{tabular}[t]{ll}
\verb"\AL{0}" & \AL{0}\\
\verb"\AL{1}" & \AL{1}\\
\verb"\AL{2}" & \AL{2}\\
\verb"\AL{3}" & \AL{3}\\
\verb"\AL{4}" & \AL{4}\\
\verb"\AL{5}" & \AL{5}\\
\verb"\AL{F}" & switch to full arrows\\
\verb"\AL{O}" & switch to open arrows
\end{tabular}

\newpage
\section*{Examples}

\begin{tabular}{ll}
\verb"\AL{OdFgOgFeOfFf}" &
\AL{OdFgOgFeOfFf} \\
\verb"\AL{OjihF204}" &
\AL{OjihF204} \\
\verb"\AL{OjihF135}" &
\AL{OjihF135} \\
\verb"\AL{FjObFiOaFhOc}" &
\AL{FjObFiOaFhOc} \\
\verb"\AL{OjFbOiFaOhFc}" &
\AL{OjFbOiFaOhFc} \\
\verb"\AL{OjiF3kOhFc}" &
\AL{OjiF3kOhFc} \\
\verb"\AL{FjiO3kFhOc}" &
\AL{FjiO3kFhOc}
\end{tabular}
\end{document}

You must log in to answer this question.

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