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

From Apache OpenOffice Wiki
Jump to: navigation, search
(New page: {{DISPLAYTITLE: How do I change the spacing around my formula?}} <section begin=question/> '''How do I change the spacing around my formula?''' <section end=question/> <section begin=ans...)
 
m
 
(6 intermediate revisions by 3 users not shown)
Line 7: Line 7:
 
<section begin=answer/>
 
<section begin=answer/>
  
<div style="background-color:#EFEFEF; padding: 2px; line-height: 0px; font-size: xx-small!important; margin-right: 10px; margin-bottom: 10px; border: 1px solid #666; text-align: center; width: 3em;" title="Applies to OpenOffice.org 1.1.x">
 
'''1.1.x'''
 
</div>
 
  
 
If you have embedded your formula in a ''Writer'' document you
 
If you have embedded your formula in a ''Writer'' document you
 
can do as follows.
 
can do as follows.
 +
  
 
If you want to change the spacing around a single formula follow
 
If you want to change the spacing around a single formula follow
 
these steps:
 
these steps:
 +
#Select the formula.
 +
#Select {{menu|Format|Frame}}.
 +
#Select the tab page '''Wrap'''.
 +
#In the group '''Spacing''' on this page you can adjust the spacing around the formula.
  
*Select the formula.
 
*Select '''Format-Object'''.
 
*Select the tab page ''''Wrap''''.
 
*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:
 
If you want to change the spacing around ''all'' formulas follow these steps:
 +
#Open the stylist ({{menu|Format|Styles and Formatting}}).
 +
#Click the icon for frame styles (the third icon from the left).
 +
#Right-click '''Formula''' in the styles list.
 +
#Select '''Modify''' in the pop-up menu.
 +
#Select the tab page '''Wrap'''.
 +
#In the group '''Spacing''' on this page you can adjust the spacing around the formulas.
 +
 +
 +
In addition ''Math''<SPAN STYLE="font-style: normal"> inserts some spacing within the frame around your formula. Follow these steps to change this:</SPAN>
 +
 +
#Open your formula.
 +
#Select {{menu|Format|Spacing}}.
 +
#Click '''Category''' and select '''Borders''' in the pop-up menu.
 +
#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.
  
*Open the stylist ('''Format-Stylist''').
 
*Click on the icon for frame styles (the third icon from the left).
 
*Click on ''''Formula'''' and then right click in the stylist.
 
*Select '''Modify...''' in the pop-up menu.
 
*Select the tab page '''Wrap'''.
 
*In the group ''''Spacing'''' on this page you can adjust the spacing around the formulas.
 
  
In addition ''Math''<SPAN STYLE="font-style: normal"> inserts some spacing around your formula. Follow these steps to change this:</SPAN>
+
To change the ''Math'' margins in all existing formulas, use a macro. This can be done as follows:
 +
# Select {{menu|Tools|Macros|Organize Macros|OpenOffice 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 {{button|New}} button.
 +
# Select the ''Main'' macro in the right pane.
 +
# Click the {{button|Edit}} button.
 +
# 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
 +
#:
 +
# Switch to the window containing your document, and select {{menu|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 {{button|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.
  
*Open your formula.
 
*Select '''Format-Spacing'''.
 
*Click ''''Category'''' and select '''Borders''' in the pop-up menu.
 
*You can now change the left and right margins of your formulas.
 
 
<section end=answer/>
 
<section end=answer/>
  
 
[[Category:Documentation/FAQ/Formula]]
 
[[Category:Documentation/FAQ/Formula]]

Latest revision as of 13:34, 7 October 2021


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 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 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