Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 3 down vote accepted

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}

enter image description here

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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.