# Customizing \chapter command

Here is the picture:

The code is from this post.

\documentclass[a4paper,12pt]{book}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{fontspec}
\usepackage{titlesec}
\setmainfont{EB Garamond 12 Regular}
\newfontfamily\cmaiusc[LetterSpace=40,WordSpace=2,RawFeature={+swsh,+dlig}]{EB Garamond 12 SC}

% Environments
\usepackage{setspace}
\newenvironment{comment}
{\begin{spacing}{0.8}\itshape\scriptsize\hspace{-1em}}
{\end{spacing}}

\newcommand{\bbook}[4][]{%
\makebox[\textwidth][c]{\includegraphics[width=6in]{#4}}
\chapter[#1]{#2,\\\large #3\\\char"2766}
\thispagestyle{empty}
\begin{center}
{\cmaiusc capitolo\ \roman{chapter}}.
\end{center}
}

\titleformat{\chapter}[hang]%
{\centering\huge}%
{}%
{0pt}%
{}
\titlespacing*{\chapter}
{0pt}{0pt}{5pt}

\begin{document}
\tableofcontents
\cleardoublepage\noindent                                      % from here
\begin{minipage}{\textwidth}

\begin{center}
\parbox{4.65in}{
\begin{comment}
comment
\end{comment}
}
\end{center}

\end{minipage}

\vspace{\baselineskip}                                         % to here

\lipsum[1-10]
\end{document}


Is possible replace the \bbook command in this code with the classic \chapter command but that incorporate all the code enclosed into the "from here" "to here" besides the commands of \bbook. So the "new" \chapter command should have four arguments, if is possible in the order shown below. In this example:

\chapter{genese_heading}{Analysis mathematica}{principia.}{comment}


I would that the "new" command \chapter goes into the headers and the \tableofcontents as the normal chapter command, but only with the second argument of it, in this example: "Analysis mathematica"

-
Please always mark your inline code using backticks  to as I did in my edit. –  doncherry Jul 21 '12 at 11:41
Don't do it. Many LaTeX functions rely on the original syntax of \chapter. –  egreg Jul 21 '12 at 12:54
@egreg oh, thanks, however is possible that the first argument of \bbook go into the headers and \tableofcontents ? –  FormlessCloud Jul 21 '12 at 13:11

I suggest this strategy:

\documentclass[a4paper,12pt]{book}
\usepackage{graphicx}
\usepackage{lipsum}
\usepackage{fontspec}
\usepackage{titlesec}
\setmainfont{EB Garamond}
\newfontface\cmaiusc[LetterSpace=40,WordSpace=2,RawFeature={+swsh,+dlig}]{EB Garamond Regular SmallCaps}

% Environments
\usepackage{setspace}
\newenvironment{chaptercomment}
{\centering
\begin{minipage}{.8\textwidth}
\centering
\begin{spacing}{0.8}
\itshape\scriptsize\ignorespaces}
{\end{spacing}\end{minipage}\par\bigskip}

\newcommand{\Chapter}[4][]{%
\chapter[\if\relax\detokenize{#1}\relax#2\else#1\fi]{%
\makebox[\textwidth][c]{\includegraphics[width=6in]{#4}}\\
#2,\\\large #3\\\char"2766}
\thispagestyle{empty}
\begin{center}
\cmaiusc capitolo\ \roman{chapter}.
\end{center}
}
\titleformat{\chapter}[display]%
{\centering\huge}%
{}%
{-40pt}%
{}
\titlespacing*{\chapter}
{0pt}{0pt}{5pt}

\begin{document}
\frontmatter

\tableofcontents

\mainmatter

\begin{chaptercomment}
\lipsum[2]
\end{chaptercomment}

\lipsum[1-10]

\end{document}


The input is simpler than before and the markup clearer.

If you say

\Chapter[Short title]{Long title}{subtitle}{image}


then "Short title" will go in the TOC and the headings, as usual, otherwise "Long title" will be used.

-
Thanks ! perfect ! is possible choose the \char"2766 for each chapter separately? and make the title of chapter in the table of contents in small caps like the memoir class ? –  FormlessCloud Aug 3 '12 at 9:31
@FormlessCloud To make title of chapter in Table of Contents small caps, use following code: \chapter*{Heading for chapter printed on page} \addcontentsline{toc}{chapter}{\textsc{Small Caps Title in ToC}}` –  Rafal Jun 2 at 14:54