For a paper I have to make my LaTeX document guideline conforming. Many of you will already guess now that this means dirty work by violating virtually all possible typography standards.

My biggest problem is concerning section headings. They have to be:

• Capitalized
• Underlined
• Centered
• Have roman numerals
• The bibliography should not be appended a section number.

I tried to achieve this using the sectsty package and since that did not work out gave the titlesec package a shot, both with and without the ulem package.
However, no combination worked. The problem occurs in any way when you give the option underlined.

Here is a minimal example with the sectsty package:

\documentclass{scrartcl}

\usepackage{ucs}
\usepackage[utf8x]{inputenc}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%% Get stupid underlining for headings right
\usepackage[]{ulem}

\usepackage{sectsty}
\sectionfont{\MakeUppercase\rmfamily\center\underline}

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


How can I make those headings conform to the rules? Would it probably even be the easiest way to manually write the headings, without a command at all?

-
Are you allowed to fiddle with the sectioning command and/or include packages as needed? I know that some journal restrict the use of external packages, or have a list of "approved packages" that you can use. –  Werner Aug 29 '11 at 16:09
Yes I am, all I have to do is hand in a PDF. –  Ingo Aug 29 '11 at 16:16
I think this question deserves the starred-version tag. I had to drop another tag and chose sectsty. –  lockstep Sep 3 '11 at 11:22
Quoting from page 5 of the manual of the sectsty package: "The documentation for this package is written with the standard LATEX classes in mind, so might not [tee] up exactly to the KOMA-script classes. Despite that, and despite differences in behaviour when things go wrong, sectsty should work as expected with the KOMA-script classes." I guess you're encountering an instance when this isn't the case... –  Mico Sep 3 '11 at 17:22
On second thought, this question is also not specific to koma-script, but shows how to solve a horizontal-alignment problem. –  lockstep Sep 3 '11 at 23:30

Building on Gonzalo's answer: Use the numberless key to define the starred version of \section.

\documentclass{scrartcl}

\usepackage[explicit]{titlesec}
\usepackage[normalem]{ulem}
\usepackage{lipsum}

\titleformat{\section}
{\normalfont\Large\sffamily\bfseries\filcenter}{}{0em}{\uline{\thesection\hspace*{ 1em}\MakeUppercase{#1}}}
\titleformat{name=\section,numberless}
{\normalfont\Large\sffamily\bfseries\filcenter}{}{0em}{\uline{\MakeUppercase{#1}}}

\renewcommand*{\thesection}{\Roman{section}}

\begin{document}

\section{Test Section}

\lipsum[1]

\begin{thebibliography}{9}
\bibitem{A01} A. Author. \emph{Alpha}. 2001.
\end{thebibliography}

\end{document}


-
Thanks, you just made my day! –  Ingo Sep 3 '11 at 11:25
@Ingo: But not enough to upvote, let alone accept, my answer? ;-) –  lockstep Sep 3 '11 at 11:33
@Ingo: Note that upvoting, accepting, and awarding bounty all have to be done separately. –  lockstep Sep 4 '11 at 8:34
I'm sorry, must have forgotten that in a rush :). –  Ingo Sep 4 '11 at 9:58
A rush of happiness, I presume. :-) –  lockstep Sep 4 '11 at 9:58

Here's a simple solution using the ulem package and the explicit option for titlesec:

\documentclass{scrartcl}

\usepackage[explicit]{titlesec}
\usepackage[normalem]{ulem}
\usepackage{lipsum}

\titleformat{\section}
{\normalfont\Large\sffamily\bfseries\filcenter}{\uline{\thesection\hspace*{ 1em}}}{0em}{\uline{\MakeUppercase{#1}}}

\renewcommand*{\thesection}{\Roman{section}}

\begin{document}
\section{Test Section}

\lipsum[1]

\begin{thebibliography}{9}
\bibitem{A01} A. Author. \emph{Alpha}. 2001.
\end{thebibliography}

\end{document}


-
Nice and clean solution - the explicit package option is the key here. –  Werner Aug 29 '11 at 18:01
I thank you very much, Gonzalo! Whatever it takes to comply with those ... nice ... requirements. –  Ingo Aug 30 '11 at 10:16
One more question, though. Why do prefer titlesec over sectsty? –  Ingo Aug 30 '11 at 10:47
@Ingo Gerth: with the explicit option for titlesec one has access to the title as a parameter, so it is easy to apply \ulem to it. –  Gonzalo Medina Aug 30 '11 at 11:44
Gonzalo, thank you very much again. However, it so happens that this causes the bibliography to have a section number, whereas it should not. You can easily try this out. Is there any workaround for this? –  Ingo Sep 3 '11 at 10:54
\documentclass{article}
\usepackage{fontspec}
\usepackage{lipsum}

\begin{document}
\thispagestyle{empty}
\font\uc="Times New Roman" at 12pt
\begin{center}
\underbar{\uc{But it may be enough to get you started, at least. }}
\end{center}
\lipsum[1]

\begin{thebibliography}{9}
\bibitem{A01} A. Author. \emph{Alpha}. 2011.
\end{thebibliography}

\end{document}

-
You forgot to load lipsum (I did it in my edit) and loaded some irrelevant packages (I deleted them). Notice that your solution doesn't number the sections and doesn't allow for labelling. You should also mention (although fontspec makes it clear) that your code needs to be run with xelatex. –  Gonzalo Medina Sep 9 '11 at 13:17