Add indentation on paragraph in LaTeX
LaTeX by default generates some space or indentation when you write a paragraph but in some cases, LaTeX does not identify the paragraph. Hence, you have to add a particular amount of indentation.
In this tutorial, you will learn how to indentate manually on a paragraph and change the default amount globally. Also, get different styles of indentation on paragraphs.
Add indentation globally on paragraphs in LaTeX
You can set a specific amount of indentation for every paragraph globally. To get this you have to use the \setlength{\parindent}{<len>}
command in the preamble of your document.
In <len>
you can set any unit value that is accepted in LaTeX. And make sure to use the \par
command at the end of every paragraph. Then there will be no problem detecting paragraphs by LaTeX.
\documentclass{article} \usepackage{lipsum} \setlength{\parindent}{1in} \begin{document} \lipsum[1][1-7]\par \lipsum[1][1-7]\par \lipsum[1][1-7] \end{document}
Output:
Add indentation locally on paragraphs in LaTeX
There are three methods of adding indentation to specific paragraphs in LaTeX.
- With
\indent
- With
\hspace{<len>}
- With
\setlength{\parindent}{<len>}
You can use these commands before any paragraph to get an indentation. Here the \indent
command is used to add a default amount of indentation and with the \hspace{<len>}
and \setlength{\parindent}{<len>}
command you can set a specific amount of space.
\documentclass{article} \usepackage{lipsum} \begin{document} \indent\verb|\indent|\lipsum[1][1-7]\par \hspace{1in}\verb|\hspace{1in}|\lipsum[1][1-7]\par \setlength{\parindent}{1.5in}\verb|\setlength{\parindent}{1.5in}|\lipsum[1][1-7] \end{document}
Output:
Add indentation whole section except the first line
In order to get this, you have to use the \setlength{\hangindent}{<len>}
command before the paragraph. Or you can use the hangparas
environment provided by the hanging
package.
This hangparas
environment allows you to select how many lines are not indented.
\begin{hangparas}{<len>}{<line-num>}
.....
\end{hangparas}
In the <line-num>
you can enter the number of lines not to be indented from the first.
\documentclass{article} \usepackage{lipsum} \usepackage{hanging} \begin{document} \setlength{\hangindent}{1cm}\noindent\lipsum[1][1-7]\par \begin{hangparas}{1.5cm}{2} \lipsum[1][1-7] \end{hangparas} \begin{hangparas}{0.75cm}{3} \lipsum[1][1-7] \end{hangparas} \end{document}
Output:
Leave a Reply