[Tex/LaTex] Manual linebreak with justification but without empty line afterwards

line-breakingparagraphsspacing

What do I write at the end of a paragraph if my text is a couple letters short of being flush from left to right and I want the last line stretched slightly so that no empty space is left that the end?

If I do the obvious,

\documentclass{article}
\begin{document}

X Blah blah blah blah blah blah blah blah blah Blah blah blah blah blah
blah blah  blah  blah blah Blah blah blah blah blah blah blah blah. 

Y Blah blah blah blah blah blah blah blah blah Blah blah blah blah blah
blah blah blah blah blah Blah blah blah blah.

A Blah blah blah blah blah blah blah blah blah Blah blah blah blah blah
blah blah  blah  blah blah Blah blah blah blah blah blah blah blah. 
\linebreak
% Unwanted empty line appears here

B Blah blah blah blah blah blah blah blah blah Blah blah blah blah blah
blah blah blah blah blah Blah blah blah blah.
\end{document}

then an extra empty line appears after that and separate the paragraphs. How do I prevent this empty line from appearing?

To clarify: I would like to have two paragraphs, not one. Indeed getting rid of the paragraph break would remove the empty line between paragraphs when using manual line-break. But that would make A and B one paragraph instead of two.

See standard formatting in paragraphs X and Y.

Is there a way which does not require use of braces? Using braces might annoy those with whom I share article who want to revert to original formatting. Deleting all manual code of one type can be automated; but removing braces must be done manually since they are used in many places.

EDIT: Have any attempts to turn the command into one line added after the paragraph desired to be formatted or to automate this for whole document where last line has whitespace shorter than a certain length, like was discussed in Avoid just nearly filled last lines, been successful?

Best Answer

if the last line of your paragraph is really nearly full, you can get it to end flush right by the following approach.

  • wrap the paragraph in braces.

  • end the paragraph with these commands (inside the braces):

    \unskip\parfillskip 0pt \par
    

update: a mechanism that doesn't require braces.

  • before the paragraph, insert

    \startsquarepar
    
  • at the end of the paragraph, insert

    \stopsquarepar
    
  • define these two commands in the preamble as follows:

    \newcommand{\startsquarepar}{%
        \par\begingroup \parfillskip 0pt \relax}
    \newcommand{\stopsquarepar}{%
        \par\endgroup}
    

it's not necessary to have blank lines either before or after either of these commands (the grouping and included \par ensures that that's not a problem), but readability and "good practice" suggests that a blank line before \startsquarepar and one after \stopsquarepar is a good idea.

blank lines within the scope of \startsquarepar and \stopsquarepar will start new paragraphs as expected, and all paragraphs within this scope will end flush right -- whether or not there's the right amount of material in each paragraph to avoid excessive spacing.

why didn't i use \begin... and \end...? while there are no "strings" attached to \begin..., latex has co-opted the use of \end... for its own purposes in defining environments. if you really prefer the \begin ... \end terminology and environment syntax, it's easy to transform the two command definitions given into a single environment definition. (but left as an exercise to the reader.)

edit: one final suggestion from egreg's comment (to keep it from getting lost).

{{\parfillskip0pt\par}} can be a useful for a manual solution as it doesn't need bracing the paragraph.

Related Question