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.

Following good typography, what is the proper environment or LaTeX code for displaying this kind of list?

Name:

Telephone:

E-mail:

Web site:

The description environment never seems to look right for this kind of situation, especially when I have many such lists appearing within a document. Is there a special environment recommended for this kind of information?

Note, I am not necessarily referring to data appearing in in the front-matter. This can be information within the document and need not necessarily be presenting information about the author of the document.

share|improve this question
    
You could put the data in a tabular. That allows you to right-align the first column and left-align the second. Makes it look a little better in my opinion. –  Roelof Spijker Nov 14 '11 at 12:19
    
I would use a tabular too, but with two left aligned columns, e.g. \begin{tabular}{@{}ll@{}} or \begin{tabularx}{@{}l>{\raggedright}X@{}} (use \tabularnewline in this case). –  Schweinebacke Nov 14 '11 at 12:23
add comment

2 Answers

up vote 6 down vote accepted

As mentioned in the comments the simplest would be to a tabular environment similar to the solutions from Align colums of text and use tabular to align the columns, or the tabbing environment.

enter image description here

If there is a lot of data you should consider using more than just one column.

enter image description here

\documentclass[border=5pt]{standalone}
\begin{document}
\noindent
\begin{tabular}{l@{\thinspace}l}
Name:      &Village\\
Telephone: &+12 111 111\\
E-mail:    &village@something.com\\
Web site:  &http://tex.stackexchange.com
\end{tabular}

\bigskip
If there is a lot of data consider two columns:

\medskip
\noindent
\begin{tabular}{l@{\thinspace}ll@{\thinspace}l}
Name:       &Village         &Email:    &village@something.com\\
Mobile:     &+12 111 111 111 &Website:  &http://tex.stackexchange.com\\
Phone:      &+12 111 111     &Birthdate:&04/01/1977
\end{tabular}
\end{document}

As per @Werner's comment, it would be useful to define as macro so that the formatting is consistent. This is especially important if you are typesetting this more than once in a document. I have also used \url here as per @YiannisLazarides suggestion, along with the hyperref package to provide click able link. You could also just use the url package.

This version also uses the collcell package to provide the flexibility of selecting if the colon's are to be aligned using the A column type, or placed on the left using the L column type. This might be overkill for the case where you only have 4 entries, and could manually include the : in the \UserInfo macro at the appropriate points). But if the list of entries grows longer this method allows you to easily switch between the two formats, should you later decide you like one version over the other.

\documentclass{article}
\usepackage{hyperref}
\usepackage{collcell}

\newcommand{\AddColon}[1]{#1:}%
\newcolumntype{L}{>{\collectcell\AddColon}{l}<{\endcollectcell}@{\thinspace}}% if want colons on left
\newcolumntype{A}{l@{:\thinspace}}% if want colons aligned

\newcommand{\UserInfo}[5][L]{%  #1 can be A=aligned colon, L=left colon
    \par\noindent%
    \begin{tabular}{#1 l}%
        Name      &#2\\%
        Telephone &#3\\%
        E-mail    &#4\\%
        Web site  &\url{#5}%
    \end{tabular}%
    \ignorespaces\par%
}

\begin{document}
\UserInfo{Village}{+12 111 111}{village@something.com}{http://tex.stackexchange.com}
\bigskip
\UserInfo[A]{Village}{+12 111 111}{village@something.com}{http://tex.stackexchange.com}
\end{document}

enter image description here

share|improve this answer
    
For the sake of consistency, I would suggest writing a macro that takes the personal information as arguments. Something like \info{<name>}{<telephone>}{<email>}{<website>}. –  Werner Nov 14 '11 at 18:16
    
@Werner: Good point. I have updated the solution to include that. –  Peter Grill Nov 14 '11 at 18:27
    
@PeterGrill add this and you have a db also tex.stackexchange.com/questions/15330/… and a top solution. I would also user \url :) –  Yiannis Lazarides Nov 14 '11 at 18:48
    
@Peter Grill : you forgot to use the arguments #1, #2, #3 and #4 in the definition of the macro. –  projetmbc Nov 14 '11 at 19:49
    
@projetmbc: Wow that's embarrassing. Thanks for pointing that out. –  Peter Grill Nov 14 '11 at 19:57
show 2 more comments

Just to show some variations, here is a key-value approach:

\documentclass[a4paper]{article}
\usepackage{keyval,booktabs}

\makeatletter
\def\ui@key#1{\define@key{ui}{#1}{\@namedef{ui@#1}{##1}}}
\ui@key{name}\ui@key{place}\ui@key{phone}\ui@key{mobile}
\ui@key{email}\ui@key{website}\ui@key{style}

\def\ui@style@one{\noindent\begin{tabular}{@{}l@{ }l@{}}
  \toprule
  \multicolumn{2}{@{}l@{}}{Name: \ui@name} \\
  \midrule
  Place:   & \ui@place \\
  Mobile:  & \ui@mobile \\
  Phone:   & \ui@phone \\
  E-Mail:  & \texttt{\ui@email} \\
  Web site:& \texttt{\ui@website} \\
  \bottomrule
  \end{tabular}}
\def\ui@style@two{\noindent\begin{tabular}{@{}l@{ }l@{\qquad}l@{ }l@{}}
  \toprule
  \multicolumn{4}{@{}l@{}}{Name: \ui@name} \\
  \midrule
  Place:   & \ui@place     & E-Mail:    & \texttt{\ui@email} \\
  Mobile: & \ui@mobile   & Web site:  & \texttt{\ui@website} \\
  Phone:  & \ui@phone    & & \\
  \bottomrule
  \end{tabular}}

\newcommand{\UserInfo}[1]{%
  \setkeys{ui}{style=one,name=,place=,mobile=,phone=,email=,website=,#1}%
  \@nameuse{ui@style@\ui@style}}
\makeatother

\begin{document}
\UserInfo{%style=one, % default
  name=Brutus L. User,
  place=Village,
  mobile=+12 111 111 111,
  phone=+12 111 111,
  email=village@something.com,
  website=http://tex.stackexchange.com}

\bigskip

\UserInfo{style=two,
  name=Brutus L. User,
  place=Village,
  mobile=+12 111 111 111,
  phone=+12 111 111,
  email=village@something.com,
  website=http://tex.stackexchange.com}


\end{document}

One can choose between one an two column tabular. The \ui@key macro is just to avoid repeating over and over similar definitions such as

\define@key{ui}{name}{\def\ui@name{#1}}

enter image description here

share|improve this answer
    
Hope you don't mind me asking an unrelated question, is it possible to pass values from one family to another with keyval, i.e., if you had a key width for example in one family to pass it onto an includegraphics? –  Yiannis Lazarides Nov 14 '11 at 23:24
    
@YiannisLazarides I think that xkeyval says something about this. –  egreg Nov 14 '11 at 23:31
    
@YiannisLazarides: With xkeyval you can give multiple families which a tried one by one, and you can use \setkeys* to store all unknown keys in a macro which can be processed later. I'm using this in adjustbox for example. –  Martin Scharrer Nov 15 '11 at 10:01
    
@MartinScharrer Thanks you you guys are right I had a look at the xkeyval docs and its all there. –  Yiannis Lazarides Nov 15 '11 at 10:58
add comment

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.