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 am using TexMaker to prepare my PhD dissertation and this is actually my first real experience with LaTeX!

I am using titlesec to customize my headings. However, for some reason, some of the headings run into the right margin. Could you please help me fix the problem?!

I have attached a simple example.

\documentclass[12pt]{report}

\usepackage[letterpaper]{geometry}
\geometry{verbose,tmargin=1.25in,bmargin=1.25in,lmargin=1.4in,rmargin=1.15in}
\pagestyle{plain}
\usepackage[doublespacing]{setspace}

\usepackage{titletoc}
\usepackage{titlesec}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\titleformat{\chapter}{\normalfont\Large\bfseries\fillast\singlespacing}{\thechapter}{1em}{}
\titleformat{\section}{\normalfont\large\bfseries\singlespacing}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\bfseries\singlespacing}{\thesubsection}{1em}{}

\begin{document}

\chapter{\MakeUppercase{Overview of the Notional All-Electric Ship Model}}

Text goes here.Text goes here.Text goes here.Text goes here.
Text goes here.Text goes here.Text goes here.Text goes here.
Text goes here.Text goes here.Text goes here.Text goes here.
Text goes here.

\end{document}
share|improve this question
    
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  tohecz Feb 21 '13 at 16:43
    
Just one suggestion. Have you considered using the title Notional All-Electric Ship Model Overview? It's shorter, so it could overcome the problem. Also it seems more to the point. –  Marc van Dongen Feb 21 '13 at 17:08

1 Answer 1

up vote 5 down vote accepted

Hyphenated words do not automatically hyphenate, and generally it is often a good idea with titles to line break by hand. However you don't want the uppercasing or line breaks in the table of contents or page head so move the uppercase to the format, and use the optional argument to supply a second version for the toc.

\documentclass[12pt]{report}

\usepackage[letterpaper]{geometry}
\geometry{verbose,tmargin=1.25in,bmargin=1.25in,lmargin=1.4in,rmargin=1.15in}
\pagestyle{plain}
\usepackage[doublespacing]{setspace}

\usepackage{titletoc}
\usepackage{titlesec}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\titleformat{\chapter}{\normalfont\Large\bfseries\fillast\MakeUppercase}{\thechapter}{1em}{}
\titleformat{\section}{\normalfont\large\bfseries\singlespacing}{\thesection}{1em}{}
\titleformat{\subsection}{\normalfont\bfseries\singlespacing}{\thesubsection}{1em}{}

\begin{document}

\chapter[Overview of the Notional All-Electric Ship Model]
          {Overview of the Notional\protect\\ All-Electric Ship Model}

Text goes here.Text goes here.Text goes here.Text goes here.
Text goes here.Text goes here.Text goes here.Text goes here.
Text goes here.Text goes here.Text goes here.Text goes here.
Text goes here.

\end{document}
share|improve this answer
    
Thank you so much David. I knew I could manually fix it, but I did not know what the problem was. So, the problem is that the word is hyphenated itself. –  Salman Feb 21 '13 at 18:18
    
@doncherry Thanks for the hint. I did accept his answer. –  Salman Mar 12 '13 at 20:07

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.