Rather than defining a specific color for some text in a drawn box, I want the text to be clipped from the box so that the paper color is visible. Here's the MWE:




\geometry{papersize={70mm, 20mm}}

\begin{tikzpicture}[remember picture,overlay]
\filldraw [fill=#7, draw=#7, line width=0.25mm, rounded corners=0.25mm]
     ($(current page.south west)+(#1,#2)-(#3/2,#4/2)$) rectangle 
     ($(current page.south west)+(#1,#2)+(#3/2,#4/2)$)
      node[pos=0.5, text depth=0pt, text=white] {#6};

\tikzstyle{reverseclip}=[insert path={(current page.north east) --
  (current page.south east) --
  (current page.south west) --
  (current page.north west) --

\placeTextBox{35mm}{10mm}{30mm}{3.1mm}{3.0mm}{\textbf{Transparent text}}{black}

This gives me the following result:

enter image description here

However, instead of using "text=white" in the node for the text, what do I need to do in order to have the text clipped from the black box to get the red paper color to show through?


You can use a knockout group, but is is not supported by many viewers. You can also use a tikzfadingfrompicture like this

\documentclass[tikz, border=1cm]{standalone}
\usetikzlibrary{fadings, patterns}
\node[fill=transparent!0] {\textbf Transparent text};
\pattern [pattern=checkerboard,pattern color=black!30] (-2,-1) rectangle (2,1);
\fill[red, path fading=myfading, fit fading=false] (-2,-1) rectangle (2,1);

Red node with transparent text on checkerboard pattern

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.