# Echo specific phrases later in the text

I am writing a college course outline. It contains both a table with an overview of the dates and topics and a more extended outline of the specific topics later in the text. Ideally, I would like to input the dates into the table and have other places in the text echo the dates, so I don't have to make the changes in multiple places. I'm sure this is possible, I just don't know how.

• If you say \def\dateColumbus{1492}, then wherever in the document you use \dateColumbus{}, the text 1492 will appear. – Steven B. Segletes Sep 16 '16 at 9:50

Using xparse, you could do something like this. Note that this uses the new and experimental(but stable) syntax from the LaTeX3-team. It is meant for class- and package-developers, so it follows a very different syntax than LaTeX and TeX. The same code could ofcourse be made in TeX also.

Here, you get info by writing \vars{name}, where name would produce your name.

You could of course use just a regular \newcommand{\myname}{John Doe} and you would have a variable by calling \myname. It depends on what kind of syntax you want.

### Code

\documentclass{article}

\usepackage{xparse}

\ExplSyntaxOn
\NewDocumentCommand{\vars}{m}
{
\str_case_x:nn {\str_foldcase:n {#1}}
{
{name}{John\ Doe}
{phone}{555\,12345}
{mytable}{%
\begin{tabular}{lr}
\hline
Foo & Bar \\
\hline
\vars{name} & \vars{phone}\\
\hline
\end{tabular}
}
}
}
\ExplSyntaxOff

\begin{document}

My name is \vars{name}.

\begin{table}[hbt]
\centering
\caption{My info}
\vars{mytable}
\end{table}

\end{document}