Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I see in memoir that \section is implemented like so:

\newcommand{\section}{%
  \sechook%
  \@startsection{section}{1}%  level 1
      {\secindent}%            heading indent
      {\beforesecskip}%        skip before the heading
      {\aftersecskip}%         skip after the heading
      {\normalfont\secheadstyle}} % font
\newcommand{\sechook}{}
\newcommand{\setsechook}[1]{\renewcommand{\sechook}{#1}}
\newlength{\secindent}
\newcommand{\setsecindent}[1]{\setlength{\secindent}{#1}}
  \setsecindent{\z@}
\newskip\beforesecskip
\newcommand{\setbeforesecskip}[1]{\setlength{\beforesecskip}{#1}}
  \setbeforesecskip{-3.5ex \@plus -1ex \@minus -.2ex}
\newskip\aftersecskip
\newcommand{\setaftersecskip}[1]{\setlength{\aftersecskip}{#1}}
  \setaftersecskip{2.3ex \@plus .2ex}
\newcommand{\secheadstyle}{}
\newcommand{\setsecheadstyle}[1]{\renewcommand{\secheadstyle}{#1}}
%%%  \setsecheadstyle{\Large\bfseries\raggedright}
  \setsecheadstyle{\Large\bfseries\memRTLraggedright}

I thought I'd try color'izing my section numbers, and first tried:

\renewcommand{\sechook}{\color{blue}}

This didn't work, since the scope of the blue was everything after and including the section. Next I tried:

\setsecheadstyle{\color{blue}\Large\bfseries\memRTLraggedright}

This is better, but color'izes the section number and the section title. I can't see in the \section implementation above where the counter is, so I think I'm looking in the wrong place.

Here's a MWE for my busted attempt:

\documentclass[openany]{memoir}
\usepackage{color}

\setsecheadstyle{\color{blue}\Large\bfseries\memRTLraggedright}

\begin{document}

\chapter{Foo}
\section{blah}
\section{stuff}
\subsection{more stuff}
\subsubsection{even more stuff}

\end{document}

This produces

attempt at colorizing

I also see that I've lost subsection and subsubsection numbers (which I had with the book class). So two questions:

  • How can I get back my sub and subsub section numbers?
  • How would one color just the section numbers (and subsection numbers once I get them back)?
share|improve this question

1 Answer 1

up vote 4 down vote accepted

To control the level up to which sectional units will be numbered, you can use \setsecnumdepth{<sectional unit>}; to color the sectional unit numbers, you can use \setsecnumformat:

\documentclass[openany]{memoir}
\usepackage{xcolor}

\setsecnumformat{\color{blue}\csname the#1\endcsname\quad}
\setsecnumdepth{subsubsection}

\begin{document}

\chapter{Foo}
\section{blah}
\section{stuff}
\subsection{more stuff}
\subsubsection{even more stuff}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.