Page LayoutCustom sec. heading causes incorrect breaks at the bottom

Information and discussion about page layout specific issues (e.g. header and footer lines, page formats, page numbers).
Post Reply
Dündar
Posts: 2
Joined: Tue Aug 03, 2010 6:42 am

Custom sec. heading causes incorrect breaks at the bottom

Post by Dündar »

I use the code below which makes section heading numbers in bold and the rest is normal as "II.2 Sample section title" which is what I want. But when I use this code just after some section titles page break occurs. If I do not use this code, the standard report class does not do this and working correctly. Why is the code below not working for page breaks? There seems Latex ignores nopagebreak command.

Code: Select all

\def\numberedsubsectionwithtwoarguments[#1]#2{%
    \ifhmode\par\fi
    \removelastskip
    \vspace*{12pt}\goodbreak
    \refstepcounter{subsection}%
    \noindent
    \leavevmode
    \begingroup
        \th@HdFnt\th@ScSz
        \thesubsection
        \th@SubSecFnt\th@ScSz
        \;\
        #2\quad
    \endgroup\nopagebreak[4]  
    \addcontentsline{toc}{subsection}{\protect\numberline{\thesubsection.}#1}}

Recommended reading 2024:

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

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

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

Custom sec. heading causes incorrect breaks at the bottom

Post by localghost »

When using the standard classes the best for customization of headings is to use the titlesec package. You should manage to get the desired output without the described problems.


Best regards and welcome to the board
Thorsten
Dündar
Posts: 2
Joined: Tue Aug 03, 2010 6:42 am

Custom sec. heading causes incorrect breaks at the bottom

Post by Dündar »

Yes I have solved the problem using the titlesec package. But it took so much time since the documentation is very complicated and there is not much examples on the net. With the two lines of code I have label and numbers in bold, title is normal.

Code: Select all

\RequirePackage{titlesec}

\titleformat{name=\subsection}[block]
{\bfseries}{\thesubsection.}{6pt}{\normalfont}
Post Reply