2

I want to format my chapter title for example:

"Chapter one: Introduction"

I have a new command defined as the following:

\documentclass[a4paper,12pt] {report}
\usepackage{thesis_packages}

\newcommand{\ch}[2]{ 
\setcounter{chapter}{#1}
\setcounter{section}{0}
\chapter*{#2}}

\begin{document}

\include{introduction}
\end{document}


% introduction.tex
\ch{1}{Chapter One: Introduction}   \label{ch:intro}

For that, I need to write \ch{1}{Chapter One:intro} in the introduction.tex file. However,I receive an error says "undefined control sequence \ch{1}{Chapter One:intro}". The new command is defined in the main text file. I use report documentclass.

7
  • 1
    Welcome to TeX SX! What have you tried? Which document class do you use?
    – Bernard
    Jul 30 '17 at 21:34
  • @n.a.s: The update does not really clearify the problem. Do you use a book - like class at all, that has the \chapter command?
    – user31729
    Jul 30 '17 at 22:03
  • I am working on thesis, and I use report class.
    – n.a.s
    Jul 30 '17 at 22:04
  • There's a } missing after \chapter*{#2}. The content of introduction is still hidden.
    – user31729
    Jul 30 '17 at 22:15
  • 1
    The command you introduced is suicidal.
    – Johannes_B
    Jul 31 '17 at 5:25
2
\documentclass[a4paper,12pt]{report}

\makeatletter
\newcommand{\inletters}[1]{\ifcase \csname c@#1\endcsname
  zero\or one\or two\or three\or four\or five\or six\or seven\or
  eight\or nine\or ten %complete here if you have more than 10 chapters 
  \else ??\fi} 

\renewcommand{\@makechapterhead}[1]{\vspace*{50\p@}%
  {\parindent\z@ \raggedright \normalfont\Huge\bfseries
    \ifnum \c@secnumdepth>\m@ne \@chapapp~\inletters{chapter}: \fi
     #1\par\nobreak\vskip 40\p@}}

\def\@chapter[#1]#2{\ifnum \c@secnumdepth >\m@ne
    \refstepcounter{chapter}%
    \typeout{\@chapapp\space\thechapter.}%
    \addcontentsline{toc}{chapter}%
    {\@chapapp~\inletters{chapter}: #1}% <-- modification
  \else
    \addcontentsline{toc}{chapter}{#1}%
  \fi
  \chaptermark{#1}%
  \addtocontents{lof}{\protect\addvspace{10\p@}}%
  \addtocontents{lot}{\protect\addvspace{10\p@}}%
  \if@twocolumn
    \@topnewpage[\@makechapterhead{#2}]%
  \else
    \@makechapterhead{#2}%
    \@afterheading
  \fi}
\makeatother


\begin{document}

\chapter{Introduction}

In this chapter, ...

\section{First section}

\end{document}

enter image description here

enter image description here

7
  • This will print one, two etc. any occurence where \thechapter is expanded, i.e. in the ToC or in a reference
    – user31729
    Jul 30 '17 at 23:39
  • @Christian Hupfer: Thank you for the comment. This is corrected.
    – user94293
    Jul 31 '17 at 9:50
  • I can't upvote again, however ;-)
    – user31729
    Jul 31 '17 at 9:51
  • Thanks. How can I add the same chapter format in TOC?
    – n.a.s
    Jul 31 '17 at 10:05
  • @user94293 I tried your suggestion, it shows only number of chapter and the title. I want it to be similar to "Chapter One: Introduction" for instance. The word chapter also should be included!
    – n.a.s
    Jul 31 '17 at 10:44
4

The new command \ch seems to be unnecessary. To do what you want automatically, there are two things you need.

First, you need to print the chapter number in words instead of the usual numerals. To do this, load the fmtcount package. This will provide you with \numberstring and \Numberstring commands (for lowercase and capitalized respectively) to print the current value of a counter in words.

\usepackage{fmtcount}

Second, you need to slightly change the format of the chapter headings to put it all on one line. I expect there's a package for this purpose out there, but it's quite easy to do it by redefining \@makechapterhead yourself:

\makeatletter
\renewcommand{\@makechapterhead}[1]{\vspace *{50\p@ }{\parindent \z@ 
\raggedright \normalfont \ifnum \c@secnumdepth >\m@ne \Huge \bfseries 
\@chapapp \space \Numberstring{chapter} : \fi #1\par \nobreak \vskip 40\p@ }}
\makeatother

Then in the body of the document, you can use the \chapter command normally:

\chapter{First Chapter}

This is Chapter One.

Chapter One: First Chapter [vertical space] This is Chapter One.

4
  • +1 for the use of fmtcount
    – user94293
    Jul 30 '17 at 23:32
  • Thanks so much Freind. Using fmtcount package is really helpful. The problem is when I use this code in my latex project, an error appears says" an extra \else in \include{introduction}. Also I don't want section numering to appear as "one.1 section name"?
    – n.a.s
    Jul 31 '17 at 8:52
  • A \fi is missing before #1 in the definition of \@makechapterhead.
    – user94293
    Jul 31 '17 at 10:02
  • @n.a.s Sorry, I think those problems are corrected now. The first was due to the missing \fi pointed out above. The second was caused by \thechapter being used by the section commands. Aug 1 '17 at 17:36
2

You simply can use the tools from titlesec which make formatting of section titles easy. What you want is the block style:

\documentclass[a4paper,12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{geometry} 
\usepackage[letterspace=30]{microtype}
\usepackage{fmtcount}
\usepackage{titlesec}
\titleformat{\chapter}[block]{\Huge\bfseries\lsstyle}{\chaptername~\Numberstring{chapter}:}{0.333em}{}

\begin{document}

\chapter{Introduction}

In this chapter, ...

\end{document} 

enter image description here

To have the same (almost ;o)) in the table of contents, you can use \titletoc. As it gives access to the string \thecontentslabel, you have to convert this string to a number before you can use the fmtcount commands. This is done with one of the commands ending in num (\Numberstringnum, \numberstringnum, &c.):

\documentclass[a4paper,12pt]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fourier}
\usepackage{geometry}
\usepackage[letterspace=30]{microtype}
\usepackage{fmtcount}
\usepackage{titlesec, titletoc}
\titleformat{\chapter}[block]{\Huge\bfseries\lsstyle}{\chaptername~\Numberstring{chapter}:}{0.333em}{}

\titlecontents{chapter} [0em]{\bfseries} {\chaptername~the~Ordinalstringnum{\thecontentslabel}:\quad} 
{}{\hfill\contentspage} 

\begin{document}

\tableofcontents
\chapter{Introduction}

In this chapter, ...

\end{document} 

enter image description here

13
  • Thanks Bernad. This code works perfectly, but when I paste the line[\titleformat{\chapter}[block]{\Huge\bfseries\lsstyle}{\chaptername~\Numberstring{chapter}:}{0.333em}{}] into my main text file, I get an error: "undefined control sequence \chapter{introduction}".?
    – n.a.s
    Jul 31 '17 at 8:49
  • I used \titleformat[hang], and it works!. Thanks a lot. I will accept this as an answer.
    – n.a.s
    Jul 31 '17 at 9:20
  • hang is the default. The difference with block can be seen only with multilined titles. Actually, you're right, it's better than blockfor flushleft titles. The latter should be used for centred or flushright titles.
    – Bernard
    Jul 31 '17 at 9:49
  • Spacing lowercase? Oh, no! ;-)
    – egreg
    Jul 31 '17 at 9:54
  • @egreg: I think for very big sizes in boldface, this is tolerable. I don't like so much kerning in big titles, but I don't know how to deactivate it, so letter spacing is a work-around – which I use very sparingly…
    – Bernard
    Jul 31 '17 at 10:01
1

For reference/just for fun, here is how you can accomplish this in ConTeXt.

\setuphead
  [chapter]
  [conversion=Word,
   numbercommand=\NUMBERCOMMAND,
   style=\bfd]
\define[1] \NUMBERCOMMAND
  {Chapter #1:}

\starttext
  \chapter{Introduction}
  In this chapter, \periods
\stoptext
1
  • @9tTn98, can you please upvote the question if you find it useful? Thanks
    – n.a.s
    Jul 9 '18 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.