2

I am using memoir with xelatex for typesetting a book with multiple chapters and sections. I would like to include the book name (or part name), and chapter name above the section title for each section as shown below. How would I do this?

book name, chapter name, section name

The arrows and text in english is for highlighting the different styles.

Following the technique given in Daleif1 Theme : how to get part's title above chapter? I have been able to get it to work partially, with

    * Book * Part * Chapter
as the headings.

I have used psvectorian package for the ornaments.

Here is the code that I used:

\documentclass[a5paper,11pt,twoside,onecolumn,openany,final]{memoir}
\usepackage[a5paper,hmargin=0.7in,vmargin=0.75in]{geometry}
\usepackage{multicol,polyglossia,etoolbox,fontspec}
\usepackage{psvectorian}
%
\defaultfontfeatures{Mapping=tex-text}
\setmainlanguage{english}
\setotherlanguage{sanskrit}
\setmainfont{FreeSerif}
\newfontfamily{\englishfont}{FreeSerif}
\newfontfamily{\devanagarifont}[Script=Devanagari]{Sanskrit 2003}
% https://tex.stackexchange.com/questions/237695/how-to-specify-font-for-superscripts-using-ucharclasses-with-xelatex
\usepackage[Latin, Devanagari, SuperscriptsAndSubscripts]{ucharclasses}
\setTransitionTo{SuperscriptsAndSubscripts}{\englishfont}
\setTransitionFrom{SuperscriptsAndSubscripts}{}
%
\setTransitionTo{Devanagari}{\devanagarifont}
\setTransitionFrom{Devanagari}{\englishfont}
\setTransitionsFor{Latin}
  {\hyphenrules{english}\englishfont}
  {\hyphenrules{sanskrit}\devanagarifont}
\setTransitionsFor{Devanagari}
  {\hyphenrules{sanskrit}\devanagarifont}
  {\hyphenrules{english}\englishfont}
%
\setcounter{secnumdepth}{-1}
\renewcommand\secheadstyle{\centering\large\noindent}
\newcommand{\itibig}{\centerline{\psvectorian[height=2mm,width=4cm]{88}}}
\newcommand{\itimedium}{\centerline{\psvectorian[width=3cm]{84}}}
\newcommand{\itismall}{\centerline{\psvectorian[width=2cm]{49}}}
%
% https://tex.stackexchange.com/questions/199949/daleif1-theme-how-to-get-parts-title-above-chapter
\makeatletter
\makechapterstyle{mysection}{
  \chapterstyle{verville}
  \setlength\beforechapskip{-1cm}
  \setlength{\afterchapskip}{20pt}
  \renewcommand\printchaptertitle[1]{%
    {\centering\huge\noindent\currentbooktitle\itibig}
    {\centering\LARGE\noindent\currentparttitle}
    {\centering\Large\noindent##1\par\smallskip\itismall}
    }
}
\newcommand{\resetparttitle}{\gdef\currentparttitle{\strut}}
\resetparttitle
\makeatother

\chapterstyle{mysection}
\newcommand\newpart[1]{%
   %\phantomsection % if you use hyperref uncomment this line
   \addcontentsline{toc}{part}{#1}%
   \gdef\currentparttitle{#1\\}%
}
\newcommand\newbook[1]{%
   %\phantomsection % if you use hyperref uncomment this line
   \addcontentsline{toc}{book}{#1}%
   \gdef\currentbooktitle{#1\\}%
}

% https://groups.google.com/forum/#!topic/comp.text.tex/iIt_qxzTX5k

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\makeactive#1{\catcode`#1 = \active \ignorespaces}%
\chardef\letter = 11
\chardef\other = 12
\def\uncatcodespecials{%
   \def\do##1{\catcode`##1 = \other}%
   \dospecials
}%
\def\gobble#1{}%
%
\catcode`@ = \letter % So we can have private control sequences.
% ^^L (=formfeed,<FF>) 
\def^^L{\par}%
%
\begingroup
   \makeactive\^^M \makeactive\ %No spaces or ^^M's from here on. ^^M = linefeed
\gdef\obeywhitespace{%
\makeactive\^^M\def^^M{\par\futurelet\next\@finishobeyedreturn}%
\makeactive\ \def {\ }%
%
\aftergroup\@removebox%
\futurelet\next\@finishobeywhitespace%
}%
%
\gdef\@finishobeywhitespace{{%
\ifx\next %
\aftergroup\@obeywhitespaceloop%
\else\ifx\next^^M%
\aftergroup\gobble%
\fi\fi}}%
%
\gdef\@finishobeyedreturn{%
\ifx\next^^M\vskip\blanklineskipamount\fi%
\indent%
}%
\endgroup
%
\def\@obeywhitespaceloop#1{\futurelet\next\@finishobeywhitespace}%
%
\def\@removebox{%
   \setbox0 = \lastbox
   \ifdim\wd0=\parindent
     \setbox2 = \hbox{\unhbox0}%
     \ifdim\wd2=0pt
       \ignorespaces
     \else
       \box2 % Put it back: it wasn't empty.
     \fi
   \else
      \box0 % Put it back: it wasn't the right width.
   \fi
}%
\newskip\blanklineskipamount
%\blanklineskipamount = 0pt
\blanklineskipamount = -.8\baselineskip
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newenvironment{linewise}{\begingroup\obeywhitespace}{\endgroup}%
\RequirePackage{calc}
\newcommand{\setblankskip}[1]{\setlength{\blanklineskipamount}{-\baselineskip+#1}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 1 - indented to be in center of page - straight on left, right is ragged
   \newfontfamily{\devanagarifont}[Script=Devanagari]{Sanskrit 2003}
    \newcommand{\stotra}{\setlength{\leftskip}{0em}\setblankskip{5pt}\obeywhitespace}
    \newcommand{\bsanskrit}{\begin{stotra}}
    \newcommand{\esanskrit}{\end{stotra}}
\begin{document}
\newbook{अध्यात्मरामायण}
\newpart{सुन्दरकाण्ड}
\bsanskrit
\chapter{प्रथम सर्ग}
श्रीमहादेव उवाच ।

शतयोजनविस्तीर्णं समुद्रं मकरालयम् ।
लिलङ्घयिषुरानन्दसन्दोहो मारुतात्मजः ॥ १॥

ध्यात्वा रामं परात्मानमिदं वचनमब्रवीत् ।
पश्यन्तु वानराः सर्वे गच्छन्तं मां विहायसा ॥ २॥

अमोघं रामनिर्मुक्तं महाबाणमिवाखिलाः ।
पश्याम्यद्यैव रामस्य पत्नीं जनकनन्दिनीम् ॥ ३॥

कृतार्थोऽहं कृतार्थोऽहं पुनः पश्यामि राघवम् ।
प्राणप्रयाणसमये यस्य नाम सकृत्स्मरन् ॥ ४॥

नरस्तीर्त्वा भवाम्भोधिमपारं याति तत्पदम् ।
किं पुनस्तस्य दूतोऽहं तदङ्गाङ्गुलिमुद्रिकः ॥ ५॥
\chapter{द्वितीयः सर्गः}
\section{This is a section }
\esanskrit
\resetparttitle
\chapter*{PPP} % emulate the back matter such as the bibliography
\end{document}

The document now gives a blank page, before the first page, which I would like to delete. And the output of page 2 is as follows:

output of current code - page 2

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.