Document ClassesChange book for sections/chapter marks

Information and discussion about specific document classes and how to create your own document classes.
Post Reply
jean88
Posts: 12
Joined: Sat Jan 09, 2010 10:52 pm

Change book for sections/chapter marks

Post by jean88 »

I hope this is the right section for this question. I need to change the format of the chapter marks.

Code from book.cls

Code: Select all

\def\@makechapterhead#1{%
  \vspace*{50\p@}%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \huge\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 20\p@
      \fi
    \fi
    \interlinepenalty\@M
    \Huge \bfseries #1\par\nobreak
    \vskip 40\p@
  }}
Changing this for my needs isn't a problem but when I 'm using this with apacite \bibliography layout keeps the ancient layout from the book class. Can this be solved?

Another question. I need to change the section and subsections in this was.
1.2.3 Test Section
where Test would be aligned left to the margin. (1.2.3 is in the margin)

Any ideas?

Recommended reading 2024:

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

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

Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Change book for sections/chapter marks

Post by Stefan Kottwitz »

Hi Jean,

welcome to the board!
I recommend to redefine the macro \@makeschapterhead too, because \bibliography is using the starred macro \chapter*.

Concerning \section etc. you could redefine the \section macro and change the \@startsection parameters there.

But have a look at the titlesec package, this package is very useful for changing the design of chapter or section titles.

Stefan
LaTeX.org admin
jean88
Posts: 12
Joined: Sat Jan 09, 2010 10:52 pm

Change book for sections/chapter marks

Post by jean88 »

For some reason this won't work. (I just made a few minor changes to test)

Code: Select all

\documentclass{book}
\makeatletter
\def\@makechapterhead#1{%
  {\parindent \z@ \raggedright \normalfont
    \ifnum \c@secnumdepth >\m@ne
      \if@mainmatter
        \huge\bfseries \@chapapp\space \thechapter
        \par\nobreak
        \vskip 10\p@
      \fi
    \fi
    \interlinepenalty\@M
		\bfseries #1\par\nobreak
    \vskip 40\p@
  }}
\makeatother
\begin{document}
\chapter{Test chapter}
\nocite{*}
\bibliographystyle{plain}
\bibliography{referenties}
\end{document}
Titlesec won't display a title for the bibliography at all. At least, I got the sections in a sort of layout I want for my memoir.

Code: Select all

\documentclass{book}
\usepackage[explicit]{titlesec}

\titleformat{\section}[block]
  {\normalfont\sffamily} %format
  {\begin{tabbing} \=\=  \kill \> \thesection \' \> #1 \end{tabbing}} %label
  {0pt} %sep
  { } %before 
	{}%after

\titlespacing*{\section}
  {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\titleformat{\subsection}[block]
  {\normalfont\sffamily} %format
  {\begin{tabbing} \=\=  \kill \> \thesubsection \' \> #1 \end{tabbing}} %label
  {0pt} %sep
  { } %before 
	{}%after

\titlespacing*{\subsection}
  {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\titleformat{\chapter}[block]
  {\normalfont\sffamily} %format
  {\begin{tabbing} \=\=  \kill \> \thechapter \' \> #1 \end{tabbing}} %label
  {0pt} %sep
  { } %before 
	{}%after

\titlespacing*{\chapter}
  {0pt}{3.5ex plus 1ex minus .2ex}{2.3ex plus .2ex}

\begin{document}

\chapter{Test chapter}
\section{Test section}
\subsection{Test subsection }

\nocite{*}
\bibliographystyle{plain}
\bibliography{referenties}

\end{document}
Many thanks in advance.
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Change book for sections/chapter marks

Post by Stefan Kottwitz »

You did not redefine \@makeschapterhead but only \@makechapterhead.

Stefan
LaTeX.org admin
jean88
Posts: 12
Joined: Sat Jan 09, 2010 10:52 pm

Change book for sections/chapter marks

Post by jean88 »

Thx, that works. Any idea why titlesec won't do that? For the moment I need to change chapters in that way en the sections with titlesec. If I want to change the sections without titlesec I suppose change must be made in the \@sectionstart command. In which file can I find that command?
User avatar
Stefan Kottwitz
Site Admin
Posts: 10345
Joined: Mon Mar 10, 2008 9:44 pm

Re: Change book for sections/chapter marks

Post by Stefan Kottwitz »

You will find the definition of \@startsection in the file latex.ltx.

Stefan
LaTeX.org admin
jean88
Posts: 12
Joined: Sat Jan 09, 2010 10:52 pm

Change book for sections/chapter marks

Post by jean88 »

I found it here: C:\MiKTeX 2.8\tex\latex\ltxmisc\section.sty

Seems very difficult to change that. I ll keep the titlesec solution. For the titlesec solution I have one more question:

Code: Select all

\titleformat{\chapter}[block]
  {\normalfont\sffamily} %format
  {\begin{tabbing} \=\=  \kill \> \thechapter \' \> #1 \end{tabbing}} %label
  {0pt} %sep
  { } %before
   {}%after
From the examples I found I'm a bit confused with the last three arguments. What do they stand for when using option "block"?

Anyway, thanks for the already provided answers.


EDIT: another litle question. If I want to use another font for everything (including the titlesec definitions) is there a way to do that? And if I need an Arial or Times New Roman font?
jean88
Posts: 12
Joined: Sat Jan 09, 2010 10:52 pm

Change book for sections/chapter marks

Post by jean88 »

I have some problems with the spacing. Adding a tabbing environment in the title headings adds space before and after that environment. Is there a way to set the space before and after to 0 points so I can use the \titlespacing*{\subsection}{0pt}{0pt}{14pt} as a normal spacing?

PS: I solved my question:
From the examples I found I'm a bit confused with the last three arguments. What do they stand for when using option "block"?
jean88
Posts: 12
Joined: Sat Jan 09, 2010 10:52 pm

Change book for sections/chapter marks

Post by jean88 »

jean88 wrote: Another question. I need to change the section and subsections in this was.
1.2.3 Test Section
where Test would be aligned left to the margin. (1.2.3 is in the margin)
Just for the community. I solved my problem with titlesec (which caused layout problems) :

Code: Select all

%BEGIN: hanging section numbers http://tug.org/pipermail/texhax/2005-November/005054.html
\makeatletter
  \def\@seccntformat#1{%
       \protect\makebox[0pt][r]{%
              \csname  the#1\endcsname\quad}}
\makeatother
%END
Post Reply