Difference between revisions of "Documentation/FAQ/Formula/How do I change the spacing around my formula?"

From Apache OpenOffice Wiki
Jump to: navigation, search
(Added a method to adjust math borders for existing formulas.)
Line 36: Line 36:
 
#You can now change the left and right margins of your formulas.
 
#You can now change the left and right margins of your formulas.
 
#If you want to set these margins as the default, press '''Default''' and confirm.
 
#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:
 +
# Select ''Tools-Macros-Organize Macros-OpenOffice.org Basic''
 +
# 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.
 +
# Select the ''Main'' macro in the right pane
 +
# Click the ''Edit'' button.
 +
# Add the ''SetMathBorder'' code after the main Sub:
 +
#: <pre>
 +
#: Main sub
 +
#:
 +
#: End sub
 +
#:
 +
#: Sub SetMathBorder
 +
#: dim embeddedObjects, elementNames, i, element
 +
#: 
 +
#:    embeddedObjects = ThisComponent.getEmbeddedObjects()
 +
#:    elementNames = embeddedObjects.getElementNames()
 +
#:    for i=0 to UBOUND(elementNames)
 +
#:      element = embeddedObjects.getByName(elementNames(i)).Model
 +
#:      if (element.supportsService("com.sun.star.formula.FormulaProperties")) then
 +
#:          element.TopMargin = 30 : rem sets to 0.30 mm
 +
#:          element.BottomMargin = 30
 +
#:          element.LeftMargin = 30
 +
#:          element.RightMargin = 30
 +
#:      endif
 +
#:    next i
 +
#:    ThisComponent.reformat() 
 +
#: End Sub </pre>
 +
# Switch to the window containing your document, and select Select ''Tools-Macros-Run Macro''
 +
# Select ''My Macros-Standard-Module1'' in the tree in the left pane (Library).
 +
# Select ''SetMathBorder'' in the right pane (Macro name).
 +
# Click the ''Run'' button
 +
 
<section end=answer/>
 
<section end=answer/>
  
 
[[Category:Documentation/FAQ/Formula]]
 
[[Category:Documentation/FAQ/Formula]]

Revision as of 08:51, 13 January 2011


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
    dim embeddedObjects, elementNames, i, element
    embeddedObjects = ThisComponent.getEmbeddedObjects()
    elementNames = embeddedObjects.getElementNames()
    for i=0 to UBOUND(elementNames)
    element = embeddedObjects.getByName(elementNames(i)).Model
    if (element.supportsService("com.sun.star.formula.FormulaProperties")) then
    element.TopMargin = 30 : rem sets to 0.30 mm
    element.BottomMargin = 30
    element.LeftMargin = 30
    element.RightMargin = 30
    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


Personal tools