现代简历顶部对齐照片、姓名和信息

现代简历顶部对齐照片、姓名和信息

我正在尝试将现代简历文档的所有标题(姓名、标题和联系信息)顶部对齐。我找到了此代码

\usepackage{etoolbox}

\patchcmd{\makecvhead}{{minipage}[b]}{{minipage}[t]}{}{}

\newsavebox{\mytempbox}
\newlength{\mytitleoffset}
\savebox{\mytempbox}{\addressfont S}
\setlength{\mytitleoffset}{\ht\mytempbox}

\patchcmd{\makecvhead}{\raggedleft\fi}{\raggedleft\fi\vspace{-\mytitleoffset}}{}{}
\patchcmd{\makecvhead}{{tabular}[b]}{{tabular}[t]}{}{}

在回答这个问题时如何在 ModernCV 中为姓名/标题设置不同的对齐方式?.但是,我的简历中包含一张照片,虽然标题和联系信息的顶部对齐功能有效,但它们顶部对齐到照片底部正上方的某个点。我该如何解决这个问题,以便姓名、联系信息和照片都与页面顶部对齐。

Example document
\documentclass{moderncv}

\moderncvstyle{classic}

\name{John}{Doe}
\address{Street St., 167}{8888 Town}{Country}
\phone{+1~(234)~567~890}
\homepage{xxx.ddd.cc.ee}

\usepackage{etoolbox}

\patchcmd{\makecvhead}{{minipage}[b]}{{minipage}[t]}{}{}

\newsavebox{\mytempbox}
\newlength{\mytitleoffset}
\savebox{\mytempbox}{\addressfont S}
\setlength{\mytitleoffset}{\ht\mytempbox}
\photo[96pt]{headshot}

\patchcmd{\makecvhead}{\raggedleft\fi}{\raggedleft\fi\vspace{-\mytitleoffset}}{}{}
\patchcmd{\makecvhead}{{tabular}[b]}{{tabular}[t]}{}{}


\begin{document}
\makecvtitle

\end{document}

在此处输入图片描述

答案1

带包装adjustbox和新品\patchcmd

备注:我添加了一个包showframe来查看布局,并在最终文档中进行评论。

\documentclass{moderncv}
\usepackage{showframe}%<-- comment inthe final document
\usepackage{adjustbox}%<< added

\moderncvstyle{classic}

\name{John}{Doe}
\address{Street St., 167}{8888 Town}{Country}
\phone{+1~(234)~567~890}
\homepage{xxx.ddd.cc.ee}

\usepackage{etoolbox}

\patchcmd{\makecvhead}{{minipage}[b]}{{minipage}[t]}{}{}

\newsavebox{\mytempbox}
\newlength{\mytitleoffset}
\savebox{\mytempbox}{\addressfont S}
\setlength{\mytitleoffset}{\ht\mytempbox}

\photo[96pt]{example-image-a}

\patchcmd{\makecvhead}{\raggedleft\fi}{\raggedleft\fi\vspace{-\mytitleoffset}}{}{}
\patchcmd{\makecvhead}{{tabular}[b]}{{tabular}[t]}{}{}

%%%%%%%%%%%%%  new patchcmd
\makeatletter
\patchcmd{\makecvhead}{\framebox{\includegraphics[width=\@photowidth]{\@photo}}}
{\framebox{\adjustbox{valign=t}{\includegraphics[width=\@photowidth]{\@photo}}}}{}{}
\makeatother
%%%%%%%%%%%%%%%%%%%%
\begin{document}
\makecvtitle

\end{document}

在此处输入图片描述

相关内容