1

I'm using memoir with the \book, \chapter, and \section sectioning macros.

Each book contains several chapters, each chapter contains several sections, followed by a single "Practical Reflections" section containing a paragraph or two, followed by a single "Prayer" section containing a paragraph or two.

These are always at the very end of each chapter, there are always one of them, and they're always in this order.

What sectioning/dividing macro or other macro would be appropriate to mark these off, giving me the flexibility to insert a title and style the title and content in a separate place from the content that they will contain?

3
  • Should the Practical Reflections and Prayer headers be typeset in the same format as ordinary section headers? The reason I ask is that you use the term "section" for these special headers, and \section is a somewhat specific term in LaTeX. Separately, do you already use fleurons and other printers' marks in your document, or would using them introduce entirely new (and potentially distracting) stylistic elements?
    – Mico
    Aug 25 '15 at 18:40
  • You can put off the formatting till later if you define something like \newcommand{\PrayerSection}[1]{\subsection*{#1}}. Instead of the starred section command you could create your own, since you don't need numbering, just spacing and font: \par\bigskip\noindent\emph{#1}\par\medskip Aug 25 '15 at 19:21
  • @Mico No they should be typeset differently. I'll edit the question to specify this, thanks for bringing it up. And no I do not currently have fleurons or similar, but yes I would prefer to use them.
    – Steven
    Aug 25 '15 at 22:19
3

You got three options depending on what changes to the layout you maybe want to make later:

1. Change only the title text

In this case define

\newcommand{\prayername}{Prayer}
\newcommand{\practrefname}{Practical refelctions}

and use them withe the desired sectioning command, e.g.

\chapter{My Chapter (Way 1)}
Text
\section{Normal Section}
Text
\section{\prayername}
Prayer Text
\section{\practrefname}
Practical Reflections Text

2. Make a macro to format the title

You can define a macro to format the special headers, if it’s possible that you later want to change their appearance to distinct them from regular sections. You may combine this solution with #1 and you can define a single macro to format both headlines the same way or one for each headline; I’ll show just one combined with #1:

\newcommand{\specialsec}[1]{% Version A
   \section*{#1}%
}
\newcommand{\specialsec}[1]{% Version B
   \section[#1]{\sffamily\itshape#1}%
}
\makeatletter
\newcommand{\specialsec}[1]{% Version C
   \par\addvspace{2\baselineskip}
   \noindent\rule{3em}{0.5pt}
   \par\vspace{0.5\baselineskip}
   \noindent{\sffamily\bfseries\itshape#1\par}
   \vspace{0.5\baselineskip}
   \@afterheading
}
\makeatother

Usage as above but with:

\specialsec{\prayername}
Prayer Text
\specialsec{\practrefname}
Practical Reflections Text

3. Make an environment

If you want to format not only the headline but the text too, you can define an environment (or two). This can be combined with #1 and/or #2:

\newenvironment{SpecialSection}{% Version A
   \par
   \itshape\sffamily
}{
   \par
}
\usepackage{mdframed,xcolor}% Version B and C
\newenvironment{SpecialSection}{% Version B
   \begin{mdframed}[backgroundcolor=lightgray]
}{
   \end{mdframed}
}
\usepackage{mdframed,xcolor}% Version B and C
\newenvironment{SpecialSection}[1]{% Version C
   \begin{mdframed}[backgroundcolor=lightgray, frametitle=#1]
}{
   \end{mdframed}
}

Usage:

% Version A and B
\begin{SpecialSection}
   \specialsec{\prayername}
   Prayer Text
\end{SpecialSection}
\begin{SpecialSection}{\prayername}
   Prayer Text
\end{SpecialSection}

I hope this give you some guide line on how to implement it. The actual layout of my solutions is rather beautiful ;-)

I didn’t say anything about how or why I did the actual formatting, but feel free to ask anything in the comments …


Full Code for #1–#3 to play around with

\documentclass{book}

% #1
\newcommand{\prayername}{Prayer}
\newcommand{\practrefname}{Practical Reflections}

% #2
\newcommand{\specialsec}[1]{% Version A
   \section*{#1}%
}
%\newcommand{\specialsec}[1]{% Version B
%   \section[#1]{\sffamily\itshape#1}%
%}
%\makeatletter
%\newcommand{\specialsec}[1]{% Version C
%   \par\addvspace{2\baselineskip}
%   \noindent\rule{3em}{0.5pt}
%   \par\vspace{0.5\baselineskip}
%   \noindent{\sffamily\bfseries\itshape#1\par}
%   \vspace{0.5\baselineskip}
%   \@afterheading
%}
%\makeatother

% #3A
%\newenvironment{SpecialSection}{% Version A
%   \par
%   \itshape\sffamily
%}{
%   \par
%}
\usepackage{mdframed,xcolor}% Version B and C
%\newenvironment{SpecialSection}{% Version B
%   \begin{mdframed}[backgroundcolor=lightgray]
%}{
%   \end{mdframed}
%}
\newenvironment{SpecialSection}[1]{% Version C
   \begin{mdframed}[backgroundcolor=lightgray, frametitle=#1]
}{
   \end{mdframed}
}

\begin{document}

\chapter{My Chapter (Way 1)}
Text
\section{Normal Section}
Text
\section{\prayername}
Prayer Text
\section{\practrefname}
Practical Reflections Text

\chapter{My Chapter (Way 2)}
Text
\section{Normal Section}
Text
\specialsec{\prayername}
Prayer Text
\specialsec{\practrefname}
Practical Reflections Text

\chapter{My Chapter (Way 3, Version A and B)}
Text
\section{Normal Section}
Text
%\begin{SpecialSection}% works only when version A or B is active
%   \specialsec{\prayername}
%   Prayer Text
%\end{SpecialSection}
%\begin{SpecialSection}
%   \specialsec{\practrefname}
%   Practical Reflections Text
%\end{SpecialSection}

\chapter{My Chapter (Way 3, Version C)}
Text
\section{Normal Section}
Text
\begin{SpecialSection}{\prayername}
   Prayer Text
\end{SpecialSection}
\begin{SpecialSection}{\practrefname}
   Practical Reflections Text
\end{SpecialSection}

\end{document}

4. Another solution with some nicer format for both sections and two different environments:

\documentclass{book}

\usepackage{mdframed,xcolor}

\newcommand{\prayername}{Prayer}
\newcommand{\practrefname}{Practical Reflections}

\mdfdefinestyle{specialsecbase}{
   hidealllines = true,
   leftline = true,
   linewidth = 3pt,
   frametitlefont = \sffamily\bfseries,
   frametitleaboveskip = 0pt,
   innerbottommargin = 2.5pt,
}

\newenvironment{Prayer}{
   \begin{mdframed}[
      style = specialsecbase,
      frametitle=\prayername,
   ]
}{
   \end{mdframed}
}
\newenvironment{PracRef}{
   \begin{mdframed}[
      style = specialsecbase,
      linecolor = gray,
      frametitle=\practrefname
   ]
}{
   \end{mdframed}
}

\usepackage{lipsum}% for blindtext

\begin{document}


\chapter{My Chapter (Way 4)}
Text
\section{Normal Section}
Text
\begin{Prayer}
   \lipsum[1]
\end{Prayer}
\begin{PracRef}
   \lipsum[2]
\end{PracRef}

\end{document}

result

1
  • @sdegutis: I added another solution with two different environments for your special sections, but it’s i quite impossible to define a nice layout without knowing how the rest of your book looks, so it’s up to you to either look at mdframed’s manual to change the style or implement it using another package ;-)
    – Tobi
    Aug 26 '15 at 10:49

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.