2

I set my address in an moderncv document with \address{...}{...}{...}.

Now I want to use that address somewhere else, how can I access the address?

  • Welcome to TeX.SX! Please help us help you by showing a minimal compilable example (including the place where you want to use the address). – TeXnician Nov 6 '17 at 13:52
3

Looking in moderncv.cls for the definition of \address tells you where the data are stored:

\NewDocumentCommand{\address}{mG{}G{}}{\def\@addressstreet{#‌​1}\def\@addresscity{‌​#2}\def\@addresscoun‌​try{#3}}

Here is an MWE extracting the data later, using

\makeatletter
Street: \@addressstreet\\
City: \@addresscity\\
Country: \@addresscountry

\documentclass[11pt,a4paper,sans]{moderncv} 

\moderncvstyle{classic} 
\moderncvcolor{blue} 
\usepackage{lipsum} 

\usepackage[scale=0.75]{geometry} 
 \firstname{John} % Your first name
 \familyname{Smith} % Your last name
 \address{123 Broadway}{City, State 12345}{USA}
 \mobile{(000) 111 1111}
 \phone{(000) 111 1112}
 \email{john@smith.com}
%----------------------------------------------------------------------------------------

\begin{document}

\makecvtitle % Print the CV title

%----------------------------------------------------------------------------------------
%   EDUCATION SECTION
%----------------------------------------------------------------------------------------

\section{Dissecting Address}
\makeatletter
Street: \@addressstreet\\
City: \@addresscity\\
Country: \@addresscountry

\end{document}

enter image description here

| improve this answer | |
  • How can I use them at an parameter? \cvitem{Address}{\@addressstreet, \@addresscity, \@addresscountry} gives me a lot of errors. – Auroratic Nov 6 '17 at 16:33
  • @Auroratic In a document @ is precluded from being part of a macro name. One can get around it by (hopefully temporarily) treating @ as a normal letter by invoking the switch \makeatletter. This is later to be turned off with \makeatother. So \makeatletter \cvitem{Address}{\@addressstreet, \@addresscity, \@addresscountry} \makeatother works for me in my code. – Steven B. Segletes Nov 6 '17 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.