Contact list as dictionary

by N3buchadnezzar   Last Updated August 13, 2019 20:23 PM - source

Introduction

I am trying to create a template to make it easier to type problemsets and exams for the university I am working for. In that regard it is often neccecary to write down the contact information of the members of the faculty.

What I am looking for is a user friendly way to insert people into a "dictionary" and retrieve them using some ID.

Something like the following would ideal

Example

\updateContactInfo{
    \addMember{
        id = joe,
        name = Joe Doe,
        mobile = 12345678,
        phone = 87654321
    }
    \addMember{
        id = jane,
        name = Jane Doe,
        mobile = 12345678,
        phone = 87654321
    }
}

\begin{document}

\getContactInfo[jane][name]

\end{document}

Here is what I have so far, but the code is not ideal. The syntax is hard to read and update for the normal user

Code

\documentclass{article}
\usepackage[utf8]{inputenc}

\usepackage{xparse,xstring}

\NewDocumentCommand\contactInfo{m m}{%
    \IfStrEqCase{#1}{%
        {jane}{%
        \IfStrEqCase{#2}{%
            {name}{Jane Doe}
            {mobile}{32132132}
            {phone}{123123123}
            }[]
        }
        {Joe}{%       
        \IfStrEqCase{#2}{%
            {name}{Joe Doe}
            {mobile}{32132132}
            {phone}{123123123}
            }[]
        }
        {richard}{%
        \IfStrEqCase{#2}{%
            {name}{Richard Roe}
            {mobile}{32132132}
            {phone}{123123123}
            }[]
        }%
        }[]
}

\begin{document}

\contactInfo{jane}{mobile}

\end{document}
Tags : macros lists


Related Questions



Some text or symbol after \item element

Updated July 17, 2017 14:23 PM

Comma-separated list

Updated February 26, 2018 09:23 AM

Create an in-document to-do-list

Updated April 03, 2017 19:23 PM

Macro to format a list with arbitrary items

Updated July 07, 2019 19:23 PM