![数学与文字的结合](https://linux22.com/image/261418/%E6%95%B0%E5%AD%A6%E4%B8%8E%E6%96%87%E5%AD%97%E7%9A%84%E7%BB%93%E5%90%88.png)
https://tex.stackexchange.com/a/88762/17049提供了一个漂亮的解决方案来获得如下螺旋:
我一直试图将它用于一些混合文本/数学内容(用于书籍封面),但我发现即使是很小的摘录,pdflatex 也会继续运行而不会终止。[使用完整核心至少 10 分钟。] 我做的唯一更改是替换
Lorem ipsum ...
在链接答案中的代码中If $K \leq G$ and there are inclusions $gKg^-1\leq K$ for every $g\in G$, ... .
有没有什么方法可以获得混合文本/数学内容的螺旋,通过修改链接答案或其他方式?
梅威瑟:
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations.text}
\makeatletter
\let\pgf@lib@dec@text@dobox@original=\pgf@lib@dec@text@dobox%
\def\pgf@lib@dec@text@dobox{%
\pgf@lib@dec@text@dobox@original%
\ifpgfdecorationtextalongpathscaletext%
\pgfmathparse{\pgf@lib@dec@text@endscale+(\pgf@lib@dec@text@startscale-\pgf@lib@dec@text@endscale)*\pgfdecoratedremainingdistance/\pgfdecoratedpathlength}%
\setbox\pgf@lib@dec@text@box=\hbox{\scalebox{\pgfmathresult}{\box\pgf@lib@dec@text@box}}%
\fi%
}
\newif\ifpgfdecorationtextalongpathscaletext
\def\pgf@lib@dec@text@startscale{1}
\def\pgf@lib@dec@text@endscale{1}
\pgfkeys{/pgf/decoration/.cd,
text path start scale/.code={%
\pgfdecorationtextalongpathscaletexttrue%
\def\pgf@lib@dec@text@startscale{#1}%
},
text path end scale/.code={%
\pgfdecorationtextalongpathscaletexttrue%
\def\pgf@lib@dec@text@endscale{#1}%
}
}
\begin{document}
\begin{tikzpicture}[
decoration={
reverse path,
text along path,
text path start scale=1.5,
text path end scale=0,
text={If $K \leq G$ and there are inclusions $gKg^-1\leq K$ for every $g\in G$, ... .}}
]
\draw [decorate]
(0,0)
\foreach \i [evaluate={\r=(\i/2000)^2;}] in {0,5,...,2880}{ -- (\i:\r)};
\useasboundingbox (-2.75,-2.75) rectangle (2.75,2.75);
\end{tikzpicture}
\end{document}
答案1
如果您按照 Herbert 在 pstricks 示例中的做法操作,您的代码就可以正常工作——将数学运算括在花括号中:
If {$K \leq G$} and there are inclusions {$gKg^-1\leq K$} for every {$g\in G$}, ...
问题在于长段数学运算被视为一个单位,因此您必须将它们分解:
{$g$}{$K$}{$g^{-1}$} {$\leq$} {$K$}
我修复了没有注意到的 {-1} 问题,该问题也必须放在其自己的花括号中。
答案2
它需要latex->dvips->ps2pdf
。xelatex
在这种情况下不起作用。如果真的需要,应该很容易将其应用于 TikZ 解决方案。
\documentclass[pstricks]{standalone}
\usepackage[T1]{fontenc}
\usepackage{mathptmx,pst-plot,pst-text}
\newdimen\MyDim \MyDim=30pt
\makeatletter
\def\doPerChar#1#2\@nil{%
\CharacterAction{#1}%
\ifx\relax#2\relax\else\doPerChar#2\@nil\fi}
\def\perChar#1{\doPerChar#1\@nil}
\def\CharacterAction#1{%
\fontsize{\MyDim}{1.1\MyDim}\selectfont#1%
\global\advance\MyDim by -0.175pt}
\makeatother
\pagestyle{empty}
\begin{document}
\begin{pspicture}(-3.5,-3)(3,3)
\pstextpath{%
\parametricplot[linestyle=none,plotpoints=5000,algebraic,unit=0.2]
{50}{0}[/A 5e-3 def ]{A*(cos(t)+t^2*sin(t)) | A*(sin(t)-t^2*cos(t))}}{\perChar{%
{$a$}{$\!^2$}+{$b$}{$\!^2$}={$c$}{$\!^2$}~is~from~Pythagoras~%
who~lived~in~Greek.~{$\sin^2x+\cos^2x=1$}~is~also~from~him~and~%
the~same~in~geometry~\ldots}}
\end{pspicture}
\end{document}