Advertisements

GREPgraphing – Beyond 2000

In 2016, I developed a concept of creating bar graphs using GREP styles. Put simply, when a number was typed such as 1423, several different GREP styles would kick in to transform the number into a bar graph. In the above example:

  • if there’s a one for the 1 followed by three digits, make the one character 1000% wide;
  • If there’s a 4 followed by two digits, make the four character 400% wide;
  • If there’s a 2 followed by one digit, make the two character 20% wide;
  • If there’s a 3 as the last character, make the three 3% wide.

To successfully work with any whole number between 1-1999, this technique requires creating 29 different types of GREP styles and character styles. It uses a fixed width font and takes advantage of GREP styles to adjust the width of the numbers to represent them as their appropriate value as a bar graph. I’ve written about this technique in more detail over at InDesignSecrets.

In 2018, I expanded upon this idea and made a script so that anyone wishing to use the technique without typing the 29 character and GREP styles could simply run a script:

Beyond 2000

One catch with this technique is that it stops at 1999 as the character style to represent 2000 can’t be made by creating a 2000% width as the maximum character width is 1000%. However, there is a workaround – create a new character style called 2000, based on the 1000 style, but give it a tracking of 600.

Adjust the GREP graph paragraph style and underneath the 1000% GREPstyle, make a new one using the new 2000% character style that was made and give it the following pattern:

2(?=\d\d\d\b)

To test this, I have two different GREPgraph styles containing the 1000 figure and have put them side by side. In the text frame underneath, if I type 2000 into the text frame with the GREPgraph beyond 2000 style applied to it, it should be the same width, right?

Absolutely. If I make an additional 3000% character style based on the 2000% style but changed its tracking to 1200, and added a GREPstyle to the paragraph style to apply the 3000% character style to the pattern 3(?=\d\d\d\b), this will work too.

From here, a pattern can now be seen: to get to the next 1000 in width, add another 600 to the tracking of that thousand’s character style and add a new GREP style pattern to the GREPgraph style. This will work until the tracking hits its maximum of 10,000.

Doing all this in less GREP steps

As stated earlier, the original technique required 29 GREP styles to create a GREPgraph, but what if I said it was possible to achieve the numbers 1-1999 (actually a few more – 2047) using 12 GREP styles? This can be done too, but requires a technique in Excel, and that is to convert the original base-10 number into a 16-bit binary number. I’d actually described this technique back in 2011, but it was implemented differently and with more complications: this method is far simpler.

First, convert the desired base-10 number to a 16-bit binary number in Excel using the following formula:

=DEC2BIN(A1/256,8)&DEC2BIN(MOD(A1,256),8)

Now that the number is displayed in binary, copy the binary number into InDesign.

The technique basically works the same way as the original GREPgraph technique but has a slightly different implementation. First, the character styles need to be created that will change the widths, but instead of making 1-9, 10-90, 100-900 and 1000, only the character styles 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512 and 1024 need to be created. For example, the character style 32 will only contain the width of 32%, and this pattern will apply to the other numbers mentioned.

Zero and 1024 are the exceptions. Zero will have a character style featuring a .1pt size, no fill or stroke, and 1% width. 1024 will have a character style of 1000% and a tracking of 14.

This will create a total of 12 character styles.

Now to make the paragraph style. To keep it simple, the appearance of the bar graph will controlled by the paragraph rule (though more advanced methods can be made using combinations of rule above, below, underlines and strikethroughs).

Here is where the magic happens – the GREP styles. Here are the styles and how they are implemented in the GREP style panel of the Paragraph style.

And here is the result:

So what’s happening here?

It’s important to understand how binary numbers are written compared to base-10 numbers. The following site gives a really good explanation, and that’s all that’s happening here – the GREP styles are being applied to the 1s in the binary number, based on their position in the binary number, and applying the appropriate GREP widths.

It can go larger

Just like the regular GREP graph, this too can be expanded to numbers larger than 2000 by creating an additional character style that has an added tracking applied. In this case, to represent the numbers 1-4095, a further character style can be added: 2048.

An advantage of this technique is that instead of creating an additional 9 character/GREP styles for each power of 10 using the base-10 GREP styles, the binary method will require a new style every time the total doubles e.g. 14th GREP style would be 4096, 15th GREP style would be 8192…

The obvious disadvantage with this technique: the numbers to be displayed as bar graphs have to be written out in binary first.

Is this something I would use? Probably not myself, as GREPgraphs are normally enough for my purposes, but I often hear the question “what if you need more than 1999 in a graph” so I felt that it was worth answering the question: It can be done, but it’s a lot of effort to get there.

Advertisements

Please fix Text Variables so they behave like regular text

Within the type menu of Adobe InDesign is the Text Variables feature. This allows users to insert a special character that will display one of the following items:

  • A chapter number
  • A file-related date such as the creation date, modification date or output date
  • Filename
  • Image Name (aka captions setup)
  • Last Page Number
  • Running Header based on either a used paragraph or character style
  • Custom static text

Unfortunately, there is an unwanted behaviour of the text variables – InDesign treats them as a single character rather than the actual content within the variable. This has a few unwanted consequences:

  • Long variables that would normally break over several lines are squished into one line;
  • They cannot be formatted using GREP or Nested styles, nor can specific words be manually selected for formatting.

It’s an issue that is “in backlog” by the Adobe InDesign team to address, but that was first stated in 2017.

If the issue was resolved, it would have enabled my GREPGraph solution to be applied in the following InDesignSecrets article.

As it turns out, it is also affecting another solution that would make lives easier for anyone who has to create diaries and planners on a regular basis.

The brief:

A planner is created by making a base template and then creating threaded text for the dates that are represented only by numbers. This makes populating a diary from week to week relatively easy…

…until the other material has to be populated, such as what month it is, what term it is, and what week it is. This is best illustrated in the first two minutes of a Youtube video by Rob Cubbon.

Incidentally in Rob’s video, he uses frame breaks between each record, but that isn’t required. Instead, adjust the paragraph style of the numbers by going to the Keep Options and from the Start Paragraph dropdown, select In Next Frame.

The technique:

Instead of populating the text frames simply with numbers, what if the frames were populated with more information that can be called upon by running header text variables, such as the month?

I can make a list in excel that contains the day of the week and the month in one column. This is also done without a space intentionally for reasons that will become evident soon.

I can then copy this text to my InDesign file. However, note that the text overflows and isn’t correct – that is because the flowing numbers need to have a character style that will hide the text that we want to be visible elsewhere. To do this, I’ve created a character style called hidden, and its properties are:

  • .1 point high;
  • 1% wide;
  • No fill or stroke.

That’s fine, but applying that manually to everything but the numbers will be a nuisance, so the paragraph style for the numbers has to be modified using Nested Styles.

The nested style will apply a style of [None] to the digits as they need to be visible, but will intentionally hide the month.

So why I am I intentionally hiding the month? Because I’m only interested in the information it represents, and this can be called upon by a text variable. I will go to the master page and insert a text variable for a running header showing me the first result of hidden on the page.

The issue with the technique

That’s fine until I get to a spread that contains two months. I’d rather both months be present rather than the earlier month. For example, I’d like the headline to read April/May instead of April. I can do this by returning to my master page, apply my blinking text cursor to the text variable that is already there, type a slash and then create a new text variable that is a running header looking for hidden character style in the last instance.

Once I’ve inserted the variable and returned to that spread, that now looks fine, but all others are now affected.

I should be able to make a GREP style that will look for a word, then a backslash, and the same word it initially found. I’ll create a new text frame with some sample text to see if it works. The GREP code I’ll use is this:

Apply style: Hidden

GREP: (.+?)\K\/\1

Looks like its working in my demo, but as I check the document it isn’t… I’ll find a spread where I know the months split.

But that should work. I saw it work on plain text, why isn’t it working on text variables? That’s because GREP styles and Nested Styles don’t work on text variables. If I want this technique to work, I’ll have to use a workaround.

The workarounds:

  • Use a script to convert the text variables to plain text. Marijan Tompa used to have such a product via the Adobe Exchange, but it has since been removed, and it is not mine to give away. Other scripts do exist on the Adobe InDesign forums, but they are not as flexible as Marijan’s original script. It also works only one way, and can’t convert the text back to variables.
  • Don’t attempt to use the GREP style to hide the duplicate month, but instead only add a Running Header for the first instance on a page and add the others manually by overriding the affected master pages;
  • Create the desired date in Excel using a formula.

The issue with the first two solutions is that it prevents the solution from remaining live. The last solution will work but requires in-depth knowledge of Excel and – for many diaries – requires having an Excel file on stand-by for this purpose.

Ultimately, I’d love to see a fix for this issue as it would open up many possibilities. If you feel that this needs attention now rather than later, please cast your vote here.

Using character styles for dot leaders

The topic of tabs and leaders has been covered on InDesignSecrets before in a 6-part series but it’s worth sharing this particular tip as it saves me plenty of heartache in my day-to-day role.

Usual technique

The usual practice of creating a dotted line (usually for either leading up to a page number in a table of contents OR preparing a space for users to add information to a handwritten form) is often accomplished by the tabs feature. For example:

This is achieved by making a paragraph style that has a tab stop that has been right-aligned to the end of the text frame, and in the leader text field of the tab dialog box, a period has been entered, and it is this period that repeats to generate the dotted line.

Issues with this technique

However, I find this is quite restrictive in terms of:

My preferred technique

Instead, I prefer to make a character style called “dotted line” giving it the dotted line appearance that I’m after in the underline panel of the character style dialog box.

If more control is required, I can also prepare a stroke style specifying the dot style and frequency that the dots appear.

I can then either apply the character style manually to the areas requiring the dotted lines, or I can make a paragraph style that calls the dotted line character style using a GREP style that looks for tab spaces.

Bonus tip

Note that my GREP style is looking for \t|~y rather than just \t – the ~y represents a right indent tab. For dot leaders that need to go to text at the end of a text-frame, I prefer to use a right indent tab instead of setting a right align tab, because if the text frame changes width and I want the right aligned item to remain right aligned to the text frame, I don’t have to adjust the tab stop of the right align tab.

To insert a right indent tab, press SHIFT+TAB. This will work anywhere in a text frame except within a table where it will highlight the previous cell. To apply a right indent tab inside a table, either insert one via right-clicking to call upon the contextual menu, then navigate to Insert Special Characters, Other, then Right Indent Tab.

Otherwise, it can be called upon by opening the quick-apply menu via COMMAND+RETURN on Mac (or CONTROL+RETURN on Windows) and type either Right Indent Tab (or, if you’re really lazy – nt tab as highlighted in pink in the figure below).

Features or Speed… why not both InDesign?

porquenolosdos

After a recent post discussing the complications of indexing a rather large InDesign file (1600+pp), it is worth mentioning another issue encountered with the project, namely the reduced speed of InDesign.

There are already several articles concerning “slowdowns” while working with InDesign, namely:

http://indesignsecrets.com/why-is-indesign-soooo-slow.php

http://forums.adobe.com/message/4815713#4815713

Put simply, the larger the file became, the harder it was to work on. Little things such as placing the text cursor between words resulted in a spinning beachball of death for five minutes before the cursor once again became a text cursor.

Disabling several features in InDesign made the file somewhat workable:

1. Display performance – to these settings :

slowdown01
2. Pages panel – turn off the preview for the actual pages:

slowdown04
3. Turn the preflight panel off:

slowdown05
4. Live screen drawing – never:

slowdown03
5. Dynamic spelling off:

slowdown02
6. Do not use GREP styles or Nested styles
7. Do not use index entries or cross references

While this made the file workable, it was at the expense of the good features of InDesign. The slowdown was to the stage where using a word processor to accomplish the same task was considered!

Within the preferences, there is no ability to control the amount of RAM reserved for InDesign to use, nor is there the ability to control how often InDesign autosaves to its backup… something that is possibly slowing InDesign down even further.

Some of the features of InDesign were not necessary for this task as the project was completely black text supplied by the client, so having a lower quality display performance without seeing the page previews was not an issue. Preflight was not a concern with this particular file given that it was black text within one rather long text-frame and the spelling was to remain as the client provided the artwork.

Initially there was concern that turning GREP styles off would limit the control of “runt lines”. GREP styles had also been used for formatting of particular words, but because no type was going to be added, performing a one-off find/replace using the relevant GREP was able to remove the need for GREP styles. It was amazing to see the difference in speed when the file had the GREP styles turned on, opposed to when they were not applied – in this project the GREP styles were a major contributing factor to the file’s slow performance.

Followers of this blog will be familiar with several GREP styles that have been used to correct names or details within variable data campaigns. After this experience, it would appear that GREP styles are better suited to projects where content will be added dynamically (such as a Data Merged file) or constant alterations need to be made; rather than static documents – especially where no new content will be added.

The project DID have to be indexed (as discussed in a previous post) and found that once the file was indexed, the speed of the file slowed to a crawl.

%d bloggers like this: