0

I tried to use hbox/wbox, tabular and colorboxes.

Just look at image and this source.

Could anybody help with correct styling?

 \documentclass{book}
 \usepackage{lipsum}
 \usepackage{tcolorbox}
 \makeatletter
 \def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
 \def\@makechapterhead#1{%
   \reset@font
   \parindent \z@ 
   \vspace*{10\p@}%
   \begin{tabular}{l l}
    \begin{tcolorbox}[center title,left=5pt,right=0pt,top=5pt,bottom=5pt,width=5cm, colback=red, colframe=red,enlarge left by=0mm,boxsep=5pt,arc=0pt,outer arc=0pt,]
        \fontsize{14pt}{14pt}\selectfont \textcolor{white}{\@chapapp{} \thechapter }
    \end{tcolorbox}
       &
    \begin{tcolorbox}[center title,left=0pt,right=0pt,top=5pt,bottom=5pt,colback=black, colframe=black,enlarge left by=0mm,boxsep=5pt,arc=0pt,outer arc=0pt,]
        \fontsize{14pt}{14pt}\selectfont \textcolor{white}{#1}
    \end{tcolorbox}
 \end{tabular}
 }

 \begin{document}
 \chapter{Introduction}
 \lipsum

 \chapter{Some very long title with many words and terms}
 \lipsum

 \end{document}

enter image description here

2

Instead of a tabular, you could use a raster with an extruded right box. Following code needs some geometry adjustments, but can help as starting point.

\documentclass{book}
 \usepackage{lipsum}
 \usepackage[most]{tcolorbox}
 \makeatletter
 \def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
 \def\@makechapterhead#1{%
   \reset@font
   \parindent \z@ 
   \vspace*{10\p@}%
   \begin{tcbraster}[raster columns=2, sharp corners, raster equal height, notitle, sharp corners, colupper=white, fontupper=\fontsize{14pt}{14pt}\selectfont, raster width=\linewidth+\marginparwidth+\marginparsep, raster force size=false]
    \begin{tcolorbox}[halign=center, valign=center, colback=red, colframe=red, add to width=-4cm]
        \@chapapp{} \thechapter
    \end{tcolorbox}
    \begin{tcolorbox}[colback=black, colframe=black, extrude right by=\marginparwidth+\marginparsep]
        #1
    \end{tcolorbox}
 \end{tcbraster}
 }

 \begin{document}
 \chapter{Introduction}
 \lipsum

 \chapter{Some very long title with many words and terms}
 \lipsum

 \end{document}

enter image description here

enter image description here

0

The below given MWE will set it for you:

\documentclass{book}
\usepackage{lipsum}
\usepackage{tcolorbox,array}
\makeatletter
\def\thickhrulefill{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\@makechapterhead#1{%
  \reset@font
  \parindent \z@
  \vspace*{10\p@}%
  \def\xwidth{5cm}%
  \def\xsep{1pc}%
  \global\setbox0=\vbox{\begin{tcolorbox}[center title,left=0pt,right=0pt,top=5pt,bottom=5pt,colback=black, colframe=black,enlarge left by=0mm,boxsep=5pt,arc=0pt,outer arc=0pt,width=\textwidth+\xwidth]
       \parbox{\dimexpr(\textwidth-\xwidth-\xsep-\xwidth)}{\raggedright\fontsize{14pt}{18pt}\selectfont \color{white}#1}%
   \end{tcolorbox}}
  \begin{tabular}{@{}m{\xwidth}@{\hspace{\xsep}}m{\dimexpr(\textwidth-\xwidth-\xsep)}@{}}
   \begin{tcolorbox}[center title,left=5pt,right=0pt,top=5pt,bottom=5pt,, colback=red, colframe=red,enlarge left by=0mm,boxsep=5pt,arc=0pt,outer arc=0pt,width=\xwidth,height=\the\ht0-2.1mm]
       \fontsize{14pt}{18pt}\selectfont \textcolor{white}{\@chapapp{} \thechapter }
   \end{tcolorbox}
      &
      \box0
\end{tabular}
}

\begin{document}
\chapter{Introduction}
\lipsum[1]

\chapter{Some very long title with many words and terms}
\lipsum[1]

\chapter{Some very long title with many words and terms Some very long title with many words and terms}
\lipsum[1]

\end{document}

Please note that there is two command \xwidth and \xsep which will set the width of red box and sep between red and black box respectively. You can change it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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