anchor.diff:    {$ENDIF}
   end;
   
  +//-- BG ---------------------------------------------------------- 17.05.2014 --
  +function Collapse(A, B: Integer): Integer; {$ifdef UseInline} inline; {$endif}
  +begin
  +  if A >= 0 then
  +    if B >= 0 then
  +      Result := Max(A, B)
  +    else
  +      Result := A + B
  +  else
  +    if B >= 0 then
  +      Result := B + A
  +    else
  +      Result := Min(A, B);
  +end;
  +
   procedure TBlock.CollapseMargins;
   {adjacent vertical margins need to be reduced}
   var
     TopAuto: boolean;
     TB: TSectionBase;
  -  LastMargin, Negs, I: Integer;
  +  LastMargin, I: Integer;
     Tag: TElemSymb;
     CD: ThtConvData;
   begin
  
positive.code:     begin
        TB := MyCell[I];
        if TB.Display <> pdNone then
          if TB is TBlock then
            if Block.Positioning = posStatic then
              break;
        Dec(I);
      end;
  
      if I >= 0 then
      begin
        // collapse block, if it has no bottom padding and no bottom border
        BCD := ConvData(100, 100, Block.EmSize, Block.ExSize, Block.BorderWidth);
  
negative.code:       begin
          LastMargin := TBlock(TB).MargArray[MarginBottom];
          TBlock(TB).MargArray[MarginBottom] := 0;
          MargArray[MarginTop] := Collapse(LastMargin, MargArray[MarginTop]);
        end
        else if (Tag = LISy) and TopAuto and (Symbol in [ULSy, OLSy]) then
          MargArray[MarginTop] := 0; {removes space from nested lists}
  