0

EDIT: My first MWE and question didn't really cover what I want. What I actually want looks like this, multicolour banded text example except, a) I want the outline thickness to remain consistent with what I get from \textpdfrenderand, b) I would love to be able to search and copy-paste text. The \contour package creates the outline by duplicating the text a number of times. That ruins the "text"-ness of the text. I should note that \textpdfrender already exists and works well, if you're using a single colour to fill your text. In my previous question: How to fill text with bands of colour in tikz and keep normal text positioning, I got this solution from mais

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{calc} 
\usepackage{pgfplots}
\usepackage[outline,pdftex]{contour} % the options make it look better
\usepackage{pdfrender}
\begin{document}
% \TextShadeContour{<number of colors>}{<contour color>}{<text>}
\newcommand{\TextShadeContour}[3]{%
\begin{tikzpicture}[baseline]
    \foreach \c in {1,2,...,#1}{
        \pgfplotscolormapaccess[1:#1]{\c}{ShadingColor}
        \definecolor{colortemp}{rgb}{\pgfmathresult}
        \ifnum\c=1
            \node[colortemp, anchor=base, inner xsep=0pt, inner ysep=.5pt, outer sep=0pt] (n) at (0,0) {\contour{#2}{#3}};
        \else
            \pgfmathparse{1-(\c-1)/#1}
            \clip let \p1=(n.south west), \p2=(n.north east), in (n.south west) rectangle (\x2,\y1+\pgfmathresult*\y2-\pgfmathresult*\y1);     
            \node[colortemp, anchor=base, inner xsep=0pt, inner ysep=.5pt, outer sep=0pt] {#3};
        \fi
    }
\end{tikzpicture}%
}
{\pgfplotsset{colormap={ShadingColor}{color=(pink),color=(orange),color=(green)}} \TextShadeContour{3}{black}{42}: \textpdfrender{
    TextRenderingMode=FillStroke,
    LineWidth=0.2pt,
    LineJoinStyle=1, 
        FillColor=green,
  }{C}\pgfplotsset{colormap={ShadingColor}{color=(pink),color=(orange)}}\TextShadeContour{2}{black}{Ma}
}
\end{document}

I want to be able to essentially use the pdf special somehow (perhaps?) to outline these as does \textpdfrender

EDIT: This was my original MWE which didn't actually describe what I wanted. If you look at the example from http://project.ktug.org/dvipdfmx/doc/tug2005.pdf#page=11, we should have an outline with grey filling the text.

\documentclass{article}
\begin{document}
stuff
\special{pdf:bcolor [.5] [0]}
\special{pdf:literal direct 1 w 2 Tr}
stuff
\end{document}
keymasta
  • 177
  • 1
    no luatex uses other primitives. \pdfextension literal direct {1 w 2 Tr} e.g. Or try the pdfrender package. – Ulrike Fischer Dec 07 '21 at 23:04
  • 1
    \special is a feature for adding to dvi files, it does not work with pdflatex either. – David Carlisle Dec 07 '21 at 23:16
  • @Ulrike Fischer: I still do not get an outline effect. How would I make only the outline show. I am trying to outline the output of [1] I have been searching around for reference to \pdfextension commands and found not much in terms of examples. I want the part of \pdfrender which adds the outline.

    @David Carlisle: That makes sense. [1] https://tex.stackexchange.com/questions/622920/how-to-fill-text-with-bands-of-colour-in-tikz-and-keep-normal-text-positioning

    – keymasta Dec 08 '21 at 18:47

1 Answers1

2

With the pdfrender package and lualatex this here works:

\documentclass{article}
\usepackage{pdfrender}
\usepackage{color}

\begin{document} \textpdfrender {FillColor=red,StrokeColor=blue,TextRenderingMode=2,LineWidth=0.2} {FILL &amp; STROKE}

\end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • That's true but I want it to be like this (and outlined as in \textpdfrender). I'll edit the question title: https://tex.stackexchange.com/questions/622920/how-to-fill-text-with-bands-of-colour-in-tikz-and-keep-normal-text-positioning – keymasta Dec 08 '21 at 20:02