How do I change the spacing around my formula?

From Apache OpenOffice Wiki
Jump to: navigation, search


How do I change the spacing around my formula?



If you have embedded your formula in a Writer document you can do as follows.


If you want to change the spacing around a single formula follow these steps:

  1. Select the formula.
  2. Select Format-Frame.
  3. Select the tab page Wrap.
  4. In the group Spacing on this page you can adjust the spacing around the formula.


If you want to change the spacing around all formulas follow these steps:

  1. Open the stylist (Format-Styles and Formatting).
  2. Click the icon for frame styles (the third icon from the left).
  3. Right-click Formula in the styles list.
  4. Select Modify in the pop-up menu.
  5. Select the tab page Wrap.
  6. In the group Spacing on this page you can adjust the spacing around the formulas.


In addition Math inserts some spacing within the frame around your formula. Follow these steps to change this:

  1. Open your formula.
  2. Select Format-Spacing.
  3. Click Category and select Borders in the pop-up menu.
  4. You can now change the left and right margins of your formulas.
  5. If you want to set these margins as the default, press Default and confirm.


To change the Math margins in all existing formulas, use a macro. This can be done as follows:

  1. Select Tools-Macros-Organize Macros-OpenOffice.org Basic.
  2. Select My Macros-Standard-Module1 in the tree in the left pane. If Module1 does not exist in the Standard, create it using the New button.
  3. Select the Main macro in the right pane.
  4. Click the Edit button.
  5. Add the SetMathBorder code after the main Sub:
    Main sub
    End sub
    Sub SetMathBorder
    On Error Resume Next ' Prevents deleted objects from causing errors.
    dim embeddedObjects, elementNames, i, element, elem, oldW
    embeddedObjects = ThisComponent.getEmbeddedObjects()
    elementNames = embeddedObjects.getElementNames()
    for i=0 to UBOUND(elementNames)
    elem = embeddedObjects.getByName(elementNames(i))
    element = elem.Model
    if (element.supportsService("com.sun.star.formula.FormulaProperties")) then
    oldW = elem.Width - element.LeftMargin - element.RightMargin ' captures old widths
    element.TopMargin = 0 ' sets internal border to zero
    element.BottomMargin = 0 ' You can adjust these values(It's just that I use the formulas in text so I prefer it to be 0)
    element.LeftMargin = 0
    element.RightMargin = 0
    ' adjusts the width, as openoffice sometimes stretches the formula as opposed to resizing it.
    elem.Width = oldW + element.LeftMargin + element.RightMargin
    endif
    next i
    ThisComponent.reformat()
    End Sub
  6. Switch to the window containing your document, and select Select Tools-Macros-Run Macro.
  7. Select My Macros-Standard-Module1 in the tree in the left pane (Library).
  8. Select SetMathBorder in the right pane (Macro name).
  9. Click the Run button. In my case, the screen is not updated correctly. An update can be triggered by minimizing and restoring, going to a different page in the document, or changing the zoom.


Personal tools