In my dream world, all received texts for books etc. is marked up using styles from e.g MS Word. In my real world, that is unfortunately rarely the case.

I have written this script to help in the situations where a long text is formatted quite consistently, different headings are perhaps marked with bold and in a bigger font size, quotations are italic etc.

Walkthrough

I have imported a text file in InDesign, but it is not marked up with styles correctly, and there would be no reason to reuse the current styles. So I will just delete all the imported styles, but preserve the formatting, so the style panels are all clean.

Text is imported and all styles are deleted.

Text is imported and all styles are deleted

Placing the cursor in the text flow somewhere will let the script know what story I want it to work with. Now, activating the script, it will automatically run through all paragraphs in the story, check how they differ from the Basic Paragraph style, and create new one's where needed.

In this case, the only differing thing is the oblique font style.

In this case, the only differing thing is the oblique font style

Each time it has created a new style, it will also check if that style will apply to the paragraph it is checking, ensuring that all the paragraphs with the same text formatting will end up having the same paragraph style.

Furthermore it will also check all text for any local formatting within the paragraphs, so bold text will get a character style, italic text, coloured text etc. Also these will be reused, so where its applicable the same style will be used.

An example of an automatically created paragraph and character style.

An example of an automatically created paragraph and character style

Where you go from the result of a lot of AutoStyles is up to you. I prefer to create new styles, then delete the AutoStyles one by one from the panel, replacing them with the new styles.

The script will unfortunately not do all the hard work for you, but is a great tool in cleaning up messy documents!

The script

The JavaScript can be downloaded here: auto_create_p_c_styles.jsx.

You can add it to your Scripts palette and run it from there. To do that, place the file inside the "~/Library/Preferences/Adobe InDesign/Version 6.0/Scripts/Scripts Panel" folder.

Note that depending on the length of your document, the script might take a while to run.

Known bugs:

  • If the first word of a paragraph is "locally formatted", the script will think that is the "general formatting" of the whole paragraph.

I have continued my AppleScript to JavaScript translation and are ready with the other two "bigger" scripts!

This would be the Automating anchored object creation script, which will help you automate creating those anchored text frames for margin text, captions etc.

By specifying which character styles or paragraph styles from a text story you want cut out and placed in an anchored text frame, it will complete the task for you.

And the Marking up index words from colours script, which is written with the intention to fit into an InCopy workflow, since you can't mark up index words in InCopy. But it can also be used without InCopy. Basically it will find all words with a specific colour swatch and add them as index words.

I hope you will enjoy! And please be sure to report any bugs you might come across.

Yesterday I twittered I was »Considering trying to translate my free InDesign AppleScripts to JavaScript. Could potentially learn a lot from it« (link).

Today I decided to try it out.

Now the first translation is available!

I decided to start out with one of the scripts I find most useful, fixing paragraph style combinations.

The script allows you to select a paragraph style combination and change it to another. For instance, if you need to search for all subheading followed by indented paragraph combinations and change the indented paragraphs to none-indented, this is the tool for you.

Translating the script should enable you to use the script in Windows as well, so go ahead and try it out!

I will soon begin translation of my other scripts, but I will not promise that all scripts will be translated, neither now or in the future - I'm still better at AppleScripting.

Creating and organising styles in the beginning of a design process can be a huge help later. Many people tend to rapidly select text, change fonts, leading etc. in their design process, to prepare something to show the client. But the more designs you need to prepare, the more changes the client suggests, and the longer you get in the design process, changing even small stuff takes longer and longer. And even when the design is finally done, and you need to work with it, you will have to recreate the document and create styles from scratch.

I would like to introduce to you, how I normally create and organise my styles to first be able to rapidly change different typefaces, font sizes and leading, and in the end skip the recreation part, since all of the styles are ready to work with.

Paragraphs, headings, captions

This technique effectiveness increases by the amount of different styles/types of text. In this case the document (a book) I will keep it quite simple: normal paragraph text and three levels of headings.

Normally when working on a book I will make sure everything is locked to the baseline grid, but in the start phase I will not lock anything. Instead I will make sure, when creating the styles, that everything adds up! If I define space before and after a paragraph, I will make sure it adds up to the leading of the text. The reason? To be able to quickly test out different leading without changing the baseline grid all the time.

Style defaults

The first paragraph styles I will add are Default, Heading default and Paragraph default. I tend to name my styles quite semantically - there is no need to keep the names short and cryptic, call them something that makes sense! In this case where we don't need that many styles, creating "default" paragraph styles might be overkill, but in bigger projects it can really be a great help. I create the default styles to have something to base other styles on, inheriting all settings if not overridden. If you are used to working with HTML and CSS, you will already know the importance of being able to inherit styles, especially if the document suddenly grows and gets more complex.

The first is the Default style, where I will define everything: leading, font, justification, tabs, what type of numbers used (old style/lining), OpenType features, stylistic sets, language, composer (paragraph/single line), hyphenation rules etc.

Basing the Paragraph default on the Default style makes sure it inherits all settings from it.

Basing the Paragraph default on the Default style makes sure it inherits all settings from it

