[Tex/LaTex] Chapter heading with the word “chapter” replaced by chapter name

chaptersmemoirsectioning

When I create a chapter

\documentclass[12pt]{memoir}
\usepackage{graphicx}
\renewcommand{\chaptername}{}

\begin{document}
\chapterstyle{veelo}
\chapter{Implementation}
\section{Implementation2}
\end{document}

It displays it like

Chapter 1
Implementation

How can I make it display

Implementation 1

I tried doing this

\renewcommand{\chaptername}{}

But it just hides the word chapter and does display implementation and 1 in the same line.

Best Answer

The following minimal example provides a solution to your problem. It modifies the \chapter header printing macros to print the chapter title in place of the chapter name (Chapter or \@chapapp):

enter image description here

\documentclass[12pt]{memoir}% http://ctan.org/pkg/memoir
\usepackage{graphicx}% http://ctan.org/pkg/graphicx (required with veelo chapter style)
\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox

\makeatletter
\g@addto@macro\chs@veelo{%
  \renewcommand*{\printchaptername}[1]{%
    \chapnamefont\MakeUppercase{#1}}% Changed \@chapapp to #1; could also use \chaptitlefont
  \let\printchaptertitle\@gobble% Remove printing of chapter title.
}
\patchcmd{\@makechapterhead}% <cmd>
  {\printchaptername}% <search>
  {\printchaptername{#1}}% <replace>
  {}{}% <success><failure>
\makeatother

\begin{document}
%\tableofcontents
\chapterstyle{veelo}
\chapter{Implementation}
\section{Implementation2}
\end{document}

The veelo chapter style is stored in \chs@veelo, which defines the style in which the chapter title is printed. Appending (via \g@addto@macro) a renewed definition of \printchaptername (which now takes an argument), it replaces the former \@chapapp printing. If you want to maintain the former chapter title font, this can be modified to set it using \chaptitlefont. Additionally, the functionality of \printchaptertitle is removed (setting it to \@gobble).

\@makechapterhead actually sets the chapter heading. So, etoolbox is used to patch it and insert the newly created \printchaptername to take the supplied argument #1.

Related Question