# Problems with chapter headings going from dvi to pdf.

I want to redefine the chapter headings using some code that I took from a friend. It works fine when I create a dvi and I see it in Okular (it doesn't look fine using Evince), but when I try generate a pdf either with pdflatex or dvipdf, the headings look wrong. I've no idea what the problem can be.

Here is an example. Thanks in advance.

\documentclass{report}

\usepackage{psboxit}
\usepackage{pstricks}

% Title for chapters
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\reset@font
\parindent \z@
\vspace*{10\p@}%
\hbox{%
\vbox{%
\hsize=2cm%
\begin{tabular}{c}
\scshape \strut \@chapapp{} \\
\psboxit{box 0 0 0 setrgbcolor fill}{%
\vrule depth 8em width 0pt%
\vrule height 0pt depth 0pt width 10pt%
{\white \LARGE \bfseries
\strut \vrule height 1em depth 0pt width 0pt
\thechapter}%
\vrule height 0pt depth 0pt width 10pt%
}
\end{tabular}%
}%
\vbox{%
\hrule height 0.4pt depth 0pt width \hsize
\par
\vskip 6pt%
\hspace{20pt}%
\parbox{260pt}{%
\LARGE \bfseries #1
}%
}%
}%
\vskip 100\p@
}

\begin{document}
\chapter{Introduction}
Intro here.
\end{document}

-
Since your goal is to produce PDF output, I recommend to use TikZ instead of PSTricks. The latter requires to produce DVI and PostScript, but TikZ is capable of directly generating PDF output. Further you could benefit of pdfTeX features. –  Stefan Kottwitz Dec 7 '10 at 14:58
Could you explain what you are trying to achieve with this code so that we can suggest a better way to do it for compiling to pdf. I tried to run your MWE, but got a huge black rectangle covering a lot of the page... –  Seamus Dec 7 '10 at 15:02

Here's a possible solution using titlesec and TikZ; the new style for the chapter titles is defined through a command:

\documentclass[twoside]{report}
\usepackage[rigidchapters,explicit]{titlesec}
\usepackage{tikz}
\usepackage{lipsum}

\newcommand\MyChapFormat{%
\titleformat{\chapter}[block]
{ }{}{0pt}
{\begin{tikzpicture}[%
blackrec/.style={draw,fill=black,minimum height=3cm,minimum width=0.8cm},%
remember picture,overlay]
\node[blackrec] (BS) at (0.5,0) {};
\node[anchor=north,yshift=-0.3cm] at (BS.north)%
{\textcolor{white}{\Large\bfseries\thechapter}};
\node[anchor=south] at (BS.north) {\scshape\chaptername};
\draw[ultra thick] (1.6,1) -- (\textwidth,1);
\node[anchor=north,align=left,text width=0.83\textwidth,xshift=6cm,yshift=-0.1cm] at (1,1)
{\bfseries\Large##1};
}
[\end{tikzpicture}]
\titlespacing{\chapter}{0pt}{0pt}{150pt}
}
\begin{document}
\tableofcontents

\MyChapFormat
\chapter{Introduction }

\lipsum[1]

\end{document}


Here's the result (I only include an image for the chapter corresponding to "Introduction"):

-
I tried it and it look great! But it must be noted that this only works with PDFLaTeX. Thanks! –  tamalet May 26 '11 at 20:29