1

I would like to write my chapter number behind the word 'chapter', but I'm having the following problems.

  1. The number is written in front of 'CHAPTER' (I would like it to be behind -- red behind blue)
  2. I have used raisebox and makebox to position the number, but I'm having problems positioning the number in the center behind 'CHAPTER'.

The problematic case is shown below.

enter image description here

\documentclass{memoir}
\usepackage{graphicx}                
\graphicspath{{graphics/}}
\usepackage{tikz}
\newcommand\numlifter[1]{\raisebox{0.6cm}[0pt][0pt]{\smash{#1}}}
\newcommand\numindent{\kern37pt}
\newlength\chaptertitleboxheight

\makeatletter
\makechapterstyle{mychapterstyle}{
    \chapterstyle{default}
    \def\format{\normalfont}
    \setlength\beforechapskip{0mm}
    \renewcommand*{\chapnamefont}{\format\small}
    \renewcommand*{\chapnumfont}{\format\HUGE}
    \renewcommand*{\chaptitlefont}{\format\Huge}
    \renewcommand*{\printchaptername}{\chapnamefont\MakeUppercase{\@chapapp}}
    \patchcommand{\printchaptername}{\begingroup\color{blue}}{\endgroup}
    \renewcommand\printchapternum{%
    \begingroup%
    \leavevmode%
    \chapnumfont%
    \color{red}%
    \itshape
    \strut%
    \numlifter{\makebox[\linewidth][l]{\thechapter}}
    \numindent%
    \endgroup%
}

\setlength\midchapskip{1ex}
\renewcommand*{\printchaptertitle}[1]{\raggedleft \chaptitlefont ##1}
\renewcommand*{\afterchaptertitle}{\vskip0.5\onelineskip \hrule \vskip1.3\onelineskip}
}
\makeatother

\chapterstyle{mychapterstyle}


\begin{document}
\chapter{foo}
Hi everyone :)
\end{document}
1

Number centered behind chapter name string

\documentclass{memoir}
\usepackage{graphicx}
\graphicspath{{graphics/}}
\usepackage{tikz}
\newcommand\numlifter[1]{\raisebox{0.6cm}[0pt][0pt]{\smash{#1}}}
\newcommand\numindent{\kern37pt}
\newlength\chaptertitleboxheight

\makeatletter
\makechapterstyle{mychapterstyle}{%
  \chapterstyle{default}%
  \def\format{\normalfont}%
  \setlength\beforechapskip{0mm}%
  \renewcommand*{\chapnamefont}{\format\small}%
  \renewcommand*{\chapnumfont}{\format\HUGE}%
  \renewcommand*{\chaptitlefont}{\format\Huge}%
  \renewcommand*{\printchaptername}{%
    \textcolor{blue}{\chapnamefont\MakeUppercase{\@chapapp}}%
  }%
  \renewcommand*{\printchaptername}{%
    \sbox0{%
      \color{blue}%
      \chapnamefont
      \MakeUppercase{\@chapapp}%
    }%
    \sbox2{%
      \color{red}%
      \chapnumfont
      \itshape
      \thechapter
    }%
    \leavevmode
    \rlap{%
      \hbox to \wd0{%
        \hfill
        \raisebox{\dimexpr.5\ht0 - .5\ht2\relax}{\usebox{2}}%
        \hfill
      }%
    }%
    \usebox{0}%
  }%
  \renewcommand*{\printchapternum}{}%
  \renewcommand*{\chapternamenum}{}%
  \setlength\midchapskip{1ex}%
  \renewcommand*{\printchaptertitle}[1]{\raggedleft \chaptitlefont ##1}%
  \renewcommand*{\afterchaptertitle}{%
    \vskip0.5\onelineskip
    \hrule
    \vskip1.3\onelineskip
  }%
}
\makeatother

\chapterstyle{mychapterstyle}

\begin{document}
\chapter{foo}
Hi everyone :)
\end{document}

Result

Older version with number following name

\documentclass{memoir}
\usepackage{graphicx}
\graphicspath{{graphics/}}
\usepackage{tikz}
\newcommand\numlifter[1]{\raisebox{0.6cm}[0pt][0pt]{\smash{#1}}}
\newcommand\numindent{\kern37pt}
\newlength\chaptertitleboxheight

\makeatletter
\makechapterstyle{mychapterstyle}{%
  \chapterstyle{default}%
  \def\format{\normalfont}%
  \setlength\beforechapskip{0mm}%
  \renewcommand*{\chapnamefont}{\format\small}%
  \renewcommand*{\chapnumfont}{\format\HUGE}%
  \renewcommand*{\chaptitlefont}{\format\Huge}%
  \renewcommand*{\printchaptername}{%
    \textcolor{blue}{\chapnamefont\MakeUppercase{\@chapapp}}%
  }%
  \renewcommand*{\printchapternum}{%
    \sbox0{\chapnamefont CHAPTER}%
    \sbox2{%
      \color{red}%
      \chapnumfont
      \itshape
      \thechapter
    }%
    \raisebox{\dimexpr.5\ht0 - .5\ht2\relax}{\copy2}%
  }%
  \setlength\midchapskip{1ex}%
  \renewcommand*{\printchaptertitle}[1]{\raggedleft \chaptitlefont ##1}%
  \renewcommand*{\afterchaptertitle}{%
    \vskip0.5\onelineskip
    \hrule
    \vskip1.3\onelineskip
  }%
}
\makeatother

\chapterstyle{mychapterstyle}

\begin{document}
\chapter{foo}
Hi everyone :)
\end{document}

Result

Disclaimer: The layout is not my taste:

  • Too many colors.
  • Too many font sizes.
  • No clear baseline.
  • All uppercase.

I recommend to simplify the layout, this is often much better.

| improve this answer | |
  • I think the OP means that the number is suppose to be in the background of the word chapter. Like llap num chapter. I want an example of this in the memoirchapstyles example doc – daleif Sep 4 '15 at 15:52
  • @daleif Thanks, answer updated with a version, where the number is centered in the background of the chapter name. – Heiko Oberdiek Sep 4 '15 at 16:01
  • Also see the Hansen style in the link I added to the question. I have an example of this is the memoir chapter style show case doc. – daleif Sep 4 '15 at 16:04
  • @HeikoOberdiek The colors were just to illustrate the problem, but thanks for the tips...and what did you mean by no clear baseline? – Overclover Sep 4 '15 at 16:32
  • @Asagen The different baseline issue only applies to the latter example, where the number follows the chapter name. – Heiko Oberdiek Sep 4 '15 at 16:34
0

If you can use tikz, it is very easy.

\documentclass{memoir}
\usepackage{graphicx}
\graphicspath{{graphics/}}
\usepackage{tikz}

\makeatletter
\makechapterstyle{mychapterstyle}{
    \chapterstyle{default}
    \def\format{\normalfont}
    \setlength\beforechapskip{0mm}
    \renewcommand*{\chapnamefont}{\format\small}
    \renewcommand*{\chapnumfont}{\format\HUGE}
    \renewcommand*{\chaptitlefont}{\format\Huge}
    \renewcommand*{\printchaptername}{%
    \begin{tikzpicture}
    \node[text=red,font=\chapnumfont\itshape] (a){\thechapter};
    \node[text=blue,font=\chapnamefont] at (a.center){\MakeUppercase{\@chapapp}};
    \end{tikzpicture}%
    }
    \renewcommand\printchapternum{}

\setlength\midchapskip{1ex}
\renewcommand*{\printchaptertitle}[1]{\raggedleft \chaptitlefont ##1}
\renewcommand*{\afterchaptertitle}{\vskip0.5\onelineskip \hrule \vskip1.3\onelineskip}
}
\makeatother

\chapterstyle{mychapterstyle}


\begin{document}
\chapter{foo}
Hi everyone :)
\end{document}

enter image description here

| improve this answer | |
  • Thanks, I liked this answer also, but I chose the other one as it shows how to solve this problem without resorting to tikz. If I had more reputation I would have given you a vote :) – Overclover Sep 4 '15 at 16:34

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.