2

I am looking for a way to add an indentation after setting \parindent to 0. I tried a suitable amount of search, but none really seemed to meet my needs.

I tried to change the command \indent by inserting spaces:

\renewcommand{\indent}{\hspace{15pt}}

However, \indent did not add any extra space at the start of a new paragraph.

Can anyone please help me?

Werner
  • 603,163
James C
  • 121
  • What kind of indent are you looking for and when and how (automatically or manually) should it be produced? – moewe Sep 07 '20 at 05:22
  • I would like to type "\indent" at beginning of a paragraph if needed and have an indentation. Since the indentation length is set by 0, I need to find an alternative method. – James C Sep 07 '20 at 05:31
  • Are you sure that your readers will understand the difference between the two types of paragraphs? – egreg Sep 07 '20 at 08:00
  • it seems a very strange requirement, you should never need \noindent or \indent within the document, such things should be set up by the document class. That said you can use \hspace* so the space is not dropped but I would not redefine the \indent primitive, define your own command. – David Carlisle Sep 07 '20 at 10:50
  • @egreg it is for my personal use. I am writing math lecture notes in latex and I want to format things this way. – James C Sep 07 '20 at 22:01

2 Answers2

2

First store the original indent by adding

\newlength{\saveparindent}
\AtBeginDocument{\setlength}{\saveparindent}{\parindent}}

to your preamble. Then also add

\newcommand{\indentpar}{\par\hspace*{\saveparindent}\ignorespaces}

as your new indentation mechanism.

Assuming you have \setlength{\parindent}{0pt} somewhere else in your document you should now be able to use it in the following way:

enter image description here

\documentclass{article}

\newlength{\saveparindent} \AtBeginDocument{\setlength{\saveparindent}{\parindent}} \newcommand{\indentpar}{\par\hspace*{\saveparindent}\ignorespaces}

\begin{document}

This is an indented paragraph.

\setlength{\parindent}{0pt}% Remove paragraph indentation This is a paragraph that is not indented.

\indentpar Here is a new indented paragraph.

\end{document}

Of course, LaTeX also provides \noindent, if you're only interested in some non-indented paragraphs:

\documentclass{article}

\begin{document}

This is an indented paragraph.

\noindent% Remove paragraph indentation just for this paragraph This is a paragraph that is not indented.

Here is a new indented paragraph.

\end{document}

Werner
  • 603,163
1

You should always be able to use \hspace for this purpose: \hspace{5mm}

EDIT:
In order for \hspace to work you probably have to switch from vertical to horizontal mode using \leavevmode. See Function and usage of \leavevmode and What are vertical and horizontal modes?

So all in all this should work: \leavevmode\hspace{5mm}

Raven
  • 3,023