Controlling Line Breaks With Data Merge
One of the limitations of Data Merge is its ability to control line breaks within a field. What if you’re pulling data from a CSV file and want the content of one field to be split across a few lines?
The most obvious workaround is to use a special character in your CSV file, then to run a grep search to replace that character with a line break. But that involves an extra step and requires you to run the data merge beforehand.
There’s another way that will give you control over the line breaks based directly on the content of your CSV file—you just need to do a little tweaking. In this example, we want to have the “time” and “menu” fields break across a few lines:
Here’s how to set it up.
1. Open your CSV file and locate where you want your line breaks to be. Add a double space where you want the line to break.
2. In InDesign, add a new character style called “LineBreak” and give it a tracking value of 10,000. Make sure everything else is left blank.
3. Create or edit the paragraph style you’ll be using along with the variable data. Add a new GREP style. Under “Apply Style,” choose your LineBreak character style and enter two spaces into the text field.
4. The outrageous tracking values will shove anything after those spaces onto the next line. If it’s not enough, you may need to use three or four spaces instead of two. Remember to adjust your CSV and GREP style.
5. The nice thing is that you can still left align, right align, or center your text correctly. This also works in tables.
There are obviously limitations to this approach, but for a basic workaround it’s saved me some time and a few headaches. I’ve found this especially useful when centering the vertical alignment of text that may or may not have more than one line in a variable data field.