答案1
关于如何将箭头置于中间位置的信息可以在本网站的几篇帖子中找到。然而,由于曲率的原因,这些帖子通常会错过此处所需的箭头的精确定位,因此再次。以下代码的相关部分是
mark=at position 0.5 with {\arrow[xshift=2pt]{Latex[length=4pt]}}
具有以下元素。0.5
指定箭头尖的位置,可能在0
(路径起点)和1
(路径终点)之间变化。Latex
指定箭头的类型;有关库提供的选项,请参阅 tikz 手册arrows.meta
。[length=4pt]
指定箭头类型的详细信息,例如其长度;下面使用的其他选项是open
(获得轮廓箭头)和fill=white
(使箭头内部覆盖其下方的线)。[xshift=2pt]
指定有关箭头尖定位的详细信息;如果没有此选项,箭头将以其尖端定位,在弯曲的线上看起来位置错误。
\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}
回收一些想法另一篇帖子,您可以通过定义弧和线的“语言”来绘制图形。
% 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}