tags:

views:

568

answers:

4

I am creating a pdf file with Latex via pdflatex and want to have have headlines with ragged text, while the rest of the document should use justified text.

This gives me an error (! LaTeX Error: Something's wrong--perhaps a missing \item):

\usepackage{ragged2e}

..

\flushleft
\chapter{Something}
\justifying

And this one messes up the vertical spacing:

{\raggedright{\chapter{Something}}}

Any idea here? Thanks in advance!

+1  A: 

\chapter, \section and so on can have quite complicated definitions in the standard classes, which sometimes interact badly with attempts to force their formatting this way.

Read the descriptions of the standard classes to find out what variable you can didle to affect the way the headings look.

Your best bet might be to look on CTAN for an alternate class (memoir, maybe) that support what you want out-of-the-box.

dmckee
+2  A: 

Use the sectsty package and use \chapterfont{\raggedright} to make all chapter headings left justified. See the sectsty manual for how to do more interesting things. If sectsty is not powerful enough, titlesec can be used. Beyond that, you can redefine the sectioning commands.

Cirno de Bergerac
Awsome, that worked. I might add that these do the job for section titles: \sectionfont{\raggedright} \subsectionfont{\raggedright} \subsubsectionfont{\raggedright}
Jakob
A: 

Note that you're on the right track loading ragged2e and using the \RaggedRight command instead of LaTeX's default \raggedright. It gives much better output some of the time, although it does hyphenate words; depending on the design of your headings that may or may not be acceptable to you.

Either way, go with @sgm's answer of using titlesec. (It's as easy to use as sectsty, and more powerful...sectsty is only good for very basic redefinitions like changing the font.)

Will Robertson
A: 

About three years ago, tired of having an assortment of packages shooting each other in the feet, and each one needing tweaking in its own special way, I switched everything to memoir.

I have never looked back.

Brent.Longborough