0

I am using the parskip package to remove indentation before each paragraph in my document. However, for certain sections of the document, I want to use the default paragraph indentation style (i.e. I want to disable parskip for that section only). Is there an easy way to do this?

If at all possible, I would like to be able to switch between using parskip and using indentfirst by section.

  • \begingroup \parindent=<length> ... [text goes here] ... \endgroup (where <length> is something like, say, 18pt). – jon Mar 2 '17 at 4:09
  • Could I make some sort of reusable "class" for indentation that I can just specify with a single tag at the start of each section? – pzp Mar 2 '17 at 4:11
  • You can write \parindent=<length> [pretty much] anywhere you want and set it to 0pt or 1239pt or etc.; but if you want it for 'certain sections', then I'd use a group or define an environment (with \newenvironment. Since commands like \section don't naturally form groups, I think it is a bad idea to try to hook into them so things happen 'automatically'. Besides, using groups or environments helps keep your code comprehensible. – jon Mar 2 '17 at 4:16
1

Perhaps this is what you are looking for:

\documentclass[12pt]{article}
\usepackage{parskip, lipsum}
\makeatletter
\newcommand{\indentpars}[1][18pt]{%
  % indentfirst.sty is the following two lines:
  \let\@afterindentfalse\@afterindenttrue
  \@afterindenttrue
  % Now we set \parindent:
  \parindent=#1\relax}
\makeatother

\begin{document}

\section{Default}
\lipsum

\section{Indent Pars}
\indentpars[3cm]
\lipsum

\section{Noindent Pars}
\parindent0pt

\lipsum

\begingroup % if doing this often, then an environment is the way to go
  Indent pars again:
  \indentpars[18pt]%
  \lipsum[1-10]
\endgroup

\lipsum

\end{document}
  • I'd be curious to learn why indenting and not-indenting paragraphs is needed. Non-indented paragraphs can confuse a reader, so mixing them with 'regular' paragraphs is probably ill-advised for most types of documents. – jon Mar 2 '17 at 4:27
  • @pzp How do you separate non-indented paragraphs? If you use a blank line then consider the poor reader when a paragraph ends with a complete line and also ends the page, how is anyone able to tell that the first text on the next page is a new paragraph? – Peter Wilson Mar 2 '17 at 19:32

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.