I am usingtikz package to produce a grey section-header bar (rounded at one end), thus:
\documentclass[a5paper]{memoir}
\setsecnumdepth{chapter} % set numbering level
\maxsecnumdepth{chapter} % default=section, 2
\setcounter{tocdepth}{1} % levels < {n} not in TOC
\usepackage[explicit]{titlesec}
\usepackage{tikz}
\usetikzlibrary{shapes.misc}
% create grey section header-bar
\let\currentsectiontitle\relax
\newcommand\titlebar{%sections
\tikz[baseline,trim left=3.1cm,trim right=3.0cm] {
\fill [black!15] (2.5cm,-1ex) rectangle (\textwidth+3.1cm,2.5ex);
\node [
fill=black!15!white,
anchor= base east,
rounded rectangle,
minimum height=3.5ex] at (2.8cm,0.13) {
% \color{black}{\thesection}
};
}}
\titleformat{\section}
{\large\bfseries}
{\titlebar}
{0.1cm}
{\gdef\currentsectiontitle{#1}#1} % http://glurl.co/dFH
\renewcommand*{\thesection}{\arabic{section}}
% start MWE
\begin{document}
\tableofcontents* % table of contents
% ------------------------
\mainmatter % document content
\chapter{Chapter 1}
\label{chapter1}
CHAPTER 1 intro
\section{Section 1}
\label{section1}
Section 1 intro
\chapter{Chapter 2}
\label{chapter2}
CHAPTER 2 intro
\section{Section 2}
\label{section2}
Section 2 intro
\end{document}
This originated from http://glurl.co/dFH (then reduced to eliminate redundant commands, by myself, using trial and error). I have remarked out the original command that placed section number in node at left end of section-header bar.
The problem I have is that when I set \maxsecnumdepth to {chapter}, which is what I want (so that sections are neither numbered in the text, nor in the TOC), the grey tikz section-header bar disappears—I suspect because the macro above depends upon the section being numbered.
Can anyone advise me on the most appropriate way to resolve this issue?
Please note: when running the MWE between the two settings (chapter / section) for \maxscnumdepth remember to compile twice to see the issue shift as described.
Thank you.
*My MWE produces the Chapter numbering twice. Not sure why.

\secnumdepthuses the format for the starred version, and you probably haven't provided a suitable format for that. – barbara beeton Aug 06 '14 at 16:52memoirto be more specific, but i hope this can help point the way for someone else. – barbara beeton Aug 06 '14 at 17:45titlesecis not really compatible withmemoir. – egreg Aug 06 '14 at 19:31