![编辑](https://linux22.com/image/339844/%E7%BC%96%E8%BE%91.png)
我想删除一张我想放标签的图表。我不想在那里放置彩色矩形。背景颜色可以更改。在这个阶段,我不知道背景颜色会是什么。一般情况下可能不会。背景可以是透明的。我搜索了互联网并阅读了手册 pgf。
这是最有帮助的: 如何沿着圆圈书写文字?
其他类似主题包括
这是我的脚本:
\documentclass[serif]{beamer}
%\usepackage[cp1250]{inputenc}
\usepackage{graphicx}
\usepackage{pgf,tikz}
\usetikzlibrary{arrows}
\usebackgroundtemplate{}
\usetikzlibrary{decorations.text}
\begin{document}
\color{red}
%\pagecolor{black}
\begin{frame}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.6cm,y=0.6cm]
\clip(-6,-6) rectangle(6.1,6.1);
\draw[solid,->,color=red](-5,0)--(6,0);
\draw[solid,->,color=red](0,-5)--(0,6);
\draw (-5,-5) .. controls (5,-5) and (5,-5) .. (5,5);
\draw [decorate,decoration={text effects along path,text={Function {$f$}{$($}{$x$}{$)$}{$=$}{$2$}{$x$}{$^3$}}, text align=center,text effects/.cd, text along path, every character/.style={color=white,fill=gray, yshift=-0.5ex}}](-5,-5) .. controls (5,-5) and (5,-5) .. (5,5);
\end{tikzpicture}
\end{frame}
\end{document}
谢谢你的帮助
编辑
参照答案。
https://tex.stackexchange.com/a/326563/112774
但事实证明,图表的其他点却进一步向下移动。
(-5.5) .. Controls (-3, -4) and (4, 4) .. (5.3)
答案1
如果这是在 Beamer 中使用,最简单的方法不是使背景透明,而是使用 Beamer 的颜色来确保与背景匹配。由于您的示例中的背景是白色,我还更改了文本颜色以匹配前景色,因为除非您的眼睛比我敏锐得多,否则白色背景上的白色文本不太容易阅读。
\documentclass[serif]{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.text,arrows}% Note that arrows is deprecated
\begin{document}
\begin{frame}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.6cm,y=0.6cm, draw=red]
\clip(-6,-6) rectangle(6.1,6.1);
\draw[solid,->,color=red](-5,0)--(6,0);
\draw[solid,->,color=red](0,-5)--(0,6);
\draw (-5,-5) .. controls (5,-5) and (5,-5) .. (5,5);
\draw [decorate,decoration={text effects along path,text={Function {$f$}{$($}{$x$}{$)$}{$=$}{$2$}{$x$}{$^3$}}, text align=center,text effects/.cd, text along path, every character/.style={color=fg, fill=bg, yshift=-0.5ex}}](-5,-5) .. controls (5,-5) and (5,-5) .. (5,5);
\end{tikzpicture}
\end{frame}
\end{document}
如果我们现在加载一个完全不同的颜色主题,例如albatross
,我们会得到完全不同的结果:
\documentclass[serif]{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.text,arrows}% Note that arrows is deprecated
\usecolortheme{albatross}
\begin{document}
\begin{frame}
\begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=0.6cm,y=0.6cm, draw=red]
\clip(-6,-6) rectangle(6.1,6.1);
\draw[solid,->,color=red](-5,0)--(6,0);
\draw[solid,->,color=red](0,-5)--(0,6);
\draw (-5,-5) .. controls (5,-5) and (5,-5) .. (5,5);
\draw [decorate,decoration={text effects along path,text={Function {$f$}{$($}{$x$}{$)$}{$=$}{$2$}{$x$}{$^3$}}, text align=center,text effects/.cd, text along path, every character/.style={color=fg, fill=bg, yshift=-0.5ex}}](-5,-5) .. controls (5,-5) and (5,-5) .. (5,5);
\end{tikzpicture}
\end{frame}
\end{document}
请注意,使用 Beamer 时,极其重要的一点是避免以通常的方式更改 Beamer 元素的颜色。\color{red}
否则\pagecolor{black}
将导致 Beamer 无法正确跟踪颜色,从而引发各种复杂情况。
这是因为 Beamer假货通过跟踪背景颜色来实现透明度。因此,如果您使用覆盖效果来呈现部分透明的内容,Beamer 实际上并不使用部分透明度。相反,它会将前景色与背景色混合以模拟部分透明度。为了使其工作,至关重要的是不要使用非 Beamer 颜色宏覆盖 Beamer 的颜色。要更改背景颜色,请使用适当的 Beamer 命令。文本等也类似。
在这种情况下,如果您只想要图片中的效果,draw=red
则将其用作参数。否则,如果所有文本等都应该是红色,则将相应的 Beamer 颜色更改为红色。tikzpicture
有关该系统如何工作以及如何使用它的详细信息,请参阅 Beamer 手册第 17 节“颜色”中的讨论。
编辑
如果您正在栅格化图像并且需要透明度以便在网络上发布,那么上述方法可能不起作用。
这是一种使用淡入淡出来实现透明效果的方法。
\documentclass[serif]{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.text,arrows,fadings}% Note that arrows is deprecated
\usebackgroundtemplate{}
\begin{tikzfadingfrompicture}[line cap=round,line join=round,>=triangle 45,x=0.6cm,y=0.6cm, name=my fading]
\draw [draw=transparent!0, postaction={decorate, decoration={text effects along path, text={Function {$f$}{$($}{$x$}{$)$}{$=$}{$2$}{$x$}{$^3$}}, text align=center, text effects/.cd, text along path, every character/.style={color=transparent, fill=transparent}}}](-5,-5) .. controls (5,-5) and (5,-5) .. (5,5);
\end{tikzfadingfrompicture}
\begin{document}
\begin{frame}
\begin{tikzpicture}[line cap=round, line join=round, >=triangle 45, x=0.6cm, y=0.6cm, draw=red]
\clip(-6,-6) rectangle (6.1,6.1);
\draw [solid,->, color=red](-5,0)--(6,0);
\draw [solid,->, color=red](0,-5)--(0,6);
\draw [decorate, decoration={text effects along path, text={Function {$f$}{$($}{$x$}{$)$}{$=$}{$2$}{$x$}{$^3$}}, text align=center, text effects/.cd, text along path, every character/.style={color=fg, yshift=-0.5ex}}](-5,-5) .. controls (5,-5) and (5,-5) .. (5,5);
\fill [red, path fading=my fading, fit fading=false] (-5,-5) rectangle (5,5);
\end{tikzpicture}
\end{frame}
\end{document}
答案2
您可以定义一个元装饰,我必须承认它处于原始状态,取决于段长度的比例,但基本思想是相同的
\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.text,patterns}
\pgfdeclaremetadecoration{draw write draw}{initial}{%
\state{initial}[width=\pgfmetadecoratedpathlength/4, next state=text]{\decoration{curveto}\afterdecoration{\pgfusepath{stroke}}}%
\state{text}[width=\pgfmetadecoratedpathlength/2,next state=draw again]{\decoration{text effects along path}\afterdecoration{\pgfusepath{discard}}}%
\state{draw again}[width=\pgfmetadecoratedpathlength/4]{\decoration{curveto}\beforedecoration{\pgfpathmoveto{\pgfpointmetadecoratedpathfirst}}\afterdecoration{\pgfusepath{stroke}}}%
}
\begin{document}
\begin{tikzpicture}
\fill[pattern=checkerboard light gray] (0,0) rectangle (6,6);
\draw[decorate,
decoration={
draw write draw,
text={Function {$f$}{$($}{$x$}{$)$}{$=$}{$2$}{$x$}{$^3$}},
text align=center,text effects/.cd,
text along path,
every character/.style={color=black,fill=none, yshift=-0.5ex},
}
] (0,0) ..controls (0,2) and (7,5) .. (5,5);
\end{tikzpicture}
\end{document}