Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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:

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

and use

\documentclass{article}
\usepackage{labels}
\usepackage{datatool}
\begin{document}
\DTLloaddb{address}{data.csv}
\DTLforeach{address}{\name=Name,\street=Street,\city=City}%
{\addresslabel{\name\\ \street\\ \city}}

\DTLdisplaydb{address}
\end{document}

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.

share|improve this question
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

1 Answer 1

up vote 1 down vote accepted

\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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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