summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/parades/paravesp.sty
blob: 5f983dd3166db3052aaba65c430a89d044053578 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
\ProvidesPackage{paravesp}[2016/02/05 space above and below paragraphs]

\newcount\pd@lastpenalty

\newcommand\pd@remember@penalty{\pd@lastpenalty=\lastpenalty\relax}

\newcommand\pd@restore@penalty{\ifnum 0=\pd@lastpenalty \else
  \penalty\pd@lastpenalty\relax \fi}

\newcommand\ParaSpaceAbove[1]{\relax % Mask \ifdim from possible expansion
\ifvmode
  \skip0=#1\relax
  \ifdim\parskip<0pt\relax
    \skip0=0pt\relax
  \fi
  \ifdim\skip0=0pt\relax
    \IssueParaSpace
  \else
    \ifdim\prevdepth>-1000pt\relax
      \advance\parskip by \prevdepth\relax % assumed: was set by SpaceBelow
      \pd@remember@penalty
      \vskip-\prevdepth\relax
      \pd@restore@penalty
      \prevdepth=-1000pt\relax
    \fi
    \ifdim\skip0>\parskip\relax
      \parskip=#1\relax
    \fi
  \fi
\fi
}

\newcommand\ParaSpaceBelow[1]{\relax
\parskip=#1\relax
\advance\parskip by -\prevdepth\relax
\ifdim\parskip<0pt\relax
  \ifdim#1<0pt\relax \parskip=#1\relax \else \parskip=0pt\relax \fi
  \nointerlineskip
\else% >=10000pt
  \ifdim\parskip>999pt\relax \parskip=#1\relax\fi
\fi}

\newcommand\IssueParaSpace{\relax
\ifhmode \typeout{! LaTeX warning: IssueParaSpace in horizontal mode.}\par \fi
\ifdim\parskip>0pt\relax
  \pd@remember@penalty
  \vskip\parskip\relax
  \pd@restore@penalty
  \prevdepth=-1000pt\relax
  \parskip=0pt\relax
\fi
}

\newcommand\IgnoreSpaceAboveNextPara{%
\ParaSpaceBelow{-0.01pt}}

\newcommand\CancelIgnoreSpaceAboveNextPara{%
\relax\ifdim\parskip<0pt\relax \parskip=0pt\relax \fi}