# Memoir ruled section centering problem

\documentclass[twocolumn]{memoir}

\setaftersecskip{0em}
\setsecheadstyle{\large \normalfont \bfseries \centering \MakeUppercase }
\setsecnumformat{  \csname  the#1\endcsname\par\nobreak \rule{\columnwidth}{0.2mm}  \par\nobreak }

\begin{document}
\section {Test Section}
\end{document}


The section title should be centered as the number.

May be \centering stops his effect after first \par (tried to change with \\ but no effect) in \setsecnumformat, I don't know how to restore it or to make it effective for the whole title. Any hint?

May be this is what you are after.

\documentclass[twocolumn]{memoir}

\setaftersecskip{0em}
\setsecnumformat{\csname  the#1\endcsname\par\nobreak\vspace{-0.55\baselineskip} \rule{\columnwidth}{0.2mm}\par\nobreak }

\newcommand{\ruledsec}[1]{%
\large \bfseries \centering \MakeUppercase{#1} \par\vspace{0.55\baselineskip}%
}
\begin{document}
\section {Test Section}

Some text here
\end{document}


• \nobreak should be after \par, not after \vspace. Oct 13 '15 at 10:53
• @egreg: I have to be careful but you know, I am not. :). Thanks.
– user11232
Oct 13 '15 at 10:59
• wonderful! would you have also some explanation for it? why did you put the code for secheadstyle in a new command? many thanks Oct 13 '15 at 19:56
• @peppino Actually you needed a \par after the section title so that \centering is applied to the title too. The use of \newcommand made this possible. Also, the space after the title could be controlled easily this way. In a nut shell, the use of new command enabled us to use \par\vspace{0.55\baselineskip} after \MakeUppercase{#1}.
– user11232
Oct 13 '15 at 23:13