top of page

How to Create "First Letter" Subheadings

Updated: Mar 25, 2021


When publishing something like a directory, it's often desirable to insert single-letter subheadings to separate the entries into groups with a single-letter heading.




This is easy to achieve with CatBase.

  1. Download our free script "FirstLetter" from the Downloads page (in the Freebies section).

  2. Install the script in your CatBase database:

  3. Go to the Admin main tab.

  4. Expand the Database Setup topic on the left of the window.

  5. Select the table that you want to apply the script to.

  6. Select the checkbox Run a script when a record is saved (underneath the list of fields).

  7. Click the View/Modify Script button next to that checkbox.

  8. Click Import a Script.

  9. Locate the FirstLetter script and double-click it to select it.

  10. Click the Save button. DO NOT attempt to modify the script! You'll break it!

  11. With the table still selected, click the New Field button.

  12. Enter the field name First Letter. It must be spelled exactly like that, although it isn't case-sensitive.

  13. Select the Indexed checkbox.

  14. Save it.

  15. Click the Save button.

  16. Now whenever a record in that table is saved - whether it's a new or modified record - the first letter of the Key Field will be copied into the First Letter field.

  17. Update your existing data:

  18. Go to the table's main tab (where you see the list of records for that table).

  19. Click the Show All button.

  20. Click the Search & Replace button.

  21. Set up the Search & Replace dialog like this:


  1. NOTE! Make sure you enter something into the Change To: text box. We've used an "A" here - it doesn't matter, because the script will update it as appropriate for each record.

Click OK, then click Yes in the Confirm dialog.

All the records will be updated.

Update your Publishing Stylesheet:

  1. Open the Publishing Stylesheet that you want to apply the single letter subheadings to (or create a new one).

  2. Add a new Paragraph and make sure it is the first Paragraph in the list (click and drag it into position if it isn't)

  3. Name it something creative such as "Letter subheading" and choose the Paragraph Style that you want these subheadings to be set in, then Save that Paragraph.

  4. Add an Element to the new Paragraph.

  5. Select the field: First Letter for that Element.

  6. Go to the Preferences tab in the Element window.

  7. In the Options area, select the checkbox labelled Unique Group Entry. This tells CatBase that you only want to publish this Element ONCE for each group.

  8. Also select the first checkbox, Omit Paragraph if this Element is blank.

  9. Save the Element.

  10. With the Publishing Stylesheet still open, go to the Preferences tab.

  11. You need to modify the existing Sort Order, or create a new one. You must have the First Letter field as the first item in the sort list. (For more info about Sort Formats, see the Sort Editor tutorial.)

You're done! When you publish your data using that Publishing Stylesheet, it will be sorted first by the First Letter field and then by whatever other fields you've selected (probably the Key Field).

94 views0 comments

Recent Posts

See All
bottom of page