53

I have following structure:

\begin{document}

Paragraph1.
Paragraph2.

\begin{minipage}
Some paragraph1.
Some paragraph2.
\end{minipage}

\end{document}

How can I make the same spacing between paraghs in minipage section as in plain paragraphs? Would like to make it as macros, in order not to repeat it many times, but this failed:

\let\currentparskip\parskip
\newenvironment{minipage_parskip}{
  \begin{minipage}{\textwidth}{
    \setlength{\parskip}{\currentparskip}
  }
}{
  \end{minipage}
}
3
  • Elaborate on what "failed" means. Also note that you're using an underscore in your environment definition which would not be allowed. Finally, your use of length setting is only local since you're surrounding it by group braces, so the effect is only momentary.
    – Werner
    Jan 31, 2012 at 23:11
  • @Werner Why should the underscore be disallowed?
    – egreg
    Jan 31, 2012 at 23:18
  • @egreg: I notice now that it is defined via \csname...\endcsname and since one never (or rarely) use \<env>...\end<env> it is "allowed", I guess.
    – Werner
    Jan 31, 2012 at 23:24

2 Answers 2

41

\parskip is the name of the length parameter that contains the current value of the parskip; so \let\currentparskip=\parskip and \setlength{\parskip}{\currentparskip} is equivalent to \setlength{\parskip}{\parskip} and inside a minipage does nothing, as the value of \parskip is already zero.

\newlength{\currentparskip}
\newenvironment{minipageparskip}
  {\setlength{\currentparskip}{\parskip}% save the value
   \begin{minipage}{\textwidth}% open the minipage
   \setlength{\parskip}{\currentparskip}% restore the value
  }
  {\end{minipage}}

While an underscore in the name of an environment is not forbidden, it's better not to use it, as some packages do change its meaning and may break your environment.

0
28

Both \parbox and \begin{minipage} temporarily reset \parindent=0pt and \parskip=0pt (and a few other parameters), which can be a nuisance.

Fortunately, \begin{minipage} also executes the \@minipagerestore macro after this, which is a hook to allow a LaTeX style to override these defaults. (See the ltboxes section in "texdoc source2e".)

So just try something like

\usepackage{parskip}
\setlength{\parskip}{\medskipamount}
\newcommand{\@minipagerestore}{\setlength{\parskip}{\medskipamount}}

in your style or class file.

Changing the behaviour of the existing "minipage" environment has the advantage that this will automatically affect the many other environments that use minipage internally (such as "columns" in beamer).

2
  • 5
    This works like a charm when added to the preamble. Just had to put \newcommand{\@minipagerestore}{\setlength{\parskip}{\medskipamount}} inside \makeatletter and \makeatother.
    – Casimir
    Oct 7, 2014 at 19:59
  • Markus, do you know of a list of the parameters reset by a minipage? I found the unofficial reference, but it only mentions \parindent. Edit per your comment on source2e, is it the @arrayparboxrestore list? That appears to be parindent parskip everypar leftskip rightskip parfillskip lineskip lineskiplimit baselineskip
    – cxw
    May 4, 2018 at 14:05

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.