1.6.12

How to format the chapter heading?


Depends on your level of expertise, if you are more comfortable with packages then usingtitlesec as suggested by Seamus in the comments is a good choice. If you are here to learn a bit more about the innards of LaTeX you can use the code below, which uses the LaTeX@makechapterhead and @makeschapterhead macros (note the make(s) in the latter). The one is used to handle the normal version of chapter and the other the starred version. It is good practice to update both of them when you are developing or modifying a class. The code can be found in book.cls.
enter image description here
\documentclass[oneside]{book}
\usepackage[english]{babel}
\usepackage{lipsum}
\makeatletter
\def\thickhrule{\leavevmode \leaders \hrule height 1ex \hfill \kern \z@}
\def\position{\centering}
%% Note the difference between the commands the one is 
%% make and the other one is makes
\renewcommand{\@makechapterhead}[1]{%
  \vspace*{10\p@}%
  {\parindent \z@ \position \reset@font
        {\Huge \scshape  \thechapter }
        \par\nobreak
        \vspace*{10\p@}%
        \interlinepenalty\@M
        \thickhrule
        \par\nobreak
        \vspace*{2\p@}%
        {\Huge \bfseries #1\par\nobreak}
        \par\nobreak
        \vspace*{2\p@}%
        \thickhrule
    \vskip 40\p@
    \vskip 100\p@
  }}
%% This uses makes
\def\@makeschapterhead#1{%
  \vspace*{10\p@}%
  {\parindent \z@ \position \reset@font
        {\Huge \scshape \vphantom{\thechapter}}
        \par\nobreak
        \vspace*{10\p@}%
        \interlinepenalty\@M
        \thickhrule
        \par\nobreak
        \vspace*{2\p@}%
        {\Huge \bfseries #1\par\nobreak}
        \par\nobreak
        \vspace*{2\p@}%
        \thickhrule
    \vskip 100\p@
  }}
\begin{document}
\chapter{The Real Numbers}
\lipsum[1-2]
\chapter*{The Imaginary Numbers}
\lipsum[1-2]
\end{document}

Here's an example using titlesec.
\documentclass{book}
\usepackage{titlesec}
\titleformat{\chapter}[display]
{\normalfont\bfseries\filcenter}
{\LARGE\thechapter}
{1ex}
{\titlerule[2pt]
\vspace{2ex}%
\LARGE}
[\vspace{1ex}%
{\titlerule[2pt]}]
\begin{document}
\chapter{The real numbers}
\end{document}

Some example code can be found here: http://web.slzm.de/blog/latex/schone-kapiteltitelseiten-in-latex/

1 comentario:

  1. El Blog Del Latex Fino: Latex, Beamer Y Otras Cosas Útiles By The Latex Expert!: How To Format The Chapter Heading? >>>>> Download Now

    >>>>> Download Full

    El Blog Del Latex Fino: Latex, Beamer Y Otras Cosas Útiles By The Latex Expert!: How To Format The Chapter Heading? >>>>> Download LINK

    >>>>> Download Now

    El Blog Del Latex Fino: Latex, Beamer Y Otras Cosas Útiles By The Latex Expert!: How To Format The Chapter Heading? >>>>> Download Full

    >>>>> Download LINK Il

    ResponderEliminar