0

I want to write chapter title as attached. For that this code doesn't work for me. Any suggestion:

\documentclass{memoir}
\usepackage[T1]{fontenc}
\usepackage{kpfonts}
\setSingleSpace{1.1}
\SingleSpacing
\usepackage{xcolor,calc, blindtext}
\definecolor{chaptercolor}{gray}{0.8}
% helper macros
\newcommand\numlifter[1]{\raisebox{-2cm}[0pt][0pt]{\smash{#1}}}
\newcommand\numindent{\kern37pt}
\newlength\chaptertitleboxheight
\makechapterstyle{hansen}{
  \renewcommand\printchaptername{\raggedleft}
  \renewcommand\printchapternum{%
    \begingroup%
    \leavevmode%
    \chapnumfont%
    \strut%
    \numlifter{\thechapter}%
    \numindent%
\endgroup%
}
  \renewcommand*{\printchapternonum}{%
    \vphantom{\begingroup%
      \leavevmode%
      \chapnumfont%
      \numlifter{\vphantom{9}}%
      \numindent%
      \endgroup}
    \afterchapternum}
  \setlength\midchapskip{0pt}
  \setlength\beforechapskip{0.5\baselineskip}
  \setlength{\afterchapskip}{3\baselineskip}
  \renewcommand\chapnumfont{%
    \fontsize{4cm}{0cm}%
    \bfseries%
    \sffamily%
    \color{chaptercolor}%
  }
  \renewcommand\chaptitlefont{%
    \normalfont%
    \huge%
    \bfseries%
    \raggedleft%
  }%
  \settototalheight\chaptertitleboxheight{%
    \parbox{\textwidth}{\chaptitlefont \strut bg\\bg\strut}}
  \renewcommand\printchaptertitle[1]{%
    \parbox[t][\chaptertitleboxheight][t]{\textwidth}{%
      %\microtypesetup{protrusion=false}% add this if you use microtype
      \chaptitlefont\strut ##1\strut}%
}}
\chapterstyle{hansen}
\aliaspagestyle{chapter}{empty} % just to save some space
\begin{document}
\chapter{Hansen Memoir Chapter Style}
\blindtext
\end{document}

enter image description here

  • What exactly doesn't work for you (i.e. what errors or result do you get)? – remco Apr 5 '18 at 13:48
  • ! LaTeX Error: File `kpfonts.sty' not found. Type X to quit or <RETURN> to proceed, or enter new name. (Default extension: sty) Enter file name: iqra.tex (./iqra.tex ! LaTeX Error: Two \documentclass or \documentstyle commands. See the LaTeX manual or LaTeX Companion for explanation. Type H <return> for immediate help. ... l.1 \documentclass{ memoir} ? – Higgs Apr 5 '18 at 13:57
  • So you don't have the package "kpfonts" installed. Perhaps download and install it? (I know it's part of the TeXlive distribution, so it should be available on CTAN). With that package installed, your code works for me with PdfLatex, XeLatex and LuaLatex. – remco Apr 5 '18 at 14:04
  • by adding only \usepackage{kpfonts} will not work? – Higgs Apr 5 '18 at 14:20
  • In MikTeX (Windows), if you request a package that is not installed, then the program will attempt to download and install it. In texlive (Windows, Linux, Mac), if you request a package that is not installed, then the program does NOT attempt to get it for you; instead, an error results. – user139954 Apr 5 '18 at 14:59

Your Answer

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

Browse other questions tagged or ask your own question.