MORE ON PARAGRAPH STYLES

Before we leave the subject of working with paragraph styles there are a few more attributes that we should look at. Top of the list is bullets and numbering. These are attributes for paragraph styles you may want to welcome with open arms.

NUMBERING

When you use paragraph styles for numbering, you don’t have to worry about what happens when you decide to add an item or two in the middle of the numbering sequence. Numbering updates automatically. To set up styling for a numbering sequence, begin with a paragraph style that starts the sequence at one (1) or whatever number you choose to start at. You will most likely want to base the style on your Body style, so select “Body” from the styles listed in the Paragraph Styles panel before selecting New Paragraph from its menu. You might decide to name this style “NumberBegin.” In the Bullets and Numbering panel for the New Paragraph dialog that opens, set the List Type to Numbers, and Level to 1. Set the value for Mode to Start At and enter the beginning number (probably 1) in the field to the right. The character sequence for the Number field will start with “^#.” after which you may decide to use a fixed space instead of the default tab (^t). For this, delete the tab metacharacter (^t) and replace it with your fixed space of choice. I often use an en space (“^>”) the width of which, as you remember, is half the size of the text. Using an en space makes calculating the value for Left Indent and First Line Indent fairly easy. Start with a value the same as the text size plus 1 or 2 points and your indent and First Line (outdent) should be right on.

The next paragraph in the numbering sequence (and all those following) will be styled with a paragraph style that increments numbering. The only difference for this style is that the Mode will be set to Continue from Previous... For this reason, base this style on your “NumberBegin” style. You may wish to name it “Number.” Make sure to change the value for Mode and you should be good to go.

BULLETS

Bullets are set up similarly to numbering but use Bullets for the List Type. Base the style on “Number” (if it exists) and name it “Bullets” (or whatever you prefer). In the New Paragraph dialog, change the List Type to Bullets. Choose the character you want for the bullet, and enter a metacharacter for the Text After (again, I prefer an en space “^>”).

NEXT STYLE PATTERN

If you wish your numbering and bullet styles to be part of a style pattern, you will need to set this up. For our sample brochure, there are several styling sequences:

  • Headline > Subhead > Body
  • Headline > Subhead > NumberBegin > Number
  • Headline > Subhead > Bullets

To create the numbering style pattern without conflicting with our current Headline > Subhead > Body style pattern, a new style is created based on Headline and is named “HeadlineNumber”. Similarly a new style based on “Subhead” is created named “SubheadNumber”. With these styles in place, the style patterns are now:

  • Headline > Subhead > Body
  • HeadlineNumber > SubheadNumber > NumberBegin > Number

For bullets, the you may decide to establish a similar pattern or just have the user select the paragraph style for Bullets as needed.

You may also decide to create object styles that are associated with these patterns. At this point the document is saved as a template and a new document is created from the template.

Once you begin working with paragraph styles that have been set up similarly, you will begin to realize the benefit when you actually start entering text or placing it from a text file. (See our previous blog for more on this subject.)

The text for our brochure is now entered using the style patterns established in the template. As you can see from the screenshot below, our text is taking up more than two-thirds of the space we had origially planned on.

Ah, the beauty of using based on. All that is needed is a change to the “BasicSans” and “BasicSerif” styles and these changes filter through to all of the styles based on.

Brochure after just a few changes

With a few changes to spacing, our brochure is ready for placing the images and captions at the bottom of the page. (We will see how this can be automated using object and paragraph styles in a later post.)

GOING TO WEB

When it comes time to take the brochure to the web (of course you will), you now have several options: Export as PDF, Export as HTML, Export for EPUB, and Publish Online (Preview). This last choice is new with the 2015.1 release of InDesign and improved with the 2015.2 releae. For our purpose here we will look at the export to HTML.

EXPORT TO HTML

Export to HTML is used when you want the content to conform to the design for your web page. For this, you will want to set another attribute for your paragraph styles: Export Tagging. In this panel for setting paragraph styling you determine the HTML tag to use for your style, and optionally a class. For our purpose we used the following tags:

  • Headline and HeadlineNumber – h1
  • Subhead and SubheadNumber – h2
  • Body, NumberBegin, Number, Bullet, BulletIndent – p
    (List tags for numbering and bullets are set up in the Eport to HTML dialog.)

When you export your document as HTML, the HTML file is created and also a folder named the same as your document with “-web-resources” appended.

If you are curious as to how the HTML looks, you can open the .html file in any plain text editor. If you do peek inside, you will discover the text frames that were styled with an object style also have a class assigned with the same name as the object style. By the way, how the HTML is created has been greatly improved with later versions of InDesign.

In the -web-resources folder you will find a file with a .css filename extension. This is also a plain text file. With just a few tweaks to the .css file created, our HTML page displays pretty much the way we had it in the document. 

HTML as exported with a few tweaks to .css

Of course, you or your HTML expert can go into the .css file and make the text display pretty much any way you want. If you do want to make major changes or additions to the .css file created, the last panel in the export to HTML dialog allows you to attach any .css files that you have created. It’s great fun!

ONWARD AND UPWARD

Creating text and object styles using a script as opposed to doing it manually may save you some set up time. Should you decide to create a script that helps automate the process, you can start with the following example. This script places what might be returned from a custom dialog in a list at the top. (We will leave creating the dialog for those who decide to take on the challenge.

Paragraph Styles Based On

   (*Assumes basic default styles exist*)
   set basicStyleList to {"BasicSerif", "BasicSans"}
   (*Items in returnFromDialog list reflect: 
   style based on (item number in basicStyleList)
   style name base (to be followed with underscore and size)
   point size, leading, 
   justification (1 = flush left, 2 = centered, 3 = justified, 4 = flush right),
   boolean indicates if hyphenation should be used
   *)
   set returnFromDialog to {{1, "Body", 10, 12, 1, true}, {2, "Head", 24, 24, 1, false}, {2, "Head", 30, 30, 1, false}, {2, "Head", 36, 36, 1, false}}
   try
	--get reference to active document
	set docRef to getDocRef()
	set paraStyleList to returnFromDialog --replace with statement following if creating dialog
	--set paraStyleList to userDialog(basicStyleList)
	createParaStyles(docRef, basicStyleList, paraStyleList)
   on error errStr
	display alert errStr
	return
   end try
   --========
   --HANDLERS
  --========
   (*Creates paragraph styles using based on style and list of attribute values*)
   on createParaStyles(docRef, basicStyleList, paraStyleList)
	tell application "Adobe InDesign CC 2015"
	   set justificationList to {left align, center align, left justified, right align}
	   tell docRef
		repeat with i from 1 to length of paraStyleList
		   copy item i of paraStyleList to {pRef, pName, pSize, pLead, pJust, pHyphen}
		   set baseName to item pRef of basicStyleList
		   set styleName to pName & "_" & pSize
		   if not (exists paragraph style styleName) then
			set basedOnStyle to paragraph style baseName
			set pStyle to make paragraph style with properties {name:styleName}
			tell pStyle
			   set based on to basedOnStyle
			   set point size to pSize
			   set leading to pLead
			   set justification to item pJust of justificationList
			   set hyphenation to pHyphen
			end tell
		   end if
		end repeat
	   end tell
	end tell
   end createParaStyles
   (*Returns reference to active document; otherwise generates error.*)
   on getDocRef()
	tell application "Adobe InDesign CC 2015"
	   if modal state = true then
	      error "Please close dialogs before running script"
	   end if
	   if not (exists document 1) then
		error "Requires active document"
	   else
		return document 1
	   end if
	end tell
   end getDocRef