0

I changed the beginning of my CV as

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

\moderncvstyle{classic}                             

\moderncvcolor{blue}                               

\usepackage[utf8]{inputenc}                       

\usepackage[scale=0.75]{geometry}

\makeatletter
\renewcommand*{\makecvtitle}{%
  \recomputecvlengths%
  % detailed information box
  \newbox{\makecvtitledetailsbox}%
  \savebox{\makecvtitledetailsbox}{%
    \addressfont\color{color2}%
    \begin{tabular}[b]{@{}p{10cm}@{}}%
      \ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet %
        \ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}} % 
      \ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile} %
      \ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
    \end{tabular}
  }%
  % name and title
  \newlength{\makecvtitledetailswidth}\settowidth{\makecvtitledetailswidth}{\usebox{\makecvtitledetailsbox}}%
  \ifthenelse{\lengthtest{\makecvtitlenamewidth=0pt}}% 
    {\setlength{\makecvtitlenamewidth}{\textwidth-\makecvtitlepicturewidth
}}%
    {}%
    \raggedright\namestyle{\@firstname\ \@familyname}\par\medskip%
    \ifthenelse{\equal{\@title}{}}{}{{\centering\titlestyle{\@title}\par}\medskip}%
\usebox{\makecvtitledetailsbox}%
  \par}% 
\makeatother

\name{John}{Doe}

\address{street and number}{postcode city}{country}

\email{[email protected]}                               

\begin{document}

\makecvtitle

\end{document}
 

The output (in overleaf) is enter image description here

For some reason, it does not work in WinEdt!

But the problem is that the name is not in the center.

I also would like to have "street and number" and "postcode city" in one column (on left) and email and phone number in another column (on right) next to it.

Could someone help me with this?

6
  • Sorry, not clear what you want to center. Can you please add a screenshot to your question? And please, add at least the preamble, starting with \documentclass.
    – MS-SPO
    Jun 14, 2022 at 11:23
  • Thank you for the comment. I'm new to everything here and I don't know what a preamble is! I put all the code that I use in the question and added the output I get from overleaf.
    – user271309
    Jun 14, 2022 at 14:36
  • That's fine. // Where did you get the code from? Did you read the moderncv-manual mirror.marwan.ma/ctan/macros/latex/contrib/moderncv/manual/… ?
    – MS-SPO
    Jun 14, 2022 at 15:00
  • As I see it, this class is quite limited. I.e. you can select from two themes, and that's it. From this perspective many of your commands don't match the manual (17 mnths old). // Though it can be done, changing macros might be a bit too much at the beginning. Did you have a look at alternatives: ctan.org/topic/cv ? As a rule of thumb, the koma-series tends to provide flexibility.
    – MS-SPO
    Jun 14, 2022 at 15:07
  • Perhaps it's even easier to find other Latex templates for CV's. Try e.g. google.com/search?&q=latex+cv , and also switch to images to see results. Looks like you can get almost anything you want.
    – MS-SPO
    Jun 14, 2022 at 15:34

1 Answer 1

1

I agree with some of the comments that if you want to completely restyle everything, there's no reason to use moderncv.

But if you like moderncv in other ways and just want to change the \makecvtitle command, it should be doable. You can do it with simpler code than what you were using—not sure where you got that code since I doubt you made it yourself… A lot of the complexity of the redefinition you were giving are eliminated if you know in advance which contact data is going to be supplied.

Here I'm separating the two "columns" of the address/contact information with \hfills, which right aligns the second column to the right side of the page. You may not want that, in which case something different would have to be done, but things can be fairly simply.

I also redefined the \mobile command since it wasn't properly setting \@mobile.

\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[utf8]{inputenc}
\usepackage[scale=0.75]{geometry}

\makeatletter
\renewcommand*{\mobile}[1]{\renewcommand{\@mobile}{#1}}

\renewcommand*{\makecvtitle}{%
{\centering\namestyle{\@firstname\ \@lastname}\par}\medskip
\leavevmode{\addressfont\color{color2}\addresssymbol\@addressstreet
\hfill
\mobilesymbol\@mobile\\
\@addresscity
\hfill
\emailsymbol\@email\\
}}
\makeatother
\name{John}{Doe}

\address{street and number}{postcode city}{country}

\mobile{(555) 555-5555}
\email{[email protected]}

\begin{document}

\makecvtitle

\end{document}

cv example

1
  • This is exactly what I was looking for. Thank you.
    – user271309
    Jun 14, 2022 at 16:54

You must log in to answer this question.