我已经用过这个堆栈交换信息构建以下 MWE:
\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usepackage{geometry}
\usetikzlibrary{positioning,calc}
\geometry{papersize={20mm, 40mm}}
\def\centerarc[#1](#2)(#3:#4:#5)
{ \draw[#1] ($(#2)+({#5*cos(#3)},{#5*sin(#3)})$) arc (#3:#4:#5); }
\newcommand\lw{0.2mm}
\newcommand\dial[2]{
\begin{tikzpicture}[remember picture,overlay]
\centerarc[fill=none,draw=black,line width=\lw]($(current page.south west)+(#1,#2)$)(-60:240:8mm)
\end{tikzpicture}
}
\begin{document}
\dial{10.0mm}{20.0mm}
\end{document}
结果我得到了这个:
我如何才能将表盘改变成这样的刻度线呢?
上述表盘的解决方案已经对我有很大帮助。
如果代码能够灵活地在每个刻度线上放置文本(比如数字 0 到 10),或者为音量旋钮定制一些内容,那么就真的很酷了,如下所示:
答案1
像这样?
\documentclass{article}
\pagestyle{empty}
\usepackage{tikz}
\usepackage{geometry}
\usetikzlibrary{positioning,calc,intersections}
\geometry{papersize={20mm, 40mm}}
\def\centerarc[#1](#2)(#3:#4:#5)
{ \draw[#1] ($(#2)+({#5*cos(#3)},{#5*sin(#3)})$) arc (#3:#4:#5); }
\newcommand\lw{0.2mm}
\newcommand\dial[2]{
\begin{tikzpicture}[remember picture,overlay]
\centerarc[name path=arcc,fill=none,draw=black,line width=\lw]($(current page.south west)+(#1,#2)$)(-60:240:8mm)
\foreach \t [count=\i from 0] in {-60,-30,...,240}{
\path [name path=\t]($(current page.south west)+(#1,#2)$)--++(\t:8.2mm);
\path [name intersections={of=arcc and \t,by={\t1}}];
\draw [line cap=round, line width=\lw](\t1)--++(\t:0.5mm);
\path (\t1)--++(\t:1.5mm)node{\scalebox{0.5}{$\i$}};
}
\end{tikzpicture}
}
\begin{document}
\dial{10.0mm}{20.0mm}
\end{document}