How to add and remove indentation of paragraph in LaTeX like first line or whole paragraph?

LaTeX gives you ability to control the way your paragraphs appear.

This tutorial aims to represent simple way, how you can format paragraphs and to be specific, aspect of paragraph formatting that we will be investigating is paragraph indentation.

We can do this locally or globally. LaTeX provides us following commands and environment for paragraph indentation.

\indent and \noindent
\hspace{length}
\parindent and \hangindent
 noindent environment

Default paragraph indent

By default, LaTeX provides a certain amount of indentation for all paragraphs.

\documentclass{article}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.\\[6pt]
Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
\end{document}

Output :

LaTeX, when using a paragraph, will have a light space before the first line of each paragraph. which is shown in this figure.

Use \indent command

To add a gap or an indentation to a particular paragraph, we can make use of the \indent command. And this command forces indentation at the beginning of a paragraph. It produces a certain amount of space.

\documentclass{article}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \\[6pt]
\indent \verb|\indent| Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. \\[6pt] 
\indent \indent \verb|\indent \indent| Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source. \\[6pt]
\indent \indent \indent \indent \verb|\indent \indent \indent \indent| There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.
\end{document}

Output :

Space after using the indent command will not change. If you use the indent command more than once, multiple spaces will be created.

Putting This command twice return as doubles space. Command can be used multiple times to acquire desired indentation space.

You can notice that the default indentation space is same as placing \indent.

Use \hspace command to customize length

Another command to use to add indentation of desire length to a paragraph is \hspace*{length}. With this command we can both add positive and negative lengths.

For example let’s see what will happen if we apply \hspace*{1.5cm} and \hspace{-1.5cm}.

\documentclass{article}
\begin{document}
\hspace{1.5cm} \verb|\hspace{1.5cm}| Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \\[6pt]
\hspace{-1.5cm} \verb|\hspace{-1.5cm}| Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.\\[6pt] 
\hspace{5em} \verb|\hspace{5em}| Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.\\[6pt]
\hspace{-17pt} \verb|\hspace{-17pt}| There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.
\end{document}

Output :

You can customize the space to increase or decrease it as you like, and use negative indents. This requires the \hspace command, which is nicely represented in this image.

As we can see, first paragraph is indented 1.5cm positively by the \hspace*{1.5cm} and second paragraph has a negative indentation of -1.5cm by same command.

Use \perindent and \hangindent command

So far the commands we have seen show us how to indent our paragraphs locally (within our text).

Next two commands will show us how to both indent our paragraphs locally (within our text) and globally(throughout all the document). We have

\parindent – length parameter
\hangindent – length parameter

The two commands above are basically length parameters and to use them, a length is passed to each of them using the \setlength command as follows

\setlength{\parindent}{length}
\setlength{\hangindent}{length}

Putting a length in the length argument e.g 1cm, 1em, 2cm, 2em etc and placing it in the preamble will automatically adjust every paragraph to be indented to that specified length.

When placed within the document will adjust paragraphs within that portion of document to be indented to the specified length.

\documentclass{article}
\setlength{\parindent}{3cm}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\verb|\par| \\[6pt] \par
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.\verb|\par| \\[6pt] \par
Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.\verb|\par| \\[6pt] \par
There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.
\end{document}

Output :

Use \setlength command to customize the indent space to decrease and increase.

\par indicates a new paragraph. As we can see from the output, \setlength{\parindent}{2cm} in the preamble format all paragraphs to be indented 2cm.

Let’s set how to achieve indentation within our body of text.

\documentclass{article}
\begin{document}
\setlength{\parindent}{2cm} \verb|\setlength{\parindent}{2cm}| Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.\verb|\par| \\[6pt] \par
 Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old.\verb|\par| \\[6pt] \par
\setlength{\parindent}{1cm} \verb|\setlength{\parindent}{1cm}| Richard McClintock, a Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.\\[6pt]
\setlength{\parindent}{3cm} \verb|\setlength{\parindent}{3cm}| There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.
\end{document}

Output :

Same with \perindent, you can customize the indent space to decrease and increase.

Looking at result from our code, you will notice that first two paragraphs are 2cm indented and the third paragraph is 1cm.

This example shows us how to define multiple indentations in your work using \parindent.

Below is an example of a hanging indentation.

\documentclass{article}
\begin{document}
\setlength{\hangindent}{3cm} \verb|\setlength{\parindent}{3cm}| Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \\[6pt]
\setlength{\hangindent}{3cm} \verb|\setlength{\parindent}{3cm}| Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Contrary to popular belief, Lorem Ipsum is not simply random text. It has roots in a piece of classical Latin literature from 45 BC, making it over 2000 years old. \\[6pt]
\setlength{\hangindent}{1cm} \verb|\setlength{\parindent}{1cm}| A Latin professor at Hampden-Sydney College in Virginia, looked up one of the more obscure Latin words, consectetur, from a Lorem Ipsum passage, and going through the cites of the word in classical literature, discovered the undoubtable source.\\[6pt]
\setlength{\hangindent}{4cm} \verb|\setlength{\parindent}{4cm}| There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in some form, by injected humour, or randomised words which don't look even slightly believable.
\end{document}

Output :

\hangindent command leaves first line of a paragraph and creates a space before the rest of line.

\hangindent above ignores the first line and indents the rest of the text in the paragraph 3cm.

Remove indentation

LaTeX will return you the default indent when you enter a paragraph in the document.

There are times when you will want to remove default indent, for this three methods are discussed below.

1. Use \noindent command before paragraph

First method is very simple, use \noindent command before the paragraph. If using more than one paragraph, use the same command before each paragraph.

\documentclass{article}
\begin{document}
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \\[6pt]
\noindent Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. 
\end{document}

Output :

LaTeX creates a default space that you can remove if you want. Its use is shown in this figure.

2. Use noindent environment

Another provision LaTeX gives us is noindent environment. All paragraph indentations from text placed within this environment are automatically disabled.

\documentclass{article}
\begin{document}
\begin{noindent}Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{noindent}\\[6pt]

\begin{noindent}
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{noindent}
\end{document}

Output :

In addition to the noindent command, there are environments with the same name that are used for similar tasks.

Above output has a light indent before second paragraph. It can be called syntactic error.

Because the environment’s \begin{noindent} command and paragraph are positioned on the same line, the indent will not show. As in the first paragraph.

3. Assign length \parindent 0cm

A need to disable paragraph indent may arise. There is a way to automatically remove paragraph indentation from a block of text or from the entire document.

To do this, assign the length 0cm to \parindent in the \setlength command.

\documentclass{article}
\setlength{\parindent}{0cm}
\begin{document}
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. \\[6pt]
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
\end{document}

Output :

You can also complete removing indents using the \parindent command. In this case the length should be zero.

Conclusion

This tutorial examines carefully with examples the different possibilities of adding indentations to paragraphs and how to automatically remove indentations.

Paragraph formatting is one of the most important concepts necessary to know in order to produce beautiful text and a mastery of this tutorial will make it easy to achieve that.

Md Jidan Mondal

LaTeX expert with over 10 years of experience in document preparation and typesetting. Specializes in creating professional documents, reports, and presentations using LaTeX.

Leave a Comment

Your email address will not be published. Required fields are marked *