# How to write a text on a curve, removing a piece of it in this section? (No fill=white)

I would like to erase a piece of graph where I want to put a label. I do not want to place there rectangles of color. The background color can be changed. At this stage, I do not know what will be the background color. It is possible that in general it will not. The background can be transparent. I searched the internet and read manual pgf.

This is most helpful: How to write a text along a circle?

Other similar topics include

This is my script:

\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}


Thanks for the help Best Regards

in this picture background transparent.

EDIT
With reference to the answer. https://tex.stackexchange.com/a/326563/112774 It turns out, however, that other points of the graph is shifted further down.

(-5.5) .. Controls (-3, -4) and (4, 4) .. (5.3)

• Is this for use in Beamer? If so, the easiest way is not to make it transparent but to use Beamer's colours to ensure a match with the background. That way, it will always match regardless. But obviously this won't work if you won't be using Beamer. – cfr Aug 25 '16 at 21:55
• Please see my edited answer for an alternative which uses TikZ fadings to create the transparency. This is much more of a faff and, if you have to do many of these, adding the alpha as part of the conversion process will be much more practical. But if you just need one or two pictures, the TikZ method may be more convenient, – cfr Aug 26 '16 at 0:53

If this is for use in Beamer, the easiest way to do this is not to make the background transparent but to use Beamer's colours to ensure a match with the background. Since the background in your example is white, I've also changed the text colour to match the foreground colour since white text on a white background is not very easy to read unless your eyes are much keener than mine.

\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}


If we now load a radically different colour theme, such as albatross, we get a quite different result:

\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}


Note that it is extremely important, when using Beamer, to avoid changing the colours of Beamer elements in the usual way. \color{red} or \pagecolor{black} will cause all kinds of complications by preventing Beamer from tracking colours correctly.

This is because Beamer fakes transparency by keeping track of the background colour. So if you use an overlay effect which renders content partially transparent, for example, Beamer doesn't really use partial transparency. Instead, it mixes the foreground colour with the background colour in order to simulate partial transparency. In order for this to work, it is vital that Beamer's colours not be overridden using non-Beamer colour macros. To change the background colour, use the appropriate Beamer command. Similarly for text etc.

In this case, use draw=red as an argument for the tikzpicture if you just want the effect in the picture. Otherwise, if all text etc. should be red, change the appropriate Beamer colour to red.

For details of how this system works and how to use it, see the Beamer manual's discussion in section 17, 'Colors'.

# EDIT

If you are rasterising images and need transparency for posting on the web, then the above method may not work.

Here's a method which uses a fading to achieve a transparent result.

\documentclass[serif]{beamer}
\usepackage{tikz}
\usetikzlibrary{decorations.text,arrows,fadings}% Note that arrows is deprecated
\usebackgroundtemplate{}
\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);

\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);
\end{tikzpicture}
\end{frame}
\end{document}


You can define a meta-decoration which I have to confess it is in primitive condition depending on the ratios of the segment lenghts but the essential idea is the same

\documentclass[tikz]{standalone}
\usetikzlibrary{decorations.text,patterns}
}

\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}


• I love this approach. Could you please clarify the meaning of "is in primitive condition depending on the ratios of the segment lenghts"? – Christoph Frings Aug 26 '16 at 10:31
• @ChristophFrings It means that I was lazy and didn't measure the text length and compared to the path length to have just the right amount of empty space around the text also arrow heads should be taken into account :) But for straightforward use I think it serves the purpose. – percusse Aug 26 '16 at 10:37
• Got it! Thx. :) – Christoph Frings Aug 26 '16 at 12:56