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?

5
  • What kind of indent are you looking for and when and how (automatically or manually) should it be produced?
    – moewe
    Commented Sep 7, 2020 at 5: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
    Commented Sep 7, 2020 at 5:31
  • Are you sure that your readers will understand the difference between the two types of paragraphs?
    – egreg
    Commented Sep 7, 2020 at 8: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. Commented Sep 7, 2020 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
    Commented Sep 7, 2020 at 22:01

2 Answers 2

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}
1
  • Thank you for your answer.
    – James C
    Commented Sep 7, 2020 at 22:07
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}

7
  • Hi Raven. Unfortunately, \hspace{5mm} did not work. It certainly adds an extra space if I use it in the middle of a paragraph. However, once I add a line \\, it doesn't give me an indentation.
    – James C
    Commented Sep 7, 2020 at 5:32
  • @JamesChung did you use it directly after the `\` or did you have a blank line in between?
    – Raven
    Commented Sep 7, 2020 at 6:07
  • See also my edited post
    – Raven
    Commented Sep 7, 2020 at 6:10
  • 2
    simpler to use \hspace* Commented Sep 7, 2020 at 10:50
  • @DavidCarlisle I ended up redefining \indent as \hspace*{15pt}. Thank you
    – James C
    Commented Sep 7, 2020 at 22:07

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .