TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to create an environment (or any other command) for entering addresses. For example, I want something like this:

\name{John Doe}
\address{100 1st Street, New York, NY}

Then it prints following a certain format like:

\usepackage{wasysym} % Just for \XBox and \Square

\item[Address Type:] \XBox Home, \Square Work
\item[Name:] John Doe
\item[Phone:] 123-456-7890
\item[Address:] 100 1st Street, New York, NY

How can I do this? I am open to any form of environment, command, or anything else.

share|improve this question
up vote 9 down vote accepted

Here's a quick implementation using xkeyval just to give an idea of what can be done using this approach:

enter image description here

\usepackage{wasysym,xkeyval}% http://ctan.org/pkg/{wasysym,xkeyval}
    \item[Address Type:] %\cmdKV@address@type
      \def\addresschoice@type{home}\ifx\addresschoice@type\cmdKV@address@type\relax\XBox Home%
      \else\def\addresschoice@type{work}\ifx\addresschoice@type\cmdKV@address@type\relax\Square Work
      \else None\fi\fi
    \item[Name:] \cmdKV@address@name
    \item[Phone:] \cmdKV@address@phone
    \item[Address:] \cmdKV@address@address
\makeaddress[name={John Doe},address={100 1st Street, New York, NY},phone={123-456-7890},type=home]
\makeaddress[name={Jane Doe},address={Unknown}]

The main advantage would be that you can specify defaults for keys if they're not supplied, limit certain inputs to specific values and mix them in any order you like. You'll have to peruse the xkeyval documentation to view all the possibilities. I don't think my code is the most optimal or uses all the benefits of xkeyval, but at least it shows a proof of concept that should fit your use case.

share|improve this answer

You can use the directory package (see the example provided with the package at CTAN or on Christophe Geuzaine's homepage):


The package also allows introducing information from an address book into a document, for instance to generate a letterhead.

share|improve this answer

Your Answer


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.