我想将数学公式绕圆圈弯曲。虽然 LaTeX 处理文本,但它不会将数学环境中的公式绕圆圈弯曲,至少我没有成功过。我为测试编写了以下代码:
\documentclass[convert={density=300,size=1080x800,outext=.png}]{standalone}
\usepackage{fontspec}
\usepackage{amssymb}
\usepackage{unicode-math}
\usepackage{xfrac}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{decorations.text,fit,chains,calc,shapes.geometric,intersections}
\usepackage[margin=15mm]{geometry}
\begin{document}
\begin{tikzpicture}
\begin{scope}[shift={(0cm,0cm)}, fill opacity=0.5, mytext/.style={text opacity=1,font=\large\bfseries}]
% Kreise
\draw[fill=red, draw = black] (0,0) circle (5); % Complex Numbers
\draw[fill=blue!10, draw = black,name path=circle 2] (0,0) circle (4.2); % Imaginary Numbers
\end{scope}
\draw [ draw opacity=0.1, rotate=120,
postaction={decorate, decoration={raise=-1ex,text along path,reverse path,text align={fit to path stretching spaces},
text={|\ttfamily\huge\color{blue}|Outer\space Space \space}}}] (0,0) circle (4.6cm);
\draw [draw opacity=0.1, rotate=180,
postaction={ decorate, decoration={raise=-1ex,text along path,reverse path,text align={fit to path stretching spaces},
text={|\ttfamily\huge\color{green}|Inner\space Space \space}}}] (0,0) circle (3.8cm);
\node at (4,0) (N) {\tiny 1,2,3,4};
\node[rotate=90] at (-3,1) (N) {$y(n)=h_0x(n)+h_1x(n-1)+\dots +h_{N-1}x(n-N+1)=\sum_{k=0}^{N-1}h_kx(n-k)$};
\end{tikzpicture}
\end{document}
答案1
来自手册!
• 只有在相当严格的限制下,才能在数学模式下排版文本。使用类别代码为 3 的任何字符(例如,在纯 TEX 中为 $)进入和退出数学模式。数学下标和上标需要包含在括号内(例如,{^y_i}),\times 或 \cdot 等命令也是如此。但是,即使是适度复杂的数学排版也不太可能沿着路径成功(甚至不可取)。
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\begin{document}
\begin{tikzpicture}[decoration={text along path, text={$\ \ \ y(n)={h_0}x(n)+{h_1}x(n-1)+{\ldots} +{h_{N-1}}x(n-N+1)={\sum_{k=0}^{N-1}}{h_kx(n-k)}$}}]
\path [decorate]
(0,0) .. controls (0,6) and (9,6) .. (9,0);
\end{tikzpicture}
\end{document}
更新
\documentclass[margin=1cm]{standalone}
\usepackage{fontspec}
\usepackage{amssymb}
\usepackage{unicode-math}
\usepackage{xfrac}
\usepackage{tikz}
\usepackage{calc}
\usetikzlibrary{decorations.text,fit,chains,calc,shapes.geometric,intersections}
\begin{document}
\begin{tikzpicture}[
disk 1/.style={fill=red, draw = black},
disk 2/.style={fill=blue!10, draw = black,name path=circle 2},
disk 3/.style={
rotate = -90,
postaction = %
{decorate,
decoration={raise = -1ex,
text along path,
reverse path,
text align = {fit to path stretching spaces},
text = {|\ttfamily\huge\color{blue}|
Outer\space Space \space}}}},
disk 4/.style={
draw opacity=0.1,
rotate=15,
postaction={decorate,
decoration={
raise=-1ex,
text along path,
reverse path,
text align={fit to path stretching spaces},
text={%
|\color{red}| $y(n)={h_0}x(n)+{h_1}x(n-1)+{\cdots}+%
{h_{N-1}}x(n-N+1)={\sum_{k=0}^{N-1}}{h_k}x(n-k)$ }
}
}
}
]
\begin{scope}[ mytext/.style={text opacity=1,
font=\large\bfseries}]
% Disk 1
\draw[disk 1] (0,0) circle (5);
% Disk 2
\draw[disk 2] (0,0) circle (4.2);
\end{scope}
% Disk 3
\path[disk 3] (0,0) circle (4.6cm);
% Disk 4
\path[disk 4] (0,0) circle (3.8cm);
\end{tikzpicture}
\end{document}