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 39: Line 39:
  
 
To change the ''Math'' margins in all existing formulas, use a macro. This can be done as follows:
 
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 ''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 ''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
+
# Select the ''Main'' macro in the right pane.
 
# Click the ''Edit'' button.
 
# Click the ''Edit'' button.
 
# Add the ''SetMathBorder'' code after the main Sub:  
 
# Add the ''SetMathBorder'' code after the main Sub:  
Line 65: Line 65:
 
#:    ThisComponent.reformat()   
 
#:    ThisComponent.reformat()   
 
#: End Sub </pre>
 
#: End Sub </pre>
# Switch to the window containing your document, and select Select ''Tools-Macros-Run Macro''
+
# 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 ''My Macros-Standard-Module1'' in the tree in the left pane (Library).
 
# Select ''SetMathBorder'' in the right pane (Macro name).
 
# Select ''SetMathBorder'' in the right pane (Macro name).
# Click the ''Run'' button
+
# 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.
  
 
<section end=answer/>
 
<section end=answer/>
  
 
[[Category:Documentation/FAQ/Formula]]
 
[[Category:Documentation/FAQ/Formula]]

Revision as of 09:09, 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. 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