2
\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?

1 Answer 1

1

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}%
     }
\setsecheadstyle{\ruledsec}
\begin{document}
\section {Test Section}

Some text here
\end{document}

enter image description here

4
  • 1
    \nobreak should be after \par, not after \vspace.
    – egreg
    Commented Oct 13, 2015 at 10:53
  • @egreg: I have to be careful but you know, I am not. :). Thanks.
    – user11232
    Commented Oct 13, 2015 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
    – peppino
    Commented Oct 13, 2015 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
    Commented Oct 13, 2015 at 23:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .