2

I am trying to get a fancy style for my report, and I found one online here

I used it for another report, but not exactly with the same code. I wanted to play around with it, change things, and started to realize that I altered it so much last time (a too long time ago), that I couldn't use it anymore.

Now, on a new computer, with a new project, I want to start with a fresh style, and I would like to play around with the element of the style.

The only trouble is that, first I can get it to work like on the example (n°39) : I don't get the black box. And second, I don't really understand the code.

That's why I'm seeking for your wisdom, to translate this bit of code so that I can use it.

Here is my code :

\documentclass[12pt]{report}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[top=2cm, bottom=2cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage{fancyhdr} % En-têtes et pieds de page
\usepackage{psboxit,pstricks}

\makeatletter
\renewcommand\part{%
  \thispagestyle{fancy}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@part\@spart}

\renewcommand\chapter{
  \thispagestyle{fancy}%
  \global\@topnum\z@
  \@afterindentfalse
  \secdef\@chapter\@schapter}
\makeatother 

%%%%%%%%%%%%%%%%%%%%%%%%%%%% THE PART I DON'T UNDERSTAND

\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 black 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}{%
        \Huge \bfseries #1}%
      }%
    }%
  \vskip 100\p@
}
\def\@makeschapterhead#1{%
  \reset@font
  \parindent \z@ 
  \vspace*{10\p@}%
  \hbox{%
    \vbox{%
      \hsize=2cm%
      \begin{tabular}{c}
        \scshape \strut \phantom{\@chapapp{}} \\
        \psboxit{box 0 0 0 black fill}{%
          \vrule depth 8em width 0pt%
          \vrule height 0pt depth 0pt width 10pt%
          {\white \LARGE \bfseries 
            \strut \vrule height 1em depth 0pt width 0pt
            \vphantom{\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}{%
        \Huge \bfseries #1}%
      }%
    }%
  \vskip 100\p@
}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    

\begin{document}
\pagenumbering{gobble}
\chapter*{Test}
\newpage
\chapter{Nice Chapter}
\newpage
\pagenumbering{arabic}
\pagestyle{fancy}
\lhead{Nice header}
\rfoot{Page\ \thepage}
\cfoot{}
\chapter{Test2}
\newpage
\chapter*{Nice Chapter2}

\end{document}

Initial Output :

enter image description here

EDIT :

As mentioned by Christian Hupfer, my code does not work properly maybe because of the age of the packages psboxit and psboxtricks

here the code with the one I previously used, but that I modified without really understanding it :

\documentclass[12pt]{report}

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[top=2cm, bottom=2cm, left=1.5cm, right=1.5cm]{geometry}
\usepackage{fancyhdr} % En-têtes et pieds de page
\usepackage[usenames,dvipsnames]{xcolor}

\makeatletter
\renewcommand\part{%
  \thispagestyle{fancy}%
  \if@twocolumn
    \onecolumn
    \@tempswatrue
  \else
    \@tempswafalse
  \fi
  \null\vfil
  \secdef\@part\@spart}

\renewcommand\chapter{
  \thispagestyle{fancy}%
  \global\@topnum\z@
  \@afterindentfalse
  \secdef\@chapter\@schapter}
\makeatother 

%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\makeatletter
    \def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
    \def\@makechapterhead#1{%
      \reset@font
      \vspace*{-40\p@}%
      \hbox{%
        \vbox{%
          \hsize=1cm%
          \begin{tabular}{c}
           \hspace*{-100mm} \scshape \strut \phantom{\@chapapp{}} \\
           \hspace*{-9mm} \colorbox{Black}{\vbox{\hbox{\vbox to 1mm{}}\hbox{\color{white} \LARGE \bfseries \hspace{1mm}\thechapter\hspace{1mm}}\hbox{\vbox to 1cm{}}}}%
          \end{tabular}%
          }%
        \vbox{%
          \advance\hsize by -1cm
          \hrule height 0.4pt depth 0pt width \hsize
          \par
          \vskip 6pt%
          \hspace{1pt}%
          \parbox{400pt}{%
            \Huge \bfseries #1}%
          }%
        }%
      \vskip 15\p@
    }
    \def\@makeschapterhead#1{%
      \reset@font
      \vspace*{-40\p@}
      \hbox{%
        \vbox{%
          \hsize=1cm%
          \begin{tabular}{c}
            \hspace*{-100mm} \scshape \strut \phantom{\@chapapp{}} \\
            \hspace*{-9mm} \colorbox{Black}{\vbox{\hbox{\vbox to 1mm{}}\hbox{\color{white} \LARGE \bfseries \hspace{1mm}\phantom{\thechapter}\hspace{1mm}}\hbox{\vbox to 1cm{}}}}%
          \end{tabular}%
          }%
        \vbox{%
          \advance\hsize by -1cm
          \hrule height 0.4pt depth 0pt width \hsize
          \par
          \vskip 6pt%
          \hspace{1pt}%
          \parbox{400pt}{%
            \Huge \bfseries #1}%
          }%
        }%
      \vskip 15\p@
    }
    \makeatother


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    

\begin{document}
\pagenumbering{gobble}
\chapter*{Test}
\newpage
\chapter{Nice Chapter}
\newpage
\pagenumbering{arabic}
\pagestyle{fancy}
\lhead{Nice header}
\rfoot{Page\ \thepage}
\cfoot{}
\chapter{Test2}
\newpage
\chapter*{Nice Chapter2}

\end{document}
16
  • Welcome to TeX.SX! psboxit is an old package that apparently belongs to latex2.09. I am not sure this should be used nowadays. psboxit is available on CTAN, but not on TeXLive for example
    – user31729
    Commented May 23, 2016 at 15:10
  • It seems so, any alternative and comment on how to modify the code to get the same results ? Commented May 23, 2016 at 15:13
  • The same as what? I don't have a screenshot etc. to compare with
    – user31729
    Commented May 23, 2016 at 15:15
  • 1
    My answer to this question, using titlesec is close to what you want.
    – Bernard
    Commented May 23, 2016 at 17:28
  • 1
    Did you try compiling the very code in the link , or an adapted version?
    – Bernard
    Commented May 25, 2016 at 10:16

0

Browse other questions tagged .