24

I have already typed in the META section of the website a post addressing the question as to how the letterpress (or engraving-like) effect in the headers of the site had been achieved. I know it can be done with vector graphics GUI-driven software (such as Inkscape or Adobe Illustrator and those of their ilk). I do not despise those applications at all (rather on the contrary), but I do my graphic work with PSTricks or Tikz (or even Asymptote) for precisely the same kind of reasons that I use TeX-based typesetting systems, as opposed to other high-quality systems such as Adobe InDesign or Quark.

Somebody at the META section suggested that maybe I should ask about this point in this section, and here I am. Anyone could say if there is a way that such an effect can be done with our beloved packages (those I have mentioned above)? Of course, it can be done going to the PostScript level, but I'm asking about a more direct way that is already available.

EDIT: Alan's answer below works fine. We get a letterpress effect indeed, but I believe it is not the same kind of effect that has been achieved in the header. Caramdir has answered in the METAsection that it was not done on TeX -- I understand he means it was done with some GUI-driven application. Anyone knows how to do this with code based on PSTricks, Tikz or Asymptote?

6
  • Could you explain in more detail how the solution proposed by Alan differs from the graphics in the header?
    – Jake
    Jul 8, 2012 at 10:36
  • In the headers we don't have a shadow dropped by the typefaces which is lighter than the background color. What I understand we have instead is something like a darker hue inside the typefaces themselves. Am I wrong about this?
    – Marcos
    Jul 8, 2012 at 10:44
  • 1
    There's no typo in my code. You must have changed the document class to memoir (which defines its own version of \HUGE.)
    – Alan Munn
    Jul 8, 2012 at 13:45
  • Alan, you're right. I am so used to working with memoir that I didn't realize \HUGE was actually introduced in it. I have edited my post accordingly.
    – Marcos
    Jul 8, 2012 at 14:36
  • 1
    Followed you here from the meta post. Herbert and Alan's answers came very close. I just want to point out that in the site logo, I had the white drop shadow, as well as a darker inner shadow inside of the letters. Light source set to 120 degrees. Here's a larger version of the logo.
    – Jin
    Jul 9, 2012 at 21:41

3 Answers 3

21
+50

Here's a pure TikZ/PGF version. Needs a bit of work to get the effect as good as the original image. It uses a couple of bits of code from the TeX-SX launchpad: the letter shape package and the shadow blur package (note: there's a minor modification of this compared to the pgf-blur package on CTAN).

The idea is to draw the letter with a shadow but to have the shadow drawn on top of the letter rather than under it to give the effect that it is the surrounding paper that is causing the shadow rather than the letter. The shapes.letter tikzlibrary is needed to define paths corresponding to letters and the pgf-blur library is for the blurred shadow.

Given those two packages, here's the code to produce the effect:

\documentclass{article}
%\url{http://tex.stackexchange.com/q/62570/86}
\usepackage{tikz}
\usetikzlibrary{shapes.letters,shadows.blur}

\pgfkeys{
  /pgf/letter/.cd,
  load font={stikz}{normal},
  size=4,
  load encoding=char,
}

\makeatletter
\tikzset{
  use letter path/.code={%
    \pgfscope
    \pgftransformscale{\letter@size}%
    \letter@path{\letter@encode{#1}}%
    \endpgfscope
  }
}
\makeatother
\begin{document}
\begin{tikzpicture}
\begin{scope}
\fill[red!70!black,use letter path=T];
\path[blur shadow,shadow blur base colour=white,use letter path=T];
\begin{scope}[shift={(2cm,-.8cm)}]
\fill[red!70!black,use letter path=E];
\path[blur shadow,shadow blur base colour=white,use letter path=E];
\end{scope}
\begin{scope}[shift={(4.1cm,0)}]
\fill[red!70!black,use letter path=X];
\path[blur shadow,shadow blur base colour=white,use letter path=X];
\end{scope}
\path (current bounding box.north west) ++(-1,1)  (current bounding
box.south east) ++(1,-1);
\clip[use letter path=T] (current bounding box.north west) rectangle
(current bounding box.south east);
\clip[shift={(2cm,-.8cm)},use letter path=E] (current bounding
box.north west) rectangle (current bounding box.south east);
\clip[shift={(4.1cm,0cm)},use letter path=X] (current bounding
box.north west) rectangle (current bounding box.south east);
\fill[blue,rounded corners] (current bounding box.north west)
rectangle (current bounding box.south east);
\end{scope}
\end{tikzpicture}
\end{document}

And here's the result (I didn't spend any time getting the colours right):

Psuedo-sunken letters

9
  • The pgf-blur package came into being from this package: tex.stackexchange.com/q/50422/86 Aug 6, 2012 at 17:44
  • Alternatively, one could paint a light red background, and the blue shape minus the letters (some winding number trick) with a standard black blur shadow on top.
    – mabartibin
    Aug 7, 2012 at 7:41
  • @mabartibin Duh ... now why didn't I think of that? Aug 7, 2012 at 8:59
  • because you were subconsciously waiting for an excuse to have something cast a white shadow ;-)
    – mabartibin
    Aug 7, 2012 at 13:55
  • @mabartibin That'll be it. Actually I decided I didn't like this method and went for an "inverse shadow" instead (see latest code on launchpad). Aug 7, 2012 at 14:01
18

needs pdflatex -shell-escape or latex->dvips->ps2pdf

\documentclass{article}
\usepackage{auto-pst-pdf}% for running it with pdflatex -shell-escape
\usepackage{pst-light3d}
\DeclareFixedFont{\Sf}{T1}{fxb}{b}{n}{2cm}
\begin{document}

\psframebox[framesep=5mm,fillcolor=black!20,fillstyle=solid]{%
  \PstLightThreeDText[fillstyle=solid,fillcolor=white,linestyle=none,
    LightThreeDYLength=0.1]{\Sf \rule[-0.75cm]{0pt}{2.5cm}Letterpress}}

\psframebox[framesep=5mm,fillcolor=black!20,fillstyle=solid]{%
  \PstLightThreeDText[fillstyle=solid,fillcolor=black!70,linestyle=none,
    LightThreeDYLength=-0.07,LightThreeDColorPsCommand=pop 1 setgray,
    LightThreeDXLength=0]{\Sf \rule[-0.75cm]{0pt}{2.5cm}Letterpress}}

\end{document}

enter image description here

3
  • Dear Herbert, thanks so much. I'm afraid what you get is the 3D effect which turns out to be the (in a sense) "opposite" to the letterpress effect. I would think that PSTricks is powerful enough to achieve the headers effect without needing to go all the way down to the PostScript level, but so far I haven't figured out the how-to and I guess you're the one who knows best.
    – Marcos
    Jul 8, 2012 at 10:38
  • see edit, I had the wrong setting for the second example.
    – user2478
    Jul 8, 2012 at 10:50
  • 1
    It works like Alan's Tikz-based code, but if you could possibly see the edit to my original question... I still think this does not make for the effect on the headers -- which does not detract from my appreciation for your assistance.
    – Marcos
    Jul 8, 2012 at 11:02
14

You can achieve a poor-man's letterpress effect by using text with a slight shadow set on an appropriately coloured background. This is how the effect is implemented in CSS. In this example I've used TikZ only to produce the background. The shadows are produced with the nice shadowbox package, first announced in this question:

How to create text with shadows?

\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage{shadowtext}
\usepackage{tikz}
% fontspec requires LuaLaTeX or XeLaTeX
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\newcommand\HUGE{\fontsize{2cm}{2cm}\selectfont}
% The regular shadowtext command to set colours is \shadowcolor
% but the command allows input only in rgb triples
% The following command allows for xcolor named values to be used
% and is much more convenient
\makeatletter
\newcommand\setshadowcolor[1]{\colorlet{st@shadowcolor}{#1}}
\makeatother
\begin{document}
\shadowoffsety{1pt}
\shadowoffsetx{0pt}

\begin{tikzpicture}
\node[fill=black!50,minimum height=3cm] 
     {\setshadowcolor{black!30}\shadowtext{\bfseries\HUGE Letterpress}};
\begin{scope}[yshift=3cm]
\node[fill=black!40,minimum height=3cm] 
     {\setshadowcolor{black}\shadowtext{\color{white}\bfseries\HUGE Letterpress}};
\end{scope}
\end{tikzpicture}
\end{document}

(The image doesn't look very nice because of the conversion to .png.)

output of code

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .