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.

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@}
\def\@makechapterhead#1{%
  \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{%
      \advance\hsize by -2cm
      \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}
share|improve this question
3  
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
3  
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
add comment

3 Answers

up vote 2 down vote accepted

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"):

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

Use the memoir class and check the »MemoirChapterStyles« document for the BlueBox (VZ39) chapter style.

share|improve this answer
    
Thanks for your answers. @Seamus. I'm writing my thesis. I want it to look like this cse.chalmers.se/~russo/russothesis.pdf @Stefan. In the end I need a pdf, but because of some graphics I need to first create a dvi. I will have a look a TikZ any way, thanks. @Thronsten. I will also have a look at memoir, but it's a 200 pages documents based on llncs. Changing the class may not be so easy. –  tamalet Dec 12 '10 at 16:24
add comment

You could also try using dvips and then converting to PDF; that would give the PSTricks code a chance to run...

share|improve this answer
    
I tried that but it still looks different. I also tried replacing pstrics with TikZ but I get some errors. In the end I just went with another chapter headings. Thanks everyone for your help. –  tamalet Dec 20 '10 at 9:58
add comment

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.