答案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}