Text FormattingChapter Headings protrude into Margin

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
mayankmi
Posts: 45
Joined: Sat Apr 20, 2013 7:52 pm

Chapter Headings protrude into Margin

Post by mayankmi »

I'm using the "Bjornstrup" style from the fncychap package for fancy chapter headings. Everything is OK so far. It's just the chapter number goes out of margins. The attachment shows what I mean. I tried few things but they don't work. I want the chapter number inside margin (see attachment).

Thanks
Attachments
Screen Shot 2013-06-11 at 2.36.05 PM.png
Screen Shot 2013-06-11 at 2.36.05 PM.png (42.81 KiB) Viewed 5646 times

Recommended reading 2024:

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

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

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Chapter Headings protrude into Margin

Post by Johannes_B »

Would you be so kind to provide your code (for your exaample above) in form of a Minimal Working Example using the code button? Right now we all could just guess.
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Chapter Headings protrude into Margin

Post by localghost »

The code for the "Bjornstrup" style (as for any other provided style) can be found in the sources of the package (*.sty). The macro \DOCH is responsible for the main formatting of the chapter heading. Copying its definition and commenting the relevant line yields the desired result.

Code: Select all

\documentclass[11pt]{report}
\usepackage[T1]{fontenc}
\usepackage{geometry}
\usepackage[Bjornstrup]{fncychap}
\usepackage{blindtext}

\renewcommand{\DOCH}{%
  \settowidth{\py}{\CNoV\thechapter}
%  \addtolength{\py}{-10pt}      % Amount of space by which the
%                                % number is shifted right
  \fboxsep=0pt%
  \colorbox[gray]{.85}{\rule{0pt}{40pt}\parbox[b]{\textwidth}{\hfill}}%
  \kern-\py\raise20pt%
  \hbox{\color[gray]{.5}\CNoV\thechapter}\\%
}

\begin{document}
  \blinddocument
\end{document}
Click on "Open in writeLaTeX" in the head of the above code box to see the result instantly. Next time please do your homework and prepare a self-contained and minimal example.


Thorsten
Post Reply