答案1
可以用来tikzmark
标记node
数学公式中的某些内容,例如这里。注意第一次运行需要编译两次才能正常[overlay,remember picture]
运行。
\documentclass{article}
\usepackage{tikz,amsmath}
\usetikzlibrary{tikzmark}
\usepackage{lipsum} % >>> for dummy text only
\begin{document}
\lipsum[1]
\vspace*{10mm} % a gap for tikzmark later. Change as you wish
\[(\,
\tikzmarknode{1}{1}
\tikzmarknode{5}{5}
\tikzmarknode{2}{2}\,)
_{\tikzmarknode{b6}{\color{cyan}6}}
\;=\;1\cdot
\tikzmarknode{62}{\color{magenta}6^2}+
5\cdot
\tikzmarknode{61}{\color{magenta}6^1}+
2\cdot
\tikzmarknode{60}{\color{magenta}6^0}
\]
\vspace*{10mm} % a gap for tikzmark later. Change as you wish
\begin{tikzpicture}[overlay,remember picture]
\path
(61)+(90:1) node[magenta] (Sw) {Stellenwerte}
(5) +(90:1) node[left] (Z) {Ziffern}
(5) +(-90:1) node[left] (S) {Stellen}
(b6|-S) node[right,cyan] (B) {Basis}
;
\foreach \i in {0,1,2}
\draw[magenta!50,shorten >=2pt] (Sw)--(6\i);
\draw[gray]
(1.north)+(90:2pt)--(Z)
(5.north)+(90:2pt)--(Z)
(2.north)+(90:2pt)--(Z)
(1.south)+(-90:2pt)--(S)
(5.south)+(-90:2pt)--(S)
(2.south)+(-90:2pt)--(S)
;
\draw[cyan,shorten <=2pt] (b6)--(B);
\draw[magenta,-stealth,shorten >=2pt] (B)--(B-|62)--(62);
\end{tikzpicture}
\lipsum[2]
\end{document}
不过还有一种方法:把所有东西都放在一个 中tikzpicture
,参数a
是b
用来控制水平间距的。我用beamer
,编译速度有点慢。
\documentclass{beamer}
\usepackage{tikz}
\begin{document}
\begin{frame}{A numeral system}
\begin{tikzpicture}[declare function={a=.45;b=1.6*a;},thick]
\path[nodes={scale=2.2}]
(0,0) node{$($}
++(0:1.2*a) node (1) {$1$}
++(0:a) node (5) {$5$}
++(0:a) node (2) {$2$}
++(0:1.2*a) node (p) {$)$}
++(0:2*a) node{$=$}
++(0:b) node{$1$}
++(0:a) node{$\cdot$}
++(0:b) node[orange,yshift=1.5pt] (62) {$6^2$}
++(0:b) node{$+$}
++(0:b) node{$5$}
++(0:a) node{$\cdot$}
++(0:b) node[orange,yshift=1.5pt] (61) {$6^1$}
++(0:b) node{$+$}
++(0:b) node{$2$}
++(0:a) node{$\cdot$}
++(0:b) node[orange,yshift=1.5pt] (60) {$6^0$}
;
\path[nodes={scale=1.5}]
(61)+(90:2) node[orange] (Sw) {Stellenwerte}
(5) +(90:2) node (Z) {Ziffern}
(5) +(-90:2) node (S) {Stellen}
(p) node[below right,teal,scale=.8] (b6) {$6$}
(b6|-S) node[right,teal] (B) {Basis}
;
\draw[orange!50] (Sw)--(61) (Sw)--(60) (Sw)--(62);
\draw[gray] (Z.-110)--(1) (Z)--(5) (Z.-70)--(2);
\draw[gray] (S.110)--(1) (S)--(5) (S.70)--(2);
\draw[teal] (B)--(b6);
\draw[orange,->] (B)--(B-|62)--(62);
\end{tikzpicture}
\end{frame}
\end{document}