1

I'm using the memoir class I'm trying to customise the appearance of lower-level headings. In one case, what I want to accomplish is very simple: adding a period at the end of a heading title (for example, to emulate what amsart does for \subsection). I want the period to be added only to the displayed heading in the document, not in table of contents: that is a reason why I'm not willing to add the period manually at the end of each heading text.

I haven't found a way to do this using the functionality provided by the memoir class neither in the memoir guide nor searching the Internet. In fact, I believe the latest memoir guide implicitly states this is not possible. Section 6.6 reads:

The lower level heads — sections down to subparagraphs — are also configurable, but there is nothing corresponding to chapter styles. There are essentially three things that may be adjusted for these heads: (a) the vertical distance between the baseline of the text above the heading to the baseline of the title text, (b) the indentation of the heading from the left hand margin, and (c) the style (font) used for the heading title.

The most common (class-agnostic) way to deal with this kind of customizations in LaTeX is using the titlesec package but I've often read that titlesec is somewhat incompatible with memoir. I went through the memoir guide, though, and I couldn't find an incompatibility statement. On the contrary, the introduction to the eight edition states:

The class also provides functions similar to those provided by the following packages, although the commands are different: crop, fancyhdr, geometry, sidecap, subfigure, titlesec. You can use these packages if you wish, or just use the capabilities of the memoir class.

Which is the right way to do what this kind of customisations when using memoir? Are memoir and titlesec now compatible? If it they are, is it safe to mix memoir heading customisations (e.g.: \setsecheadstyle, \setaftersubsecskip) with titlesec's or should I stick with titlesec if I use it?

  • 1
    You have written a lot of text, so much that i didn't even read it. Can you provide a minimal example that puts the text into code? – Johannes_B Mar 22 '15 at 13:19
  • @Johannes_B, the essence of my question is "Is there a memoir-specific way to customise the appearance of the text of a lower level heads?" If I had working code for this one, I'd have answered my own question. I put a lot of text to cite the relevant information I have, especially because a lot of people say that titlesec is "incompatible" with memoir, and titlesec seems to be the only package people cite when solving this problem. – Enrico M. Crisostomo Mar 22 '15 at 13:37
  • Related: About memoir and titlesec incompatibility. – Alan Munn Mar 22 '15 at 13:40
  • Thanks @AlanMunn. I had seen this one during my search, and it exemplifies why I'd rather not use a package that breaks the functionality of the memoir class. However, I'm OK with it if that's the only side effect of using titlesec with memoir but I wasn't sure about it (hence, my question). Thank you! – Enrico M. Crisostomo Mar 22 '15 at 13:46
  • Do you har have a macro that adds a period if none us present? As far as I remember, the setsecheadstyle and friends allow you to specify as the last macro, a macro that takes one argument. For example \MakeUppercase. So you can do it that way. If you use titlesec then that package takes over and none of the memoir specific setting will be used (again as far as I know) – daleif Mar 22 '15 at 15:52
1

This might work. Not tested with hyperref!

Basically we dissect the memoir source code and use etoolbox to patch the macro. Note however, this does not include \section* and friends, that has to be done slightly differently, and omitted here.

\documentclass[a4paper]{memoir}
\usepackage{etoolbox}
\makeatletter
% adapted from from amsthm
\def\MY@addpunct#1{%
  \relax\ifhmode
    \ifnum\spacefactor>\@m \else#1\fi
  \fi}

\patchcmd{\M@sect}{\@M#9\@@par}{\@M#9\MY@addpunct{.}\@@par}{
  \typeout{\string\M@sect\space patched (1)}
}{
  \typeout{\string\M@sect\space not patched (1)}
}
\patchcmd{\M@sect}{\@svsec #9}{\@svsec#9\MY@addpunct{.}}{
  \typeout{\string\M@sect\space patched (2)}
}{
  \typeout{\string\M@sect\space not patched (2)}
}
\makeatother


\begin{document}

\section{test}

\end{document}

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.