我是 LaTeX 新手moderncv
。我想把我的联系信息放在名字下面,但我不知道怎么做。我发现这个问题跟我的类似,但是改变了图片的位置。这是我.tex
修改后的文件:
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\makeatletter
\renewcommand*{\makecvtitle}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputecvlengths%
% optional 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}} % if \addresstreet is defined, \addresscity will always be defined but could be empty
\ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile} %
\ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
\end{tabular}
}%
% optional photo (pre-rendering)
\newbox{\makecvtitlepicturebox}%
\savebox{\makecvtitlepicturebox}{%
\ifthenelse{\isundefined{\@photo}}%
{}%
{%
% \hspace*{\separatorcolumnwidth}%
\color{color1}%
\setlength{\fboxrule}{\@photoframewidth}%
\ifdim\@photoframewidth=0pt%
\setlength{\fboxsep}{0pt}\fi%
\framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
% name and title
\newlength{\makecvtitledetailswidth}\settowidth{\makecvtitledetailswidth}{\usebox{\makecvtitledetailsbox}}%
\newlength{\makecvtitlepicturewidth}\settowidth{\makecvtitlepicturewidth}{\usebox{\makecvtitlepicturebox}}%
\ifthenelse{\lengthtest{\makecvtitlenamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvtitlenamewidth=0pt)
{\setlength{\makecvtitlenamewidth}{\textwidth-\makecvtitlepicturewidth
}}%
{}%
% \begin{minipage}[b]{\makecvtitlenamewidth}%
\raggedright\namestyle{\@firstname\ \@familyname}\par\medskip%
\ifthenelse{\equal{\@title}{}}{}{{\centering\titlestyle{\@title}\par}\medskip}%
%\hfill%
% detailed information
% \llap{
%
\usebox{\makecvtitledetailsbox}%
%\end{minipage}\ignorespaces%
%}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
% optional photo (rendering)
\usebox{\makecvtitlepicturebox}\\[2.5em]%
% optional quote
\ifthenelse{\isundefined{\@quote}}%
{}%
{{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
\par}% to avoid weird spacing bug at the first section if no blank line is left after \makecvtitle
\makeatother
\usepackage[scale=0.75]{geometry}
% personal data
\name{John}{Doe}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\email{[email protected]}
\photo[64pt][0.4pt]{picture}
\begin{document}
\makecvtitle
\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\end{document}
有此结果
但我想将图片稍微放在上面,更多地放在右边,就像在文件中不加修改的那样:
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
% personal data
\name{John}{Doe}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\email{[email protected]}
\photo[64pt][0.4pt]{picture}
\begin{document}
\makecvtitle
\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\end{document}
我应该做些什么?
答案1
更新(moderncv
v2.0)
使用moderncv
v2.0,我们必须完全重新定义\makecvhead
才能实现您想要的效果,因此请在序言中添加以下几行:
\makeatletter
\renewcommand*{\makecvhead}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputecvlengths%
% optional detailed information (pre-rendering)
\@initializebox{\makecvheaddetailsbox}%
\if@details%
\def\phonesdetails{}%
\collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
\protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
\def\socialsdetails{}%
\collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
\protected@edef\socialsdetails{\socialsdetails\protect\makenewline\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
\savebox{\makecvheaddetailsbox}{%
\addressfont\color{color2}%
\if@left\begin{tabular}[b]{@{}l@{}}\fi%
\if@right\begin{tabular}[b]{@{}l@{}}\fi%
\ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
\ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
\phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
\ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
\ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
\socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
\end{tabular}
}\fi%
% optional photo (pre-rendering)
\@initializebox{\makecvheadpicturebox}%
\savebox{\makecvheadpicturebox}{%
\ifthenelse{\isundefined{\@photo}}%
{}%
{%
\if@left%
\hspace*{\separatorcolumnwidth}\fi%
\color{color1}%
\setlength{\fboxrule}{\@photoframewidth}%
\ifdim\@photoframewidth=0pt%
\setlength{\fboxsep}{0pt}\fi%
\framebox{\includegraphics[width=\@photowidth]{\@photo}}}%
\if@right%
\hspace*{\separatorcolumnwidth}\fi}%
% name and title (pre-rendering)
\@initializelength{\makecvheaddetailswidth}\settowidth{\makecvheaddetailswidth}{\usebox{\makecvheaddetailsbox}}%
\@initializelength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
\ifthenelse{\lengthtest{\makecvheadnamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvheadnamewidth=0pt)
{\setlength{\makecvheadnamewidth}{\textwidth-\makecvheaddetailswidth-\makecvheadpicturewidth}}%
{}%
\@initializebox{\makecvheadnamebox}%
\savebox{\makecvheadnamebox}{%
\begin{minipage}[b]{\makecvheadnamewidth}%
\if@left\raggedright\fi%
\if@right\raggedleft\fi%
\namestyle{\@firstname\ \@lastname}%
\ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
\end{minipage}}%
% rendering
\if@left%
\usebox{\makecvheadnamebox}%
\hfill%
\usebox{\makecvheadpicturebox}\\[1.5em]%
\usebox{\makecvheaddetailsbox}\fi% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
\if@right%
\usebox{\makecvheadpicturebox}%
\rlap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
\hfill%
\usebox{\makecvheadnamebox}\fi%
\\[2.5em]%
% optional quote
\ifthenelse{\isundefined{\@quote}}%
{}%
{{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
\par}% to avoid weird spacing bug at the first section if no blank line is left after \makecvhead
\makeatother
完整代码:
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
% personal data
\name{John}{Doe}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\email{[email protected]}
\photo[64pt][0.4pt]{picture}
\makeatletter
\renewcommand*{\makecvhead}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputecvlengths%
% optional detailed information (pre-rendering)
\@initializebox{\makecvheaddetailsbox}%
\if@details%
\def\phonesdetails{}%
\collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
\protected@edef\phonesdetails{\phonesdetails\protect\makenewline\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
\def\socialsdetails{}%
\collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
\protected@edef\socialsdetails{\socialsdetails\protect\makenewline\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
\savebox{\makecvheaddetailsbox}{%
\addressfont\color{color2}%
\if@left\begin{tabular}[b]{@{}l@{}}\fi%
\if@right\begin{tabular}[b]{@{}l@{}}\fi%
\ifthenelse{\isundefined{\@addressstreet}}{}{\makenewline\addresssymbol\@addressstreet%
\ifthenelse{\equal{\@addresscity}{}}{}{\makenewline\@addresscity}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
\ifthenelse{\equal{\@addresscountry}{}}{}{\makenewline\@addresscountry}}%
\phonesdetails% needs to be pre-rendered as loops and tabulars seem to conflict
\ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
\ifthenelse{\isundefined{\@homepage}}{}{\makenewline\homepagesymbol\httplink{\@homepage}}%
\socialsdetails% needs to be pre-rendered as loops and tabulars seem to conflict
\ifthenelse{\isundefined{\@extrainfo}}{}{\makenewline\@extrainfo}%
\end{tabular}
}\fi%
% optional photo (pre-rendering)
\@initializebox{\makecvheadpicturebox}%
\savebox{\makecvheadpicturebox}{%
\ifthenelse{\isundefined{\@photo}}%
{}%
{%
\if@left%
\hspace*{\separatorcolumnwidth}\fi%
\color{color1}%
\setlength{\fboxrule}{\@photoframewidth}%
\ifdim\@photoframewidth=0pt%
\setlength{\fboxsep}{0pt}\fi%
\framebox{\includegraphics[width=\@photowidth]{\@photo}}}%
\if@right%
\hspace*{\separatorcolumnwidth}\fi}%
% name and title (pre-rendering)
\@initializelength{\makecvheaddetailswidth}\settowidth{\makecvheaddetailswidth}{\usebox{\makecvheaddetailsbox}}%
\@initializelength{\makecvheadpicturewidth}\settowidth{\makecvheadpicturewidth}{\usebox{\makecvheadpicturebox}}%
\ifthenelse{\lengthtest{\makecvheadnamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvheadnamewidth=0pt)
{\setlength{\makecvheadnamewidth}{\textwidth-\makecvheaddetailswidth-\makecvheadpicturewidth}}%
{}%
\@initializebox{\makecvheadnamebox}%
\savebox{\makecvheadnamebox}{%
\begin{minipage}[b]{\makecvheadnamewidth}%
\if@left\raggedright\fi%
\if@right\raggedleft\fi%
\namestyle{\@firstname\ \@lastname}%
\ifthenelse{\equal{\@title}{}}{}{\\[1.25em]\titlestyle{\@title}}%
\end{minipage}}%
% rendering
\if@left%
\usebox{\makecvheadnamebox}%
\hfill%
\usebox{\makecvheadpicturebox}\\[1.5em]%
\usebox{\makecvheaddetailsbox}\fi% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
\if@right%
\usebox{\makecvheadpicturebox}%
\rlap{\usebox{\makecvheaddetailsbox}}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvheadnamewidth is forced
\hfill%
\usebox{\makecvheadnamebox}\fi%
\\[2.5em]%
% optional quote
\ifthenelse{\isundefined{\@quote}}%
{}%
{{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
\par}% to avoid weird spacing bug at the first section if no blank line is left after \makecvhead
\makeatother
\begin{document}
\makecvtitle
\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\end{document}
原始答案(适用于旧版本moderncv
)
通过对代码进行一些修改...我修改了以下几行
% \begin{minipage}[b]{\makecvtitlenamewidth}%
\raggedright\namestyle{\@firstname\ \@familyname}\par\medskip%
\ifthenelse{\equal{\@title}{}}{}{{\centering\titlestyle{\@title}\par}\medskip}%
%\hfill%
% detailed information
% \llap{
%
\usebox{\makecvtitledetailsbox}%
%\end{minipage}\ignorespaces%
%}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
% optional photo (rendering)
\usebox{\makecvtitlepicturebox}\\[2.5em]%
到
\begin{minipage}[b]{\makecvtitlenamewidth}
\raggedright\namestyle{\@firstname\ \@familyname}\par\medskip%
\ifthenelse{\equal{\@title}{}}{}{{\centering\titlestyle{\@title}\par}\medskip}%
%\hfill%
% detailed information
% \llap{
%
\end{minipage}\hfill%
\raisebox{1em}{\usebox{\makecvtitlepicturebox}}\vspace{2.5em}%
\usebox{\makecvtitledetailsbox}%
%}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
% optional photo (rendering)
结果是
完整代码:
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\makeatletter
\renewcommand*{\makecvtitle}{%
% recompute lengths (in case we are switching from letter to resume, or vice versa)
\recomputecvlengths%
% optional 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}} % if \addresstreet is defined, \addresscity will always be defined but could be empty
\ifthenelse{\isundefined{\@mobile}}{}{\makenewline\mobilesymbol\@mobile} %
\ifthenelse{\isundefined{\@email}}{}{\makenewline\emailsymbol\emaillink{\@email}}%
\end{tabular}
}%
% optional photo (pre-rendering)
\newbox{\makecvtitlepicturebox}%
\savebox{\makecvtitlepicturebox}{%
\ifthenelse{\isundefined{\@photo}}%
{}%
{%
% \hspace*{\separatorcolumnwidth}%
\color{color1}%
\setlength{\fboxrule}{\@photoframewidth}%
\ifdim\@photoframewidth=0pt%
\setlength{\fboxsep}{0pt}\fi%
\framebox{\includegraphics[width=\@photowidth]{\@photo}}}}%
% name and title
\newlength{\makecvtitledetailswidth}\settowidth{\makecvtitledetailswidth}{\usebox{\makecvtitledetailsbox}}%
\newlength{\makecvtitlepicturewidth}\settowidth{\makecvtitlepicturewidth}{\usebox{\makecvtitlepicturebox}}%
\ifthenelse{\lengthtest{\makecvtitlenamewidth=0pt}}% check for dummy value (equivalent to \ifdim\makecvtitlenamewidth=0pt)
{\setlength{\makecvtitlenamewidth}{\textwidth-\makecvtitlepicturewidth
}}%
{}%
\begin{minipage}[b]{\makecvtitlenamewidth}
\raggedright\namestyle{\@firstname\ \@familyname}\par\medskip%
\ifthenelse{\equal{\@title}{}}{}{{\centering\titlestyle{\@title}\par}\medskip}%
%\hfill%
% detailed information
% \llap{
%
\end{minipage}\hfill%
\raisebox{1em}{\usebox{\makecvtitlepicturebox}}\vspace{2.5em}%
\usebox{\makecvtitledetailsbox}%
%}% \llap is used to suppress the width of the box, allowing overlap if the value of makecvtitlenamewidth is forced
% optional photo (rendering)
% optional quote
\ifthenelse{\isundefined{\@quote}}%
{}%
{{\centering\begin{minipage}{\quotewidth}\centering\quotestyle{\@quote}\end{minipage}\\[2.5em]}}%
\par}% to avoid weird spacing bug at the first section if no blank line is left after \makecvtitle
\makeatother
\usepackage[scale=0.75]{geometry}
% personal data
\name{John}{Doe}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\email{[email protected]}
\photo[64pt][0.4pt]{picture}
\begin{document}
\makecvtitle
\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\end{document}