Next I will create the Heading default style, basing it on the Default style, where I will change what is common for all the headings, in this case it should be a different font, since I want paragraph text in a Serif font and the headings in a Sans font.

I will also create Paragraph default, still basing it on the Default style. In my case, I don't want to change any options in this style, since it should just inherit everything from the Default style.

Paragraphs

For the normal paragraphs I am going to create 2 styles, Paragraph and Paragraph no indent, which is still semantically named and should clearly indicate "what they do". I will create both styles basing them on the Paragraph default style, but only make changes to the Paragraph style, where I will add a first line indent.

In many cases there could be several other styles created here, one with drop cap, full paragraph indented, quotation etc.

Headings

As with the normal paragraphs, I will create three styles, all basing them on the Heading default style, and call them something like Heading 1, Heading 2 and Heading 3.

I only need to change some single things in the Heading defaults style, since the rest is inherited.

I only need to change some single things in the Heading defaults style, since the rest is inherited

Here the only things needing changes are the size and spacing and if you want to differentiate in other ways, such as small caps etc.

Again, since the styles are based on a style it will inherit the options from the parent style, which means you wont have to set up all the small things 10 times.

The first "General" tab of a paragraph shows what is different in the current style from the style it is based on, for quick reference.

The first General tab of a paragraph shows what is different in the current style from the style it is based on, for quick reference

Changing the default style

Luckily InDesign is intelligent enough to "update things" for you. If you base styles on each others and change the style another style is based on, it will take effect immediately. So take it, you want to test the whole design with another font, you only need to change the Default style, and perhaps the Headings Default.

The final "invisible tree" structure, with Default in the top.

The final invisible tree structure, with Default in the top

And of course, if you have created indents based on the leading and adjusted spacing above/below a paragraph, and you change the Default style's leading, you will need to adjust those too. Unfortunately InDesign doesn't support any sort of inherited units, or units based on leading/font-size like EM squares.

When done with preparing different designs with different typefaces, discussing with your client, convincing them that you are Superman etc., you only need to adjust the documents margins and baseline grids, and locking the Default style's lines to the baseline grid.

Organising in a different way?

This is my way of working with styles - and not necessarily the only right way. Are you grouping styles? Not basing them on each others? Please share!

As a follow up post to the baseline grid guide, I would like to write a little about optical alignment in InDesign. As I stated in that post, »fine tuning a grid based design is all about optical alignment - the human eye is what matters in the end«.

When we talk about typography, what better example is there than Gutenbergs 42 line bible.

Notice the optical margins in Gutenbergs beautiful Bible.

Notice the optical margins in Gutenbergs beautiful Bible

Notice the hanging characters in the columns, especially the hyphens and dots. The hyphens are optically almost none existing, so Gutenberg allowed these to "hang" outside the column, to please the human eye.

The same counts for the drop caps. Notice the left side of the Q - not the tail in perticular which is just being decorative, but the left side of the letterform itself. It is pulled just a little into the gutter to create an optical alignment with the left column edge.

I have created a small test case, take a look at this screenshot and you will step by step see an improvement of alignment:

The document without any optical alignment.

The document without any optical alignment

Optical margin alignment

The first thing to do, to achieve an instant better result, is activating Optical Margin Alignment. Optical margin alignment is applied per story, so just place the text marker in the story you wish to apply it for, open the Story palette, and turn it on. The leading applied is just "guiding", if the main text size is 10pt the size should be set to 10 more or less here as well. But nudge it up and down till you find it fitting!

Here you can turn on and off optical margin alignment for a story.

Here you can turn on and off optical margin alignment for a story

Since the feature is turned on per story, you might have some specific styles you dont want automatically adjusted. Adobe added a feature to ignore optical margin alignment in the paragraph style:

Let a paragraph style ignore optical margin alignment.

Let a paragraph style ignore optical margin alignment

After this small change I am quite satisfied with the main text and the subheading alignment - notice especially dots, commas, hyphens and the left side of the A, and the Y hanging a little outside the column. It isn't perfect, but still it is way better than before!

The document with optical margin alignment turned on.

The document with optical margin alignment turned on

Adjusting drop caps

The drop cap is way bigger than the main text, so optical margin alignment won't really affect it that much. Instead manually adjusting it will! The same adjustments will work for bigger headers, where you want them optically aligning with the text.

First of all you have to add a normal space before the drop cap, and then adjust it to drop the first two characters instead of only one.

Adjust the drop cap to drop 2 characters.

Adjust the drop cap to drop 2 characterson

When the drop cap is adjusted and the space is added, you are able to "track it" outside the left edge.

The drop cap with an extra space.

The drop cap with an extra space

Just place the text marker between the dropped cap and the space you inserted and track it until it is in place. In this case I had to track by "-310".

The drop cap with aligned.

The drop cap with aligned

How much you align your text is up to you, but I really find the optical margin alignment tool useful. In larger projects you probably won't always have the time to finetune each heading or drop cap, but if the time is there, why not? The end result is not perfect, but quickly done. Here is a screenshot without grids:

The document with optical alignment in place.

The document with optical alignment in place