0

I am trying to make a gradient box with text with the right color completely blend with the background. Here is my document.

\documentclass{article}
\usepackage{tikz}

\begin{document} \begin{tikzpicture} \node[inner xsep=2mm,text width=5cm,left color=red,right color=white] {\parbox[t]{\textwidth}{\color{white}\sffamily\bfseries A}}; \end{tikzpicture} \end{document}

The result I got is this:

gradient1

I want the border at the right to be gone and the right color to completely blend with the background like this:

gradient2

I tried fade with transparency from this post but the result is the same.

Any help will be highly appreciated.

Raja Ayaz
  • 133
  • 1
  • 3
  • 10
  • If available, opaque (transparent) would be the better choice. If available, you'd need to shift the fading point more to the left. See drawing programs, or even Excel. – MS-SPO Jun 30 '22 at 07:05
  • Can you give an example how to shift the fading point to the left? – Raja Ayaz Jun 30 '22 at 07:23

1 Answers1

0

Use \usepgflibrary{shadings}, and put the middle color option last. Add text, e.g. by putting a node to anchor west.

P.S. See also e.g. Tikz gradient with 3 or more colors using pgfdeclarehorizontalshading

gradient

\documentclass[10pt, border=3mm]{standalone}

\usepackage{tikz} \usepgflibrary{shadings}

% see pgf manual, ch. 69 Shadings Library

\begin{document}

\tikz \draw[left color=red, right color=white, middle color=red!5]
(0,0) rectangle (2,1);% middle must be last

\end{document}

MS-SPO
  • 11,519