2

Yesterday , I saw a post about a chapter heading style which I liked. And I Was wondering if you could help me achieve the same model (although there are certain differences in the one I want). Thank you in advance.

chapter heading book

 \documentclass[a4paper]{book}
 \usepackage[T1]{fontenc}
 \usepackage{libertine}
 \usepackage[table]{xcolor}
 \makeatletter
 \def\@part[#1]#2{%
  \ifnum \c@secnumdepth >-2\relax
  \addcontentsline{toc}{chapter}{\thechapter\hspace{1em}#1}%
 \else
  \addcontentsline{toc}{chapter}{#1}%
 \fi
\markboth{}{}%
\reset@font
\parindent \z@ 
\vspace*{10\p@}%
\hbox{%
 \vbox{%
  \hsize=7mm%
  \begin{tabular}{@{}p{7mm}@{}}
    \makebox[7mm]{\scshape\strut\small\chaptername}\\
    \makebox[7mm]{\cellcolor{black}\Huge\color{white}\bfseries\strut\thechapter\rule[-4cm]{0pt}{4cm}}%
  \end{tabular}%
  \makebox(0,0){\put(-10,-100){\fbox{\phantom{\rule[-4cm]{7mm}{4cm}}}}}
  }%
\kern-2pt
\vbox to 0pt{%
   \tabular[t]{@{}p{1cm}p{\dimexpr\hsize-2.1cm}@{}}\hline
      & \Huge\itshape\rule{0pt}{1.5\ht\strutbox}#1\endtabular}%
   }%
  \cleardoublepage
%  \vskip 100\p@
}
       \makeatother

   \begin{document}
   \chapter{Books in \LaTeX}


text text text text text text text text text text text text text text text text 
text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text text.

      \end{document}
1

1 Answer 1

2
\documentclass[a4paper]{book}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage[table]{xcolor}
\makeatletter
\def\@chapter[#1]#2{%
  \cleardoublepage
  \refstepcounter{chapter}%
  \ifnum \c@secnumdepth >-2\relax
    \addcontentsline{toc}{chapter}{\chaptername~\thechapter\hspace{1em}#1}%
  \else
    \addcontentsline{toc}{chapter}{#1}%
  \fi
\markboth{}{}%
\reset@font
\parindent \z@ 
\vspace*{10\p@}%
    \hbox{%
        \vbox{%
            \hsize=7mm%
            \begin{tabular}{@{}p{7mm}@{}}
                \makebox[7mm]{\scshape\strut\small\chaptername}\\
                \makebox[7mm]{\cellcolor{black}\Huge\color{white}\bfseries\strut\thechapter\rule[-4cm]{0pt}{4cm}}%
            \end{tabular}%
            \makebox(0,0){\put(-10,-100){\fbox{\phantom{\rule[-4cm]{7mm}{4cm}}}}}
        }%
        \kern-2pt
        \vbox to 0pt{%
            \tabular[t]{@{}p{1cm}p{\dimexpr\hsize-2.1cm}@{}}\hline
            & \Huge\itshape\rule{0pt}{1.5\ht\strutbox}#1\endtabular}%
    }%
    \vskip 100\p@
} \makeatother

\usepackage{blindtext}
\begin{document}
    \tableofcontents
    \chapter{Books in \LaTeX}

    text text text text text text text text text text text text text text text text text text text 
    text text text text text text text text text text text text text text text text text text text 
    text text text text text text text text text text text text text text text text text text text 
    text text text text text text text text text text text text text text text text text. 

\blinddocument
\end{document}

enter image description here enter image description here enter image description here

14
  • Thanks a lot! But it gives me 2 errors undefined control sequence argument\cellcolor black huge color white bfseries......and a warning file book has changed Aug 24, 2018 at 11:13
  • Perhaps its because the TOc i defined \newlenght\mylength \renewommand\cftchappresnum{\chaptername~} \renewcommand\cftchaaftersnum{-} Aug 24, 2018 at 11:14
  • In the toc i have 0. Revue of literature 1....... i don't want that. I need to have chapter 1. Revue of literature. Chapter 2...... Aug 24, 2018 at 11:43
  • Even the shape and the font of my all document had change😧 Aug 24, 2018 at 11:43
  • Do you get the errors with my example or with your code?
    – user2478
    Aug 24, 2018 at 12:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .