How can I define colors for a moderncv
LaTeX file, for the following commands?
\address
\title
\phone
\mail
colormoderncv
How can I define colors for a moderncv
LaTeX file, for the following commands?
\address
\title
\phone
\mail
Your posted code produces this:
Check your log file, it appears that you do not have the marvosym fonts installed.
For the current version of moderncv
you can use the following "hack". But please keep an eye on the version number moderncv.cls 2015/07/28 v2.0.0 modern curriculum vitae and letter document class
. If the version changes it could be that this code can't work longer ...
In line 21 of the following MWE (marked with <===============
) you see the code:
\flushmakeheaddetails\@firstmakeheaddetailselementtrue\par\vspace{-\baselineskip}\null}
In the original file moderncvheadiii.sty
in line 91 you will find:
\flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}
The changing of \\
to \par\vspace{-\baselineskip}
gives the result you want.
BTW: I would not do this, the cv looks better with the space, I think.
Complete code:
% http://tex.stackexchange.com/questions/277361/moderncv-banking-style-default-space-between-address-and-phone
\listfiles
\documentclass[12pt]{moderncv}
\moderncvstyle{banking}
\makeatletter
\renewcommand{\makehead}{%\@initializecommand
\setlength{\makeheaddetailswidth}{0.8\textwidth}%
\hfil%
\parbox{\makeheaddetailswidth}{%
\centering%
% name and title
\namestyle{\@firstname~\@lastname}%
\ifthenelse{\equal{\@title}{}}{}{\titlestyle{~|~\@title}}\\% \isundefined doesn't work on \@title, as LaTeX itself defines \@title (before it possibly gets redefined by \title)
% optional detailed information
\if@details{%
\addressfont\color{color2}%
\ifthenelse{\isundefined{\@addressstreet}}{}{\addtomakeheaddetails{\addresssymbol\@addressstreet}%
\ifthenelse{\equal{\@addresscity}{}}{}{\addtomakeheaddetails[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and \addresscountry will always be defined but could be empty
\ifthenelse{\equal{\@addresscountry}{}}{}{\addtomakeheaddetails[~--~]{\@addresscountry}}%
\flushmakeheaddetails\@firstmakeheaddetailselementtrue\par\vspace{-\baselineskip}\null}% <========================
\collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
\addtomakeheaddetails{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
\ifthenelse{\isundefined{\@email}}{}{\addtomakeheaddetails{\emailsymbol\emaillink{\@email}}}%
\ifthenelse{\isundefined{\@homepage}}{}{\addtomakeheaddetails{\homepagesymbol\httplink{\@homepage}}}%
\collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
\addtomakeheaddetails{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
\ifthenelse{\isundefined{\@extrainfo}}{}{\addtomakeheaddetails{\@extrainfo}}%
\flushmakeheaddetails}\fi}\\[2.5em]}
\makeatother
\name{Sherlock}{Holmes}
\address{221B Baker Street}{London}{U.K.} % Your current address
\phone[mobile] {+44~(0)71234 00000} % Your mobile phone number
\email{superdetective@mail.com}
\begin{document}
\makecvtitle
\end{document}
Result:
A second way is to use command patchcmd
of package etoolbox
to change the line showed above.
The code for \patchcmd
is (\makeatletter
and \makeatother
are needed because @
is used in the searched line):
\makeatletter
\patchcmd{\makehead}{%search
\flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}{%replace
\flushmakeheaddetails\@firstmakeheaddetailselementtrue\par\vspace{-\baselineskip}\null}{%success
}{%failure
}
\makeatother
Then you have the complete MWE:
\documentclass[12pt]{moderncv}
\moderncvstyle{banking}
%\usepackage{etoolbox} % already loaded by moderncv!
\makeatletter
\patchcmd{\makehead}{%search
\flushmakeheaddetails\@firstmakeheaddetailselementtrue\\\null}{%replace
\flushmakeheaddetails\@firstmakeheaddetailselementtrue\par\vspace{-\baselineskip}\null}{%success
}{%failure
}
\makeatother
\name{Sherlock}{Holmes}
\address{221B Baker Street}{London}{U.K.} % Your current address
\phone[mobile] {+44~(0)71234 00000} % Your mobile phone number
\email{superdetective@mail.com}
\begin{document}
\makecvtitle
\end{document}
with the same result. Thanks to @Werner for his comment.
Best Answer
The colors of
moderncv
are controlled bycolor0
,color1
andcolor2
(the last one being used for the elements you mention). You can redefine these as you like (example for cyan):Some predefined settings can be loaded through
\moderncvcolor
:where the argument can be
blue
,orange
,green
,red
,purple
,grey
orblack
.Finally, you could also use directly
\textcolor
in the argument of any moderncv command other than\email
: