My first issue was that the background color should stretch across the entire textwidth. I tried \colorbox without the tabular environment but that resulted in several issues:
1) There was a separation between the chapter number and chapter title.
2) I could not make the chapter title's background extend across the textwidth.
Therefore, I used the tabular environment, using p{11cm} to force the column to be longer than the text in the column. I can fiddle with the value of 11cm to get better results if I need.
Unfortunately, using p{11cm} causes the row height to expand. This does not happen when I'm using l or r options.
What can I do to achieve what I need?
Here is my code:
Code: Select all
\documentclass[a4paper,openany]{amsbook}
\usepackage{color}
\usepackage{array}
\usepackage{colortbl}
\definecolor{Dark}{gray}{.20}
\definecolor{Light}{gray}{.40}
\makeatletter
\renewcommand{\@makechapterhead}[1]{%
\vspace*{50 pt}%
{\setlength{\parindent}{0pt} \raggedright \normalfont
\bfseries\Large
\begin{tabular}{|>{\color{white}\columncolor[gray]{.2}}r|>{\color{white}%
\columncolor[gray]{.6}}p{11cm}}
\thechapter & #1
\end{tabular}
\par\nobreak\vspace{40 pt}}}
\makeatother
\begin{document}
\chapter{XYZ}
\section{Introduction}
Body text here
\end{document}