我想在拱门上画一个箭头,但是尺寸听起来太大而且方向不正确!
\documentclass[tikz,convert={size=50x50,outfile=\jobname.gif}]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows}
\usetikzlibrary{calc}
\def\centerarc[#1](#2)(#3:#4:#5)% Syntax: [draw options] (center) (initial angle:final angle:radius)
{ \draw[#1] ($(#2)+({#5*cos(#3)},{#5*sin(#3)})$) arc (#3:#4:#5); }
\begin{document}
\begin{tikzpicture}[line width=4pt,>=triangle 60]
\def\r{0.35}
\draw[draw=black] (-1,-1) rectangle (1,1);
%\draw (0,0) circle (\r);
\centerarc[->,line cap=round](0,0)(330:30:\r)
\end{tikzpicture}
\end{document}
我知道尺寸太小了!我希望将其用作图标。
答案1
arrows
据说该库将被取代的原因有很多arrows.meta
,这是其中之一。在我看来,在这个小圆弧上添加这么大的箭头最优雅的方式就是弯曲它。
\documentclass[tikz,convert={size=50x50,outfile=\jobname.gif}]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,bending}
\usetikzlibrary{calc}
\def\centerarc[#1](#2)(#3:#4:#5)% Syntax: [draw options] (center) (initial angle:final angle:radius)
{ \draw[#1] ($(#2)+(#3:#5)$) arc (#3:#4:#5); }
\begin{document}
\begin{tikzpicture}[line width=4pt,>={Triangle[bend]}]
\def\r{0.35}
\draw[draw=black] (-1,-1) rectangle (1,1);
%\draw (0,0) circle (\r);
\centerarc[->,line cap=round](0,0)(330:30:\r)
\end{tikzpicture}
\end{document}
如果我要将其设为图标,我可能会使用稍微小一点的箭头。
\documentclass[tikz,convert={size=50x50,outfile=\jobname.gif}]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,bending}
\usetikzlibrary{calc}
\def\centerarc[#1](#2)(#3:#4:#5)% Syntax: [draw options] (center) (initial angle:final angle:radius)
{ \draw[#1] ($(#2)+(#3:#5)$) arc (#3:#4:#5); }
\begin{document}
\begin{tikzpicture}[line width=4pt,>={Triangle[bend,length=10pt,width=10pt]}]
\def\r{0.35}
\draw[draw=black] (-1,-1) rectangle (1,1);
%\draw (0,0) circle (\r);
\centerarc[->,line cap=round](0,0)(330:30:\r)
\end{tikzpicture}
\end{document}
答案2
自定义箭头提示也许可以解决这个问题,但需要根据具体情况手动调整 y 偏移和旋转角度!
\documentclass[tikz,convert={size=50x50,outfile=\jobname.gif}]{standalone}
\usepackage{tikz}
\usetikzlibrary{arrows.meta,bending}
\usetikzlibrary{calc}
\def\centerarc[#1](#2)(#3:#4:#5) {\draw[#1] (#2)++(#3:#5) arc (#3:#4:#5); }
\pgfarrowsdeclare{myarr}{myarr}% My arrow tip
{ \pgfarrowsleftextend{-2\pgflinewidth}
\pgfarrowsrightextend{2\pgflinewidth}}
{\pgftransformrotate{-40}%angle
%\pgftransformxshift{1\pgflinewidth}
\pgftransformyshift{\pgflinewidth}
\pgfpathmoveto{\pgfpoint{2\pgflinewidth}{0\pgflinewidth}} %A
\pgfpathlineto{\pgfpoint{0\pgflinewidth}{1.5\pgflinewidth}} %B
\pgfpathlineto{\pgfpoint{0\pgflinewidth}{-1.5\pgflinewidth}} %C
\pgfpathclose
\pgfusepathqfill}
\begin{document}
\begin{tikzpicture}[line width=4pt,>=myarr]
\def\r{0.35}
\draw[draw=black] (-1,-1) rectangle (1,1);
\centerarc[->,line cap=round](0,0)(330:30:\r)
\end{tikzpicture}
\end{document}