使用 LaTeX 制作一个实时时钟

2019-09-01 19:36发布

今天看了tikz的一些知识,顺便做一个实时时钟,主要用到的宏包是tikz和time两个宏包,编译出可以显示现在的时间和日期,刚学tikz,请各位大神指点一下代码部分有什么改进的地方效果图如下代码如下\...

今天看了tikz的一些知识,顺便做一个实时时钟,主要用到的宏包是tikz和time两个宏包,编译出可以显示现在的时间和日期,刚学tikz,请各位大神指点一下代码部分有什么改进的地方

效果图如下

10.png

代码如下

\documentclass[border=0mm]{standalone}
\usepackage{ctex}
\usepackage{tikz}
\usepackage{time}
\begin{document}
\newcommand{\mytime}{\the\time}

\begin{tikzpicture}[domain=-2:2]
\draw (0,0) circle (2cm);
\fill (0,0) circle (.7mm);  
\draw[->] (0,0) -- (90-\mytime*6:1.5);  %minute
\draw[->>] (0,0) -- (90-\mytime/2:1);  %hour
\node[red,below = 8mm] at (0,0) {\small\now};
\node[above = 8mm] at (0,0) {\tiny \TeX 白兔};
\node[red,below = 2cm] at (0,0) {\small \today};

%%%%%%%%%1-12%%%%%%%%%%%%%
\node at (90:1.8) {12};
\node at (60:1.8) {1};
\node at (30:1.8) {2};
\node at (0:1.8) {3};
\node at (-30:1.8) {4};
\node at (-60:1.8) {5};
\node at (-90:1.8) {6};
\node at (-120:1.8) {7};
\node at (-150:1.8) {8};
\node at (-180:1.8) {9};
\node at (-210:1.8) {10};
\node at (-240:1.8) {11};

%%%%%%%%%%%大节点%%%%%%%%%%%%%%%%%%%
\node at (90:2cm-1pt) {\rotatebox{0}{\rule{.8pt}{2pt}}};
\node at (60:2cm-1pt) {\rotatebox{-30}{\rule{.8pt}{2pt}}};
\node at (30:2cm-1pt) {\rotatebox{-60}{\rule{.8pt}{2pt}}};
\node at (0:2cm-1pt) {\rotatebox{-90}{\rule{.8pt}{2pt}}};
\node at (-30:2cm-1pt) {\rotatebox{-120}{\rule{.8pt}{2pt}}};
\node at (-60:2cm-1pt) {\rotatebox{-150}{\rule{.8pt}{2pt}}};
\node at (-90:2cm-1pt) {\rotatebox{-180}{\rule{.8pt}{2pt}}};
\node at (-120:2cm-1pt) {\rotatebox{-210}{\rule{.8pt}{2pt}}};
\node at (-150:2cm-1pt) {\rotatebox{-240}{\rule{.8pt}{2pt}}};
\node at (-180:2cm-1pt) {\rotatebox{-270}{\rule{.8pt}{2pt}}};
\node at (-210:2cm-1pt) {\rotatebox{-300}{\rule{.8pt}{2pt}}};
\node at (-240:2cm-1pt) {\rotatebox{-330}{\rule{.8pt}{2pt}}};

%%%%%%%%%%%%%%%%%%%%%%%%小节点%%%%%%%%%%%%%%%%%%%%%%%%%%%
\node at (90-6*1:2cm-0.5pt) {\rotatebox{-6}{\rule{.4pt}{1pt}}};
\node at (90-6*2:2cm-0.5pt) {\rotatebox{-12}{\rule{.4pt}{1pt}}};
\node at (90-6*3:2cm-0.5pt) {\rotatebox{-18}{\rule{.4pt}{1pt}}};
\node at (90-6*4:2cm-0.5pt) {\rotatebox{-24}{\rule{.4pt}{1pt}}};
\node at (90-6*5:2cm-0.5pt) {\rotatebox{-30}{\rule{.4pt}{1pt}}};
\node at (90-6*6:2cm-0.5pt) {\rotatebox{-36}{\rule{.4pt}{1pt}}};
\node at (90-6*7:2cm-0.5pt) {\rotatebox{-42}{\rule{.4pt}{1pt}}};
\node at (90-6*8:2cm-0.5pt) {\rotatebox{-48}{\rule{.4pt}{1pt}}};
\node at (90-6*9:2cm-0.5pt) {\rotatebox{-54}{\rule{.4pt}{1pt}}};
\node at (90-6*10:2cm-0.5pt) {\rotatebox{-60}{\rule{.4pt}{1pt}}};
\node at (90-6*11:2cm-0.5pt) {\rotatebox{-66}{\rule{.4pt}{1pt}}};
\node at (90-6*12:2cm-0.5pt) {\rotatebox{-72}{\rule{.4pt}{1pt}}};
\node at (90-6*13:2cm-0.5pt) {\rotatebox{-78}{\rule{.4pt}{1pt}}};
\node at (90-6*14:2cm-0.5pt) {\rotatebox{-84}{\rule{.4pt}{1pt}}};
\node at (90-6*15:2cm-0.5pt) {\rotatebox{-90}{\rule{.4pt}{1pt}}};
\node at (90-6*16:2cm-0.5pt) {\rotatebox{-96}{\rule{.4pt}{1pt}}};
\node at (90-6*17:2cm-0.5pt) {\rotatebox{-102}{\rule{.4pt}{1pt}}};
\node at (90-6*18:2cm-0.5pt) {\rotatebox{-108}{\rule{.4pt}{1pt}}};
\node at (90-6*19:2cm-0.5pt) {\rotatebox{-114}{\rule{.4pt}{1pt}}};
\node at (90-6*20:2cm-0.5pt) {\rotatebox{-120}{\rule{.4pt}{1pt}}};
\node at (90-6*21:2cm-0.5pt) {\rotatebox{-126}{\rule{.4pt}{1pt}}};
\node at (90-6*22:2cm-0.5pt) {\rotatebox{-132}{\rule{.4pt}{1pt}}};
\node at (90-6*23:2cm-0.5pt) {\rotatebox{-138}{\rule{.4pt}{1pt}}};
\node at (90-6*24:2cm-0.5pt) {\rotatebox{-144}{\rule{.4pt}{1pt}}};
\node at (90-6*25:2cm-0.5pt) {\rotatebox{-150}{\rule{.4pt}{1pt}}};
\node at (90-6*26:2cm-0.5pt) {\rotatebox{-156}{\rule{.4pt}{1pt}}};
\node at (90-6*27:2cm-0.5pt) {\rotatebox{-162}{\rule{.4pt}{1pt}}};
\node at (90-6*28:2cm-0.5pt) {\rotatebox{-168}{\rule{.4pt}{1pt}}};
\node at (90-6*29:2cm-0.5pt) {\rotatebox{-174}{\rule{.4pt}{1pt}}};
\node at (90-6*30:2cm-0.5pt) {\rotatebox{-180}{\rule{.4pt}{1pt}}};
\node at (90-6*31:2cm-0.5pt) {\rotatebox{-186}{\rule{.4pt}{1pt}}};
\node at (90-6*32:2cm-0.5pt) {\rotatebox{-192}{\rule{.4pt}{1pt}}};
\node at (90-6*33:2cm-0.5pt) {\rotatebox{-198}{\rule{.4pt}{1pt}}};
\node at (90-6*34:2cm-0.5pt) {\rotatebox{-204}{\rule{.4pt}{1pt}}};
\node at (90-6*35:2cm-0.5pt) {\rotatebox{-210}{\rule{.4pt}{1pt}}};
\node at (90-6*36:2cm-0.5pt) {\rotatebox{-216}{\rule{.4pt}{1pt}}};
\node at (90-6*37:2cm-0.5pt) {\rotatebox{-222}{\rule{.4pt}{1pt}}};
\node at (90-6*38:2cm-0.5pt) {\rotatebox{-228}{\rule{.4pt}{1pt}}};
\node at (90-6*39:2cm-0.5pt) {\rotatebox{-234}{\rule{.4pt}{1pt}}};
\node at (90-6*40:2cm-0.5pt) {\rotatebox{-240}{\rule{.4pt}{1pt}}};
\node at (90-6*41:2cm-0.5pt) {\rotatebox{-246}{\rule{.4pt}{1pt}}};
\node at (90-6*42:2cm-0.5pt) {\rotatebox{-252}{\rule{.4pt}{1pt}}};
\node at (90-6*43:2cm-0.5pt) {\rotatebox{-258}{\rule{.4pt}{1pt}}};
\node at (90-6*44:2cm-0.5pt) {\rotatebox{-264}{\rule{.4pt}{1pt}}};
\node at (90-6*45:2cm-0.5pt) {\rotatebox{-270}{\rule{.4pt}{1pt}}};
\node at (90-6*46:2cm-0.5pt) {\rotatebox{-276}{\rule{.4pt}{1pt}}};
\node at (90-6*47:2cm-0.5pt) {\rotatebox{-282}{\rule{.4pt}{1pt}}};
\node at (90-6*48:2cm-0.5pt) {\rotatebox{-288}{\rule{.4pt}{1pt}}};
\node at (90-6*49:2cm-0.5pt) {\rotatebox{-294}{\rule{.4pt}{1pt}}};
\node at (90-6*50:2cm-0.5pt) {\rotatebox{-300}{\rule{.4pt}{1pt}}};
\node at (90-6*51:2cm-0.5pt) {\rotatebox{-306}{\rule{.4pt}{1pt}}};
\node at (90-6*52:2cm-0.5pt) {\rotatebox{-312}{\rule{.4pt}{1pt}}};
\node at (90-6*53:2cm-0.5pt) {\rotatebox{-318}{\rule{.4pt}{1pt}}};
\node at (90-6*54:2cm-0.5pt) {\rotatebox{-324}{\rule{.4pt}{1pt}}};
\node at (90-6*55:2cm-0.5pt) {\rotatebox{-330}{\rule{.4pt}{1pt}}};
\node at (90-6*56:2cm-0.5pt) {\rotatebox{-336}{\rule{.4pt}{1pt}}};
\node at (90-6*57:2cm-0.5pt) {\rotatebox{-342}{\rule{.4pt}{1pt}}};
\node at (90-6*58:2cm-0.5pt) {\rotatebox{-348}{\rule{.4pt}{1pt}}};
\node at (90-6*59:2cm-0.5pt) {\rotatebox{-354}{\rule{.4pt}{1pt}}};
\node at (90-6*60:2cm-0.5pt) {\rotatebox{-360}{\rule{.4pt}{1pt}}};

\end{tikzpicture}
\end{document}