Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}
}
share|improve this question
    
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 '12 at 23:11
    
@Werner Why should the underscore be disallowed? –  egreg Jan 31 '12 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 '12 at 23:24

2 Answers 2

up vote 17 down vote accepted

\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.

share|improve this answer
    
Thank you very much, works as a charm! –  glaz666 Jan 31 '12 at 23:38

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).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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