I have a csv file containing a list of names with addresses. I'm using the datatool package to load these and output stickers (using the labels package) for envelopes. This is done using \DTLforeach. Sometimes a name is too long for one line so I manually include a \\ in the csv as to not hyphenate a name.

I also want to print a complete list of all recipients using \DTLdisplaydb.

For my stickers this works very well, but of course this breaks my table listing all recipients.

As an MWE, save this as data.csv:

John Doe,Street 1,A City
Osop Eskobmr Sempeg Cotbadt\\Demnoskoywar,Street 9,B City
Jeeta Ex,Street 2,A City

and use

{\addresslabel{\name\\ \street\\ \city}}


I guess I could insert a special command like \mybreak and define it as empty or as \newline depending on the situation. But I would prefer to keep the data as is.

  • 1
    This is a common programming problem with addresses and databases one way out of it, is to define additional fields, i.e. name, addressi, addressii, city etc. I would avoid any presentational info in a DB like the plague. I am not sure if that is what you are looking though. – Yiannis Lazarides Dec 16 '10 at 19:34

\addresslabel typesets its argument ragged right (using \raggedright) in a box of the appropriate width. Since \raggedright almost never hyphenates, this is most likely sufficient. When I remove the \\ from your example, I get the behavior I believe you want.

One way to ensure you don't get any hyphenation is to add \lefthyphenmin1000 as an optional argument to \addresslabel:

\addresslabel[\lefthyphenmin1000]{\name\\ \street\\ \city}

This tells TeX that there must be at least 1000 characters to the left of the hyphenation point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.