Line Breaks and Justification in LaTeX

In this post, we will look at line breaks and justification in LaTeX. These tools will provide a user with more nuanced command of their document.

Paragraph Break

By leaving a space between paragraphs in your document LaTeX will start a new paragraph. Below is the code followed by the output.

\documentclass{article}
\begin{document}
Hello, here is some text without a meaning. This text should show what a printed text will look like at this place. If you read this text, you will get no information.

Really?

Is there no information?

Is there a difference between this text and some nonsense like “Huardest gefburn”?

Kjift – not at all!

A blind text like this gives you information about the selected font.
\end{document}

1.png

Notice how each paragraph is indented. This is the default setting in LaTex. To remove indentation you need to use the “\noindet” declaration as shown below.

\documentclass{article}
\begin{document}
Hello, here is some text without a meaning. This text should show what a printed text will look like at this place. If you read this text, you will get no information.

\noindent

Really?
\noindent

Is there no information?
\noindent

Is there a difference between this text and some nonsense like “Huardest gefburn”?
\noindent

Kjift – not at all!
\noindent

A blind text like this gives you information about the selected font.
\end{document}

1.png

In this example, only the first paragraph is indented.

A simpler way to do this is with the short command line break \\. Below is what it looks like

\documentclass{article}
\begin{document}
Hello, here is some text without a meaning. This text should show what a printed text will look like at this place. If you read this text, you will get no information.\\
Really?\\
Is there no information? \\
Is there a difference between this text and some nonsense like “Huardest gefburn”? \\
Kjift – not at all! \\
A blind text like this gives you information about the selected font.
\end{document}

1

You can see that both “\noindent” and the short command \\ get the same results. However, the latter is probably more efficient and perhaps easier to read.

Justification

There are also ways to remove the default setting for justification. The three declaration are “\raggedright”, “\raggedleft”, and “\centering”. The “\raggedright” declaration makes the right side of the page ragged while the left side of the page is justified as shown below.

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
{\raggedright
\Blindtext}
\end{document}

1.png

You can clearly see how the right side is truly ragged. The other packages in the code create the demo paragraph automatically for us.

The “\raggedleft” declaration does the opposite. See below

\documentclass{article}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
{\raggedleft
\Blindtext}
\end{document}

1.png

I think we already know what centering does.

\documentclass{article} 
\usepackage[english]{babel} 
\usepackage{blindtext} 
\begin{document} 
{\centering 
\Blindtext} 
\end{document}

1.png

Conclusion

This post provided a demonstration of line breaks and justification in LaTeX.

Leave a Reply