15

That may be a stupid question but is there a way to keep the indent while using the parskip package? I use parskip to keep spacing between my paragraphs while leaving the table of contents and lists intacts but I would like to keep the indents in my text.

Code 1 :

\usepackage{parskip}

\tableofcontents

\section{Section 1}
\subsection{Sub 1}

Paragraph 1

Paragraph 2

Code 2

\setlength{\parskip}{10pt}

\tableofcontents

\section{Section 1}
\subsection{Sub 1}

Paragraph 1

Paragraph 2

Basically I want the aspect of the table of contents (and possible lists) from the code 1 while keeping the indent like in the code 2. The package parskip works great but I just don't like that it deletes the indents and I'd like to find a way to prevent it from doing that.

Thank you.

3
13

Package parskip sets \parindent to zero. The following example saves the old value, loads parskip and restores \parindent:

\documentclass{article}

\edef\restoreparindent{\parindent=\the\parindent\relax}
\usepackage{parskip}
\restoreparindent

\begin{document}
\tableofcontents

\section{Section 1}
\subsection{Sub 1}

Paragraph 1

Paragraph 2
\end{document}

Result

2
  • Wouldn't it be better to save the old value of \parindent in another register and then restore it, instead of using \the? This is a genuine question: is the output from \the precise enough to set a register to the original value?
    – Kalrish
    Sep 15 '16 at 20:53
  • 1
    @Kalrish The output of \the has enough decimal places to restore the old value correctly. The smallest unit in TeX is: 1 sp = 1/65536 pt ≈ 0.000015258789 pt. Compare with the smallest unit of five decimal places, the "precision" of \the: 0.00001 pt. Sep 15 '16 at 21:43
0

There seems to be no reason for the parskip package to set \parindent to zero, except its author's preferences.

The simplest way to have parskip behave in accordance with its name is to comment this "feature" in parskip.sty — and as suggested by musarithmia, preferably have it saved as a new whatever.sty file in your texmf tree (then use (sudo) texhash to have it seen by LaTeX and of course \usepackage{whatever}) :

% \parindent=\z@
3
  • 2
    I don't think it's a good idea to start changing package code directly. For one, this site depends on the assumption that everyone is using the same code base. This is what \renewcommand is for. Also, the parskip package is so minimal that you might as well copy the code into a separate file in your home texmf tree, change it how you like, and call it parsep.sty or whatever you like. Sep 5 '17 at 13:21
  • @musarithmia Right, still commenting this line is by far the simplest solution. Thanks for the comment, see edited answer. Sep 5 '17 at 13:55
  • 1
    No need for texhash if you put it in ~/texmf/tex/latex/local/ or in the same directory as the .tex file. Sep 5 '17 at 15:16
0

Since 2018-08-24, parskip package has an indent option. Quoting the documentation :

With the package option indent it is possible to explicitly set the paragraph indentation. Using this option without a value keeps the document class indentation unchanged, if it is specified with a value then that value is used. If the package is loaded without this option the indentation is set to zero.

Usage :

\usepackage[indent]{parskip}

or

\usepackage[indent=1cm]{parskip}

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.