Imagine you are creating a document in LaTeX, and you notice that there is a small indent (spaced gap) at the beginning of the first line of each paragraph.
Now you are wondering, how can you remove this indent?
Don’t worry! I’ll explain a few methods in the simplest way, like a friend, so you can solve this problem quickly and easily.
Using the \noindent command
If you want to remove the indent for only one or two specific paragraphs, you can use the \noindent
command.
Simply add this command at the beginning of the paragraph where you want to remove the space.
\documentclass[a4paper,12pt]{article}
\begin{document}
% Here is some Lorem Ipsum text
\noindent Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum vestibulum. Cras venenatis euismod malesuada.
\vspace{1cm}
\noindent 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.
\vspace{1cm}
\noindent Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\end{document}
Output:
This method is great for specific paragraphs. However, if you need to apply this to the entire document, using this command repeatedly can be time-consuming.
Removing indent for the entire document
If you want to remove the indent from all paragraphs in the document, you can add the following line of code to the preamble.
\setlength{\parindent}{0pt}
It sets the default indent to zero
. As a result, there will be no paragraph in the document with a gap or space at the beginning of its first line.
\documentclass[a4paper,12pt]{article}
\setlength{\parindent}{0pt}
\begin{document}
% Here is some Lorem Ipsum text for example
Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
\vspace{1cm}
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris.
\vspace{1cm}
Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis purus quis vehicula interdum.
\end{document}
Output:
Using the parskip Package
If you want no indent at the beginning of paragraphs but still want some vertical space between paragraphs, the parskip
package is the perfect solution.
You don’t need to write any additional commands. Just include the following package in the preamble.
\usepackage{parskip}
After adding this package, the indent will be removed, and vertical spacing will automatically be added between paragraphs.
\documentclass[a4paper,12pt]{article}
% Include the parskip package
\usepackage{parskip}
\begin{document}
% Here is some Lorem Ipsum text
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus lacinia odio vitae vestibulum vestibulum. Cras venenatis euismod malesuada.
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.
Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Curabitur pretium tincidunt lacus. Nulla gravida orci a odio. Nullam varius, turpis et commodo pharetra, est eros bibendum elit, nec luctus magna felis sollicitudin mauris.
Integer in mauris eu nibh euismod gravida. Duis ac tellus et risus vulputate vehicula. Donec lobortis purus quis vehicula interdum.
\end{document}
Output: