# How to create text with shadows?

This question led to a new package:
shadowtext

I used the following code:

\documentclass{article}

%\usepackage{pst-all}
\usepackage{pstricks}
\usepackage{pst-3d,pst-text}
\usepackage{soul}

\begin{document}

\pscharpath[
fillstyle=solid,
fillcolor=black,
linestyle=none,
linecolor=black,

\end{document}


Problem is, there doesn't appear any shadow next to the text. Any idea how to setup shadows to a string on a way that really works?

-
You need to compile this with latex+dvips. If you are using TeXShop, add % !TEX TS-program = latex as the first line of your document.  –  Alan Munn Apr 26 '12 at 1:59
Okay, I tried it using TeXworks, but this way gave me ! Undefined control sequence. errors most of the time. Don't understand why there are two tools to interpret latex. But okay, I'll use TeXShop from now on, because it works. –  Marc Apr 26 '12 at 2:37
In TeXworks, you should be able to add % !TeX program = latex. PSTricks uses Postscript commands that cannot be processed by pdflatex which is why you need to use latex when you compile this code. –  Alan Munn Apr 26 '12 at 3:37

Sorry for the shameless self-advertising, but I once wrote a small package for drop shadows which is now available on CTAN; it's called shadowbox. This package works with pdflatex.

A somewhat long MWE:

\documentclass{article}
\usepackage{multicol}
%
\begin{document}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\end{verbatim}}
\end{multicols*}
\end{minipage}
%
\section{Changing the position of the shadow}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\end{verbatim}}
%
\end{multicols*}
\end{minipage}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\end{verbatim}}
%
\phantom{}
\end{multicols*}
\end{minipage}
%
\section{Changing the color of the shadow}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\end{verbatim}}
%
\phantom{}
\end{multicols*}
\end{minipage}
%
\section{More examples}
The following code illustrates how to use shadowbox in more interesting settings:
%
\definecolor{navy}{rgb}{0,0,0.5}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\definecolor{navy}{rgb}{0,0,0.5}
\color{navy}
\fontsize{16}{16}\selectfont
Large!}
\end{verbatim}}
%
\color{navy}
\phantom{}\\
\phantom{}
\end{multicols*}
\end{minipage}
%
\color{black}
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\color{black}
\begin{tabular}{|l|l|}
\hline
1 & 2 \\
3 & 4 \\
\hline
\end{tabular}
}
\end{verbatim}}
%
\begin{tabular}{|l|l|}
\hline
1 & 2 \\
3 & 4 \\
\hline
\end{tabular}
}
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}
\end{multicols*}
(Notice the percent sign right after the shadowbox command. This is necessary!)
\end{minipage}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowbox{$\sqrt{2\pi}e^{-n}$}
\end{verbatim}}

\shadowbox{$\sqrt{2\pi}e^{-n}$}\\
\phantom{}
\end{multicols*}
\end{minipage}
%
\color{black}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\color{navy}
\fontencoding{T1}%
\fontfamily{pag}%
\fontseries{b}%
\fontsize{32}{32}%
\selectfont%
Section \arabic{section}%
}
\end{verbatim}}
%
\color{navy}%
\fontencoding{T1}%
\fontfamily{pag}%
\fontseries{b}%
\fontsize{32}{32}%
\selectfont%
Section \arabic{section}%
}
\phantom{}\\
\phantom{}\\
\phantom{}\\
\phantom{}\\
\end{multicols*}
\end{minipage}
%
\end{document}


-
Looks nice! Would you mind posting a small usage example and a picture of the output here? (self-advertising is fine, by the way) –  Jake Apr 26 '12 at 6:14
+1 for sharing: Yory, that's a cute little package, please advertise more :-) You might consider adding an environment version of your \shadowbox. –  Daniel Apr 26 '12 at 6:48
@Yori Ideally you should put it on CTAN. I would also recommend changing the name to shadowtext instead of shadowbox which seems to imply a package to put things in boxes (akin to fancybox.) See What is good practice when preparing a package for CTAN for some advice on submitting to CTAN. –  Alan Munn Apr 26 '12 at 15:49
Hi, wow, thanks everyone! I didn't expect so many replies. @HarishKumar: thank you for adding examples. @AlanMunn: I have no idea how to put packages on CTAN; it seems complicated to me, but I will have a look at your link (I also realized that shadowbox already exists and is not an appropriate name. I think shadowtext is a good alternative.) –  Yori Apr 26 '12 at 16:15
I submitted a package called shadowtext to CTAN! –  Yori Apr 27 '12 at 12:54

The reason your code doesn't compile is because it uses PSTricks and you are trying to compile it with pdflatex. PSTricks code uses Postcript commands that cannot be interpreted by pdflatex, so you need to compile it using the sequence of latex + dvips + ps2pdf.

Depending on your editor, there are different ways to do this. Since you are using a Mac, I'll outline how to do it in both TeXShop and TeXworks.

TeXworks

TeXworks is not set up to be able to compile with latex+dvips by default, so you first need to add to its preferences to create a "latex" compilation command. See this question for how to do that:

configure latexmk in Texworks 0.2.3

Once you've done this, you can choose "latex" instead of "pdfLaTeX" from the dropdown menu in the document window.

Alternatively, you can put

% !TeX program = latex


as the first line of your file.

TeXShop

In TeXShop, you need to choose "TeX and DVI" from the Typeset menu instead of "pdfTeX".

Alternatively, you can put

% !TEX TS-program = latex


as the first line of your file.

-
Thanks for your help! A bit more configurations were needed to get a "latex" option in the dropdown menu and % !TeX program = latex` didn't worked without adding the "latex" option to the dropdown menu. But in TeXShop I had no issues with that and it already worked without changing "pdfTeX" to "TeX and DVI" in the Typeset menu. –  Marc Apr 26 '12 at 9:32