22

I have several paragraphs of text in a LaTeX document. In my preamble I have \setlength{\parindent}{0pt}, but now I have a need to indent a single paragraph for emphasis.

I am wondering if there a more efficient way of doing this than:

     This paragraph is not indented.
\setlength{\parindent}{15pt}
     Here is my indented paragraph.
\setlength{\parindent}{0pt}
     And we're back to no indentation.

I feel as though there should be a simpler way to do this. Had I not changed the length in my preamble the document would by default indent all the paragraphs, but I could turn this off a single paragraph by using \noindent at the start. Why doesn't \indent work in the opposite way, and revert that paragraph to the default indentation?

2
  • 1
    You can use \hspace{15pt} to give you a “hard” indent in that paragraph. – NVaughan Mar 14 '13 at 19:10
  • 5
    \indent just inserts an empty box of width \parindent, so if this is zero nothing is visible. I don't think it's a good idea to use indentation "for emphasis". Either you use it always (with the normal exceptions) or never. – egreg Mar 14 '13 at 19:16
32

I don't think that using indentation "for emphasis" is a good idea. I prefer indented paragraphs and zero paragraph skip, but I know that somebody has different opinions.

However, I believe that one should either using indentation always (with the usual exceptions, for instance after section titles) or never.

If you really want to confuse your reader ;-), here's a way. Note that \indent just adds an empty box of width \parindent, so if you set the parameter to zero, nothing will be visible. The trick is to reset \parindent locally, the closing additional brace will reset it to zero.

\documentclass{article}
\setlength{\parindent}{0pt}
\newcommand{\forceindent}{\leavevmode{\parindent=1em\indent}}

\begin{document}

This is not indented.

\forceindent This is indented.

This is not indented.

\end{document}

enter image description here

Note. Thanks to Frank Mittelbach for having spotted a problem in the simpler solution without \leavevmode that would deliver the \everypar tokens inside a group. With \leavevmode there will be two "indent boxes", one of zero width, followed by what's possibly inserted by \everypar and then the new indent box.

Another possibility could be to not doing anything inside a group:

\newcommand{\forceindent}{\parindent=1em\indent\parindent=0pt\relax}
1
  • 1
    Better start with \leavevmode outside the brace group in \forceindent to avoid getting \everypar inside a group. – Frank Mittelbach Mar 14 '13 at 21:50
7

This is a solution that keeps whatever standard indentation your document class may have for \myindent:

\documentclass{article}

\newlength{\oldparindent}
\setlength{\oldparindent}{\parindent}
\newcommand{\myindent}{\hspace{\oldparindent}}

\setlength{\parindent}{0pt}
%\usepackage{parskip} % potentially a better solution than the line above;
                      % adds some space between paragraphs.

\usepackage{lipsum} % just for dummy text

\begin{document}
\lipsum[1]

\lipsum[1]

\myindent\lipsum[1]

\lipsum[1]
\end{document}

output

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.