Thanks for coming to InDesignSecrets.com, the world's #1 resource for all things InDesign!

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:

line breaks in data merge

Here’s how to set it up.

line breaks in data merge
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.

line breaks in data merge
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.

line breaks in data merge
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.

line breaks in data merge
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.

line breaks in data merge
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.

 

David Blanchard

David Blanchard

David Blanchard is a graphic designer from Phoenix, Arizona, but has spent most of his life between the U.S., France, and Germany. He currently lives in the Chattanooga area and is happily married with two fur-daughters. Follow his work at dtblanchard.com.
David Blanchard

Latest posts by David Blanchard (see all)

  • - November 30, -0001
Tags
Related Articles
Comments

8 Comments on “Controlling Line Breaks With Data Merge

  1. Hello,

    very clever trick, and by the way thanks for the knoweledge on dinosaurs’ diet I was afrain mine would starve of get obese.

  2. Não entendi qual o ganho de produtividade. Se devo editar manualmente o arquivo CSV (adicionando dois espaços) por que não edito manualmente diretamente o inDesign (adicionando as quebras de linhas)?

    Google Translator (sorry):
    I did not understand the productivity gain. If I should manually edit the CSV file (adding two spaces) why do I not manually edit inDesign directly (adding line breaks)?

    • Pierre-Louis: That is a very good point. In general, when talking about this kind of data publishing, the productivity gain does not come if you have to perform this only once — it is when you have to do this same thing many times.

    • The advantage I’ve found is being able to do this while still linking to the CSV file. You can add line breaks only if you run the data merge first, but then you lose the link. I personally find it nice to keep it directly linked to the CSV so that any changes stay live.

Leave a Reply

Your email address will not be published. Required fields are marked *