Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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[
   shadow=true,
   shadowsize=5pt,
   shadowangle=-40,
   shadowcolor=blue,
   fillstyle=solid,
   fillcolor=black,
   linestyle=none,
   linecolor=black,
   linewidth=0pt]{\Huge SHADOW TEXT}

\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?

share|improve this question
    
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

2 Answers 2

up vote 14 down vote accepted

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{shadowbox}
\usepackage{multicol}
%
\begin{document}
%
\setshadowoffset{1pt}
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowbox{This is a shadowbox}
\end{verbatim}}
\shadowbox{This is a shadowbox}
\end{multicols*}
\end{minipage}
%
\section{Changing the position of the shadow}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\setshadowoffset{2pt}
\shadowbox{This is a shadowbox}
\end{verbatim}}
%
\setshadowoffset{2pt}
\shadowbox{This is a shadowbox}
\end{multicols*}
\end{minipage}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\shadowoffsetx=1pt
\shadowoffsety=4pt
\shadowbox{This is a shadowbox}
\end{verbatim}}
%
\shadowoffsetx=1pt
\shadowoffsety=4pt
\shadowbox{This is a shadowbox}\\
\phantom{}
\end{multicols*}
\end{minipage}
%
\section{Changing the color of the shadow}
%
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\setshadowoffset{2pt}
\setshadowcolor{0.66, 0.66, 1}
\shadowbox{This is a shadowbox}
\end{verbatim}}
%
\setshadowoffset{2pt}
\setshadowcolor{0.66, 0.66, 1}
\shadowbox{This is a shadowbox}\\
\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}
\setshadowoffset{1pt}
\shadowbox{
   \fontsize{16}{16}\selectfont
   Large!}
\end{verbatim}}
%
\color{navy}
\setshadowcolor{0.8, 0.8, 1}
\setshadowoffset{2pt}
\shadowbox{\fontsize{16}{16}\selectfont \textbf{Large!}}\\
\phantom{}\\
\phantom{}
\end{multicols*}
\end{minipage}
%
\color{black}
\begin{minipage}{\textwidth}
\begin{multicols*}{2}
{\footnotesize
\begin{verbatim}
\setshadowoffset{1pt}
\color{black}
\shadowbox{%
   \begin{tabular}{|l|l|}
   \hline
   1 & 2 \\
   3 & 4 \\
   \hline
   \end{tabular}
}
\end{verbatim}}
%
\setshadowoffset{1pt}
\shadowbox{%
   \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}
\setshadowoffset{1pt}
\shadowbox{$\sqrt{2\pi}e^{-n}$}
\end{verbatim}}

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

enter image description here

share|improve this answer
1  
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
3  
@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
1  
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
4  
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.

share|improve this answer
    
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.