# Flexible grid layout to list addresses

I've been using LaTeX to typeset my CV for quite a few years now, and I've always had one nagging problem that I've never quite managed to solve adequately.

The very last section in my CV is always a list of references. As my credentials grow, I've had to adapt the layout of the 3–5 references listed to a single column or 2 column or 3 column, depending on how much space I have remaining to ensure a tight fit.

A simple mockup to show what I mean:

Now I don't update/send out CVs every day (at most, maybe once a year), so I've gotten by with manual adjustments of spacing and using tables. However, this is not a solution that I like or is particularly elegant.

My question is — is it possible to create a grid on-the-fly, based on the dimensions given? For example, I would like to be able to do:

\begin{refList}[2]
\refItem{
John Smith\\
Department of Foo\\
Quxington University\\
jsmith@quxington.edu
}

\refItem{...}
\end{refList}


where the references are simply given as "items" and I can choose how many (equal width) columns to use by changing [2] to something else (the number of rows is automatically determined from the number of refItems and the number of columns). There is no need to check if the items will fit in the column, because I obviously won't be using a crazy number like [5] on my CV, which will squish/overflow/truncate the entries.

While I think such a system would be nice, I don't know where to begin (or if there are CTAN packages that already do this; a quick search didn't reveal anything). I'm looking for suggestions and help on implementing this/useful packages/etc.

-

This is nothing fancy, but allows for a flexible refList environment that automatically spaces \refItems on a line:

\documentclass{article}
\usepackage{hyperref}% http://ctan.org/pkg/hyperref
\newcommand{\refItem}[2][l]{% \refItem[<align>]{<reference>}
\begin{tabular}[t]{@{}#1@{}}#2\end{tabular}\hfill}
\newcommand{\email}[1]{% \email{<email>}
\href{mailto:#1}{\ttfamily #1}}%
\newenvironment{refList}
{\null\hfill}
{\null\par}
\begin{document}

\begin{refList}
\refItem{John Smith \\ Department of Foo \\ Quxington University \\ \email{jsmith@quxington.edu}}
\refItem{Jane Doe \\ Department of Bar \\ Bazville University \\ \email{jdoe@ubazville.edu}}
\refItem{Jack B.\ Nimble \\ Department of Bar \\ Quxington University \\ \email{jbn@quxington.edu}}
\end{refList}
\bigskip
\begin{refList}
\refItem[c]{John Smith \\ Department of Foo \\ Quxington University \\ \email{jsmith@quxington.edu}}
\refItem[r]{Jane Doe \\ Department of Bar \\ Bazville University \\ \email{jdoe@ubazville.edu}}
\end{refList}
\bigskip
\begin{refList}
\refItem{John Smith \\ Department of Foo \\ Quxington University \\ \email{jsmith@quxington.edu}}
\refItem{Jane Doe \\ Department of Bar \\ Bazville University \\ \email{jdoe@ubazville.edu}}
\refItem{Jack B.\ Nimble \\ Department of Bar \\ Quxington University \\ \email{jbn@quxington.edu}} \par\medskip\null\hfill
\refItem{John Smith \\ Department of Foo \\ Quxington University \\ \email{jsmith@quxington.edu}}
\refItem{Jane Doe \\ Department of Bar \\ Bazville University \\ \email{jdoe@ubazville.edu}}
\end{refList}

\end{document}


\refItem[<align>]{<reference>} sets <reference> like a regular tabular, where you can override the default left alignment (either centred or right-aligned, as in the second refList). As is visible in the MWE above, you don't need to specify the number of columns.

\email{<email>} is meant to specify an email using the traditional hyperref interface. You can, of course, play with the hyperref link settings to suit your needs. See the hyperref documentation for details.

Here's an alternative solution that uses tabularx and required user input in terms of the columns:

\documentclass{article}
\usepackage{hyperref,tabularx,array}% http://ctan.org/pkg/{hyperref,tabularx,array}
\newcommand{\refItem}[2][l]{% \refItem[<align>]{<reference>}
\begin{tabular}[t]{@{}#1@{}}#2\end{tabular}\hfill}
\newcommand{\email}[1]{% \email{<email>}
\href{mailto:#1}{\ttfamily #1}}%
\newenvironment{refList}[1]
{\noindent\tabularx{\linewidth}{@{}*{#1}{>{\centering\arraybackslash}X@{}}}}% \begin{refList}
{\endtabularx\par}% \end{refList}
\begin{document}

\begin{refList}{3}
\refItem{John Smith \\ Department of Foo \\ Quxington University \\ \email{jsmith@quxington.edu}} &
\refItem{Jane Doe \\ Department of Bar \\ Bazville University \\ \email{jdoe@ubazville.edu}} &
\refItem{Jack B.\ Nimble \\ Department of Bar \\ Quxington University \\ \email{jbn@quxington.edu}}
\end{refList}
\bigskip
\begin{refList}{2}
\refItem[c]{John Smith \\ Department of Foo \\ Quxington University \\ \email{jsmith@quxington.edu}} &
\refItem[r]{Jane Doe \\ Department of Bar \\ Bazville University \\ \email{jdoe@ubazville.edu}}
\end{refList}
\bigskip
\begin{refList}{3}
\refItem{John Smith \\ Department of Foo \\ Quxington University \\ \email{jsmith@quxington.edu}} &
\refItem{Jane Doe \\ Department of Bar \\ Bazville University \\ \email{jdoe@ubazville.edu}} &
\refItem{Jack B.\ Nimble \\ Department of Bar \\ Quxington University \\ \email{jbn@quxington.edu}} \\
\refItem{John Smith \\ Department of Foo \\ Quxington University \\ \email{jsmith@quxington.edu}} &
\refItem{Jane Doe \\ Department of Bar \\ Bazville University \\ \email{jdoe@ubazville.edu}}
\end{refList}

\end{document}

-
I like this one, but would it be possible to make the number of columns fixed (manually input) and equal width? – Lorem Ipsum Feb 17 '13 at 14:24
@LoremIpsum: I've updated the answer with a tabularx option where you manually specify the number of columns. – Werner Feb 17 '13 at 18:43

I would use the multicol package in combination with a trivlist.

\documentclass{article}
\usepackage{multicol}

\begin{document}

\begin{multicols}{3}
\begin{trivlist}
\item John Smith\\
Department of Foo\\
Quxington University\\
jsmith@quxington.edu\\

\item John Smith\\
Department of Foo\\
Quxington University\\
jsmith@quxington.edu\\

\item John Smith\\
Department of Foo\\
Quxington University\\
jsmith@quxington.edu\\

\end{trivlist}
\end{multicols}

\end{document}


You can change the{3} in \begin{multicols}{3} to as many columns as you wish and of course one can combine the trivlist and multicols into a user defined environment.

-
That solution doesn't automatically cope with items that are too wide for a threecolumn setup. – Martin Schröder Feb 16 '13 at 20:48
@MartinSchröder I am sure improvements can be added. One would think something that can use your ragged2e package. However, the OP indicated manual breaks. I just don't like tabulars for this sort of problem. Any suggestions? – Yiannis Lazarides Feb 16 '13 at 20:55
I like the idea here, but multi-cols doesn't seem to handle columns fewer than 3 in the MWE above. For instance, if I change it to 1 or 2, I get this output: i.stack.imgur.com/K9lR5.png – Lorem Ipsum Feb 17 '13 at 14:21
@LoremIpsum The 2 should work (as per your image). For one just omit the multicolumn – Yiannis Lazarides Feb 17 '13 at 15:29