How to wrap section titles when using wordlike?

I have a template based on the wordlike package. When I have a long section title, it extends beyond the edge of the page instead of wrapping to a newline (like this). Here's the code:

\documentclass[12pt]{article}

% Emulate MS Word
\usepackage{wordlike}

% One inch margins
\PassOptionsToPackage{margin=1in}{geometry}

% Double spacing
\usepackage{setspace}
\setstretch{2}

% Don't justify along the right margin
\usepackage{ragged2e}
\RaggedRight

% Format section titles
\usepackage[uppercase]{titlesec}
\titlespacing\section{0pt}{0pt}{7pt}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\bf\center\uppercase}{\underline{\thesection.\
}}{1em}{\underline}

% Format paragraphs
\parskip 0pt
\setlength{\parindent}{0.5in}

% Remove section numbers
\setcounter{secnumdepth}{-2}

\begin{document}

\section{Here's an example of a long section title that is going to stretch beyond the page}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\end{document}


If I try to force a line break with \\, I get this error: Something's wrong--perhaps a missing \item.

-

1 Answer

The problem is not due to wordlike; standard \underline doesn't admit line breaks; use \uline from ulem, instead:

\documentclass[12pt]{article}

% Emulate MS Word
\usepackage{wordlike}
\usepackage[normalem]{ulem}

% One inch margins
\PassOptionsToPackage{margin=1in}{geometry}

% Double spacing
\usepackage{setspace}
\setstretch{2}

% Don't justify along the right margin
\usepackage{ragged2e}
\RaggedRight

% Format section titles
\usepackage[uppercase]{titlesec}
\titlespacing\section{0pt}{0pt}{7pt}
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\bfseries\filcenter}{\uline{\thesection.\ }}{0em}{\uline}

% Format paragraphs
\parskip 0pt
\setlength{\parindent}{0.5in}

% Remove section numbers
\setcounter{secnumdepth}{-2}

\begin{document}

\section{Here's an example of a long section title that is not going to stretch beyond the page due to the changes}

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

\end{document}


Using bold-faced underlined headings seems redundant, and it's not a very good practice.

-
I agree, but unfortunately the doc I'm writing (a legal memo) requires it. – Joe Mornin Jul 19 '13 at 19:07
@JosephMornin I see. Well, in some cases one is tied to obey ugly requirements ;-) – Gonzalo Medina Jul 19 '13 at 19:12