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.

The default format in latex for paragraphs is fully justified, where the first word of a line touches the left margin and the last word of a line is flush with the right margin.

This is nice for lines that are about as long as the width of the text area, but if there are few words, LaTeX will create large amounts of whitespace between the words so they touch both sides.

In a document editor like Word or Writer, when I set the format to fully justified, this only applies to lines within a certain range of the edge as in almost every line is fully justified unless a line is specifically shorter and in that case appears left justified.

Here's an example image comparing the two:

enter image description here

Is there a way to do the equivalent justification in LaTeX?

share|improve this question
10  
The default output from LaTeX is justified, but not in the way you show it. It would be really helpful if you could provide a minimal working example (MWE) that reproduces the LaTeX output you provide. This should start with \documentclass{...} and end with \end{document}. –  Werner Nov 28 '12 at 3:12
1  
This is not the default format in latex for paragraphs! Could you tell where you got that information? If it's from some online resource, it might be worthwile to try to get that changed. –  Stephan Lehmke Nov 29 '12 at 13:46
2  
Unfortunately, in any kind of typesetting scenario, any time, any where, TeX wins over Word, LibreOffice, Open Office etc. all combined. I say unfortunately because it would be a good pressure on the TeX side to take the competition seriously if any of these tools could implement TeX like optimization schemes. Right now, it's a matter of second place among those tools. Having said that, you are without a doubt, modifying some settings or a package is modifying erroneously. It's a typical MS Word artifact when you justify the paragraphs but no way in TeX. –  percusse Nov 29 '12 at 13:53
1  
Welcome to TeX.sx! Your post was migrated here from Stack Overflow. Please register on this site, too, and make sure that both accounts are associated with each other (by using the same OpenID), otherwise you won't be able to comment on or accept answers or edit your question. –  Werner Nov 29 '12 at 15:08
add comment

migrated from stackoverflow.com Nov 29 '12 at 13:25

This question came from our site for professional and enthusiast programmers.

1 Answer

up vote 12 down vote accepted

You are most likely loading a package or manually setting the value of \parfillskip. The definition of \parfillskip, from TeX for the Impatient (section on Shaping paragraphs, p 111):

This parameter specifies the horizontal glue that TEX inserts at the end of a paragraph. The default value of \parfillskip is 0pt plus 1fil, which causes the last line of a paragraph to be filled out with blank space. A value of 0pt forces TEX to end the last line of a paragraph at the right margin.

As an example, this is the effect:

enter image description here

\documentclass{article}
\newcommand{\fourscore}{\noindent Four score and seven years ago our fathers 
  brought forth on this continent a new nation, conceived in liberty, 
  and dedicated to the proposition that all men are created equal.\par}
\begin{document}
\fourscore
\setlength{\parfillskip}{0pt}
\fourscore
\end{document}

So, restoring it can either be done by finding the "offending" package, or adding

\setlength{\parfillskip}{0pt plus 1fil}

to your preamble. Without more information, it's difficult to assess how else to fix the problem.

share|improve this answer
    
TeX will scream about Underfull \hbox, right? –  Martin Schröder Nov 28 '12 at 7:50
1  
@MartinSchröder: You heard that too?! –  Werner Nov 28 '12 at 15:03
add comment

Your Answer

 
discard

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