# Shape driven formatting

I'm not exactly sure how to call it, so I've had a hard time search for it online.

What I have is a solid block of text. What I want is to change the formatting of part of this block of text (make it bold, italic, change its color) according to a shape or picture.

I'm already using pstricks for all my other figures so I'd rather stick to that if at all possible. I have a picture (png) with the shape I'm trying to imprint, but I could recreate it in pstricks if it's necessary.

• Just a thought, but the gimp in me is saying transparency layers. – Sean Allred Mar 29 '13 at 0:14
• Do you know what packages I can look at for that ? – Lexiel Mar 29 '13 at 0:40
• If you are looking for purely graphic affects such as colour then you could use a graphic program or probably pstricks to overlay some kind of mask, but your question mentioned typographic affects such as font changes to bold or italic, that is much harder (probably virtually impossible in TeX) as TeX is optimising line breaking over the whole paragraph so you don't know which letters fall in the mask shape until the end of the paragraph but you need to fix font choices before tex considers line breaking. – David Carlisle Mar 29 '13 at 1:29
• I was afraid that would be the case. I'll see if pstricks will let me apply a mask overlay (now I know what keywords to search for!) and fall back on photoshopping and including the image. Thanks for the info ! – Lexiel Apr 1 '13 at 17:09

With pst-text, you can clip a character path via \pscharclip. This allows you to display text clipped to the character(s) within the path:

\documentclass{article}
\usepackage{pstricks,xcolor,pst-text,lipsum}% http://ctan.org/pkg/{pstricks,xcolor,pst-text,lipsum}
\begin{document}
\noindent
\begin{pspicture}(\linewidth,\textheight)
\rput{0}(0.5\linewidth,0.5\textheight){%
\begin{minipage}{\linewidth}
\color{black!25}
\lipsum[1-5]
\end{minipage}%
}%
\begin{pscharclip}[linewidth=0pt,linestyle=none]{%
\rput(0.5\linewidth,0.5\textheight){\psscalebox{60}{I}}}%
\rput{0}(0.5\linewidth,0.5\textheight){%
\begin{minipage}{\linewidth}
\color{black}
\lipsum[1-5]
\end{minipage}%
}
\end{pscharclip}
\end{pspicture}
\end{document}


The above example is partially taken and modified from the pst-text documentation.

It would also be possible to clip a different path, as specified by (say) \pscustom.

• Could you do this with graphics (e.g. a logo or another image) instead of text (i.e. the letter I in your example)? – tommy.carstensen Aug 29 '15 at 11:56
• @tommy.carstensen: Yes. You can ultimately use a \pscustom to create whatever shape you're interested in as a clip. – Werner Aug 29 '15 at 17:15