[Tex/LaTex] Section titles: single, centered roman numerals

roman numeralssectioningsections-paragraphs

As the title suggests, I want my section titles to be single, centered roman numerals. That's it, no actual section names.

Is that possible? If so, how might I do it?

Best Answer

The code snippet in \@sect (see the LaTeX format file latex.ltx)

#6{%
        \@hangfrom{\hskip #3\relax\@svsec}%
          \interlinepenalty \@M #8\@@par}%

is basically responsible for typesetting the section number and section title. #6 is actually a command from \@startsection and is related to font settings. \@svsec will do \the... effectively, i.e. the section number.

This has to be removed from the standard definition be replaced by

\centering 

#6{\sv@sec}%

Please note, that this would change any of the \section... commands and would leave entries in the ToC as well.

\documentclass{article}

\usepackage{xpatch}
\usepackage{blindtext}
\makeatletter
\renewcommand{\thesection}{\Roman{section}}
\xpatchcmd{\@sect}{%
     \begingroup
      #6{%
        \@hangfrom{\hskip #3\relax\@svsec}%
          \interlinepenalty \@M #8\@@par}%
    \endgroup
}{%
    \begingroup
    \centering 

    #6{\@svsec}%

    \endgroup
}{\typeout{Works}}{\typeout{Fails!}}
\makeatother
\begin{document}
\section{First}
\blindtext
\section{Second}
\blindtext
\section{}
\blindtext
\end{document}

enter image description here