OOXML Hacking: Text Box Styles

PowerPoint’s text boxes could really use styles. But wait: they already do! Text boxes styles are built right into the file format, but there is no access to them thorough the program interface. Formatting text boxes using PowerPoint’s user interface is primitive compared to the styling that can be applied to placeholders in PowerPoint. There is no master where you can format text box defaults. The program interface only allows you to set one style, then right-click and choose Set as Default Textbox. And even this default disappears if you click on the Clear All Formatting button (Home>Font group, look for the icon with an eraser over 1 or 2 letters).


Text Box Styles XML

First, let’s clarify our terminology. Text styles in PowerPoint don’t work like any other program, because there’s no Style menu to apply to selected text. Instead, there are levels that you get to by clicking on the Increase List Level (Windows) or Indent More (Mac) buttons. Each level can have a different style.

Fortunately, with some judicious XML editing, you can create 9 preformatted levels of text for your text boxes. They can become nearly the equivalent of a text placeholder that you can add to any slide. This formatting includes line spacing, bullets, indentation, alignments and many other parameters, so this will have to be a 2-part article.

These text box styles will be saved in a theme, so they can be used in other presentations. However, if the theme is applied to Word or Excel, those programs ignore the custom styles and use their standard single-style text boxes. I guess we could expect that when all these settings are storing in a component called presentation.xml. If you’re new to this subject, read XML Hacking: An Introduction. If you’re using a Mac, you should also read XML Hacking: Editing in OS X.

The XML component that contains the text box text levels is ppt/presentation.xml. This component also contains presentation parameters like slide size, slide master ID and a list of slide IDs for all slides in the deck. Below those items is a tag called <p:defaultTextStyle> that contains 9 levels of text formatting. This structure is nearly identical to the text formatting used for default table text, covered in this article: XML Hacking: Default Table Text

Each of the text levels is identical except of a single digit in the name tag, so we can extract one level for an example that will work for all levels. When this is set up, you’ll be able to insert a text box, then click on the Increase List Level button (called Indent More in OS X) to move between styles, just like a text placeholder. Here’s a sample default level:

<a:lvl1pPr marL="0" algn="l" defTabSz="914400" rtl="0" eaLnBrk="1" latinLnBrk="0" hangingPunct="1">
  <a:defRPr sz="2400" kern="1200">
    <a:solidFill>
      <a:schemeClr val="tx1"/>
    </a:solidFill>
    <a:latin typeface="+mn-lt"/>
    <a:ea typeface="+mn-ea"/>
    <a:cs typeface="+mn-cs"/>
  </a:defRPr>
</a:lvl1pPr>

This contains 2 different sections: the first line, called an element, with a string of parameters, called attributes, plus the list of additional parameters on separate lines below, called child elements. It’s important to create the right data in the correct location, so for this article, I’m only going to cover the first line.


Text Box Styles: Attributes

From left to right, the default attributes are:

  1. marL – Sets the left margin for that text level in EMUs. 914,400 EMUs equal 1 inch, while 360,000 EMUs equal 1 centimeter.
  2. algn – Horizontal alignment. A value of l means left aligned. You can also use r for right aligned, ctr for center aligned, just for justified text and dist, which distributes text evenly across the line width, kind of like an extreme form of justification.
  3. defTabSz – Default tab size, again in EMUs.
  4. rtl – Is the language right to left? 0 means no.
  5. eaLnBrk – East Asian Line Break: East Asian languages have rules about where a line break occurs. The 1 value turns this attribute on. A 0 breaks the line wherever needed, without consulting the rules.
  6. latinLnBrk – Similar to the eaLnBreak, a 0 will not break the line without a hyphen, a 1 will break the line wherever needed without a hyphen.
  7. hangingPunct – Theoretically, this forces puctuation to be on the same line as text or allows it to drop to a spearate line. Online documentation for this is poor and I couldn’t detect any difference in setting this to 0 or 1.

Those are the defaults. Then there are several optional parameters that you can add manually:

  • marR – You can set the right margin of text, in EMUs.
  • indent – Set the first line indent of each paragraph, in EMUs.
  • fontAlgn – Vertical alignment. Acceptable values include auto and base which both set text on the font baseline, which is the default. You can also use b to align with the bottom of the descenders (like the bottom of a g or y), t to align with the ascenders or ctr to center text vertically. This latter setting solves the issue that when you increase PowerPoint bullet size, you also increase the bullet elevation above the baseline. Using fontAlgn=”ctr” forces the bullet to stay aligned with the text whatever size it is.
  • lvl – Determines the numbering level for this text level, independent of the level’s position in the hierarchy of text box styles.

The picture below illustrates 5 levels of formatting in a text box. There is no local formatting applied, all I did was type the text and click on the Increase Indent button to move between levels, exactly as with a text placeholder.

Text box styles from the first line parameters

5 levels of text box text formatted with only the first line <a:lvl#pPr> tag.


Text Box Styles: Obscure Gotcha

This XML group is called p:defaultTextStyle for a reason: it’s for other items besides text boxes. If you save you template and a PowerPoint theme (File>Save As>Save as type>Office Theme (*.thmx)), the slide master and layouts are saved in the file. Double-clicking on the theme creates a new presentation. But Handout and Notes masters are not saved in a theme, only in a template. PowerPoint creates new Handout and Notes Masters on the fly using its plain vanilla defaults. The Header, Footer, Date and Page Number placeholders are recreated from the p:defaultTextStyle levels. If the first level uses bullets, the placeholders will have bullets as well!

To get around this, format the first level without bullets, or distribute a template instead, which includes Handout and Notes masters that you can format to the design specs. I prefer templates, because you can also include sample slides.

We’re here to help. Brandwares can improve your PowerPoint project: We teach the pros! Contact me at production@brandwares.com.

7:58 pm

8 thoughts on “OOXML Hacking: Text Box Styles

    • The textbox styles will automatically be added to any shape when you right-click on the shape and choose Edit Text. Effectively, the shape becomes a text box when you do this.

  1. Is there documentation anywhere of all powerpoint xml parameters? Your site is the best I’ve found, but I haven’t found a complete list anywhere. thanks!

    • You can find all the XML parameters at several sites. Office Open XML gives short explanations of the parameters. Datypic has a more terse style, but is better at showing the parents and children of any given parameter. You pretty well need to search Datypic to find information, it’s easy to get lost. Microsoft has a lot of information on their MSDN site. Finally, you can download the ECMA Office Open XML Standards, which are the most complete documentation, but many pages to wade through. Happy reading!

  2. Hi there – when I don’t include a bullet on level 1 and click on the ‘Bullets’ button in PowerPoint and go to the second level (either by clicking Tab on my keyboard or ‘Increase List Level’ button), it doesn’t follow the formatting I have written in XML (e.g. distance from bullet to text differs).

    But when I go straight to clicking on the ‘Increase List level’ button and go to the second level this way, it does follow the XML written.

    Is there a reason why?

    Thank you.

    • When you use the bullets button, PowerPoint disregards your XML and uses the default Microsoft formatting for bullets. Always use the Increase List Level button instead.

  3. John, your articles are a godsend. The XML hack is great, but there’s an odd artifact. I’m trying to set my level 2 style to Segoe UI semibold. If I set “b=0”, on a PC the text will appear as regular. If I set “b=1”, it will appear full (not semi) bold.

    Here’s where it gets even weirder. On a Mac, odd-numbered lines of text will appear semibold and even-numbered lines will appear full bold. But this only works on a Mac. Any suggestions?

    Thanks

    • As with most Microsoft fonts, Segoe UI is arranged in a font family. Font families are groups of up to 4 fonts that allow the font to change by switching the bold and/or italic options in an Office program. Segoe UI Regular is in a font family with Segoe UI Bold, so applying the b parameter switches from the regular to the bold. Segoe UI Semibold is in a separate family with its italic version. You can’t preview this on a Mac, because macOS automatically creates families of all related fonts on the fly. But those automatic families don’t work with Office as you’ve been expecting.

      You’ll have to spec Segoe UI Semibold as the heading or body of your font theme, or spec the text box styles with Segoe UI as a non-theme font.

      I can’t answer why you getting different fonts on different lines on a Mac. If you like, you can email a sample file to my contact address and I’ll take a look at it.

Leave a Reply

*Required fields. Your email address will not be published.

Posting XML? To enter XML code, please replace all less than signs "<" with "&lt;" and greater than signs ">" with "&gt;". Otherwise, Wordpress will strip them out and you will see only a blank area where your code would have appeared.