beamer icon indicating copy to clipboard operation
beamer copied to clipboard

Option to set \parskip

Open mgkuhn opened this issue 6 years ago • 2 comments

I frequently use normal paragraphs in beamer. It would be nice to be able to set \parskip, to routinely separate paragraphs by some vertical space.

However, simply putting

\usepackage{parskip}
\setlength{\parskip}{\smallskipamount}

into the preamble does not solve the problem: many beamer environments use LaTeX's minipage environment, which resets \parskip for its content. (See the ltboxes section in "texdoc source2e".)

So far, I'm using the following workaround in my own beamerthemes:

% define an option for setting \parskip (space between paragraphs)
\DeclareOptionBeamer{parskip}[\smallskipamount]{\newskip\beamer@parskip
  \beamer@parskip=#1}
\ExecuteOptionsBeamer{parskip}
\ProcessOptionsBeamer
\ifdim\beamer@parskip=0pt\else
  \usepackage{parskip}
  \setlength{\parskip}{\beamer@parskip}
  \newcommand{\@minipagerestore}{\setlength{\parskip}{\beamer@parskip}}
  % avoid \beamerboxesrounded getting too much
  % vertical space from our \@minipagerestore
  \pretocmd{\beamerboxesrounded}{\renewcommand{\@minipagerestore}
                                              {\setlength{\parskip}{2pt plus 1pt minus 1pt}}}
\fi

In addition to setting \parskip, this also uses the \@minipagerestore command to push the changed \parskip into the minipage environment. It also hacks \beamerboxesrounded, which would otherwise get too much vertical space in the top padding from an increased \parskip.

It would be nice if beamer directly supported some official way to set \parskip throughout a presentation in a way that affects minipages without interfering with the vertical padding of color boxes.

mgkuhn avatar Oct 03 '18 18:10 mgkuhn

I think it's not a good idea to hack beamer's environments and the underlying \parbox / minipage too much. You can define environments based on beamerboxesrounded and block for yourself and alter \parskip inside them:

\newenvironment{adjustedblock}[1]%
{\begin{block}{#1}%
\setlength{\parskip}{2ex plus 1ex minus 1ex}%
\vskip-\parskip}
{\end{block}}

louisstuart96 avatar Oct 04 '18 02:10 louisstuart96

Suggestion: would it be possible to insert into beamer's existing environments (where they do not already inherit \parskip without problems) something like

\setlength{\parskip}{0pt}
% ... parts of the environment that assumes \parskip=0pt and visually breaks otherwise ...
\setlength{\parskip}{\beamer@parskip}
% ... parts of the environment where user/theme control over \parskip would be useful ...

at the right places, to make it easier for users and theme authors to change \parskip via setting \beamer@parskip (or whatever other to-be-introduced parameter) without messing up existing environments, or having to define clones of many of them? That should be much more controlled and less of a hack than my current \@minipagerestore workaround.

At the moment, it seems beamer was entirely designed to only be used with \parskip=0pt, a serious restriction compared to standard LaTeX classes such as article.

mgkuhn avatar Oct 04 '18 11:10 mgkuhn