Graphics, Figures & Tablestable width to span textwidth

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
jafar
Posts: 4
Joined: Wed Sep 22, 2010 7:46 am

table width to span textwidth

Post by jafar »

I am attempting to achieve the chapter heading layout in the attached image.

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}
Thanks
Attachments
chapterfirstpage.jpg
chapterfirstpage.jpg (118.32 KiB) Viewed 2278 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Post Reply