完整代码

完整代码

我想将我的机构徽标添加到简历中,但不幸的是它们没有出现在正确的位置。我应该如何编辑代码,让图片出现在城市正上方,而不让“机构”向下移动,即让它与其他信息对齐? 在此处输入图片描述

 %% start of file `template.tex'.
%% Copyright 2006-2013 Xavier Danaux ([email protected]).
%
% This work may be distributed and/or modified under the
% conditions of the LaTeX Project Public License version 1.3c,
% available at http://www.latex-project.org/lppl/.


\documentclass[11pt,a4paper,sans]{moderncv}        % possible options include font size ('10pt', '11pt' and '12pt'), paper size ('a4paper', 'letterpaper', 'a5paper', 'legalpaper', 'executivepaper' and 'landscape') and font family ('sans' and 'roman')

% moderncv themes
\moderncvstyle{banking}                            % style options are 'casual' (default), 'classic', 'oldstyle' and 'banking'
\moderncvcolor{red}                                % color options 'blue' (default), 'orange', 'green', 'red', 'purple', 'grey' and 'black'
%\renewcommand{\familydefault}{\sfdefault}         % to set the default font; use '\sfdefault' for the default sans serif font, '\rmdefault' for the default roman one, or any tex font name
%\nopagenumbers{}                                  % uncomment to suppress automatic page numbering for CVs longer than one page

% character encoding
\usepackage[utf8]{inputenc}                       % if you are not using xelatex ou lualatex, replace by the encoding you are using
%\usepackage{CJKutf8}                              % if you need to use CJK to typeset your resume in Chinese, Japanese or Korean

% adjust the page margins
\usepackage[scale=0.75]{geometry}
%\setlength{\hintscolumnwidth}{3cm}                % if you want to change the width of the column with the dates
%\setlength{\makecvtitlenamewidth}{10cm}           % for the 'classic' style, if you want to force the width allocated to your name and avoid line breaks. be careful though, the length is normally calculated to avoid any overlap with your personal info; use this at your own typographical risks...

% personal data
\name{John}{Doe}
\title{Resumé title}                               % optional, remove / comment the line if not wanted
\address{street and number}{postcode city}{country}% optional, remove / comment the line if not wanted; the "postcode city" and and "country" arguments can be omitted or provided empty
\phone[mobile]{+1~(234)~567~890}                   % optional, remove / comment the line if not wanted
\phone[fixed]{+2~(345)~678~901}                    % optional, remove / comment the line if not wanted
\phone[fax]{+3~(456)~789~012}                      % optional, remove / comment the line if not wanted
\email{[email protected]}                               % optional, remove / comment the line if not wanted
\homepage{www.johndoe.com}                         % optional, remove / comment the line if not wanted
\extrainfo{additional information}                 % optional, remove / comment the line if not wanted
\photo[64pt][0.4pt]{picture}                       % optional, remove / comment the line if not wanted; '64pt' is the height the picture must be resized to, 0.4pt is the thickness of the frame around it (put it to 0pt for no frame) and 'picture' is the name of the picture file
\quote{Some quote}                                 % optional, remove / comment the line if not wanted

% to show numerical labels in the bibliography (default is to show no labels); only useful if you make citations in your resume
%\makeatletter
%\renewcommand*{\bibliographyitemlabel}{\@biblabel{\arabic{enumiv}}}
%\makeatother
%\renewcommand*{\bibliographyitemlabel}{[\arabic{enumiv}]}% CONSIDER REPLACING THE ABOVE BY THIS

% bibliography with mutiple entries
%\usepackage{multibib}
%\newcites{book,misc}{{Books},{Others}}
%----------------------------------------------------------------------------------
%            content
%----------------------------------------------------------------------------------
\begin{document}
%\begin{CJK*}{UTF8}{gbsn}                          % to typeset your resume in Chinese using CJK
%-----       resume       ---------------------------------------------------------
\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{\includegraphics[scale=0.5]{picture}City}{\textit{Grade}}{Description}  % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\end{document}


%% end of file `template.tex'.

答案1

我发现您正在尝试解决两个问题:

  1. 如何在“城市”字段添加换行符?
  2. 如何(垂直)将机构名称与徽标和城市名称对齐?

该命令的定义\cventry涉及tabular*环境,因此对换行符的使用不太友好。为了解决这个问题,可以将徽标和城市名称放在允许换行的 TikZ 节点中,并在“城市”字段中输入 TikZ 图片。为了实现这一点,您可以使用定义以下宏:

\newcommand\logocity[3][]{
  \tikz[baseline=(n.center)]
  \node(n)[align=center,inner sep=0,outer sep=0]{\includegraphics[#1]{#2}\\[1ex]#3};
}

它接受三个参数:

  • 第一个可选参数指定\includegraphics命令的选项
  • 第二个参数给出图像文件的名称
  • 第三个参数给出城市名称

注意,该选项[baseline=(n.center)]会使\tikzTikZ 图片的基线位于节点的中心,从而也解决了第二个问题。

完整代码

请注意,我已经加载了tikz包(mwe加载包只是为了提供本例中使用的图像。您不需要它。)

\documentclass[11pt,a4paper,sans]{moderncv}        % possible options include font size ('10pt', '11pt' and '12pt'), paper size ('a4paper', 'letterpaper', 'a5paper', 'legalpaper', 'executivepaper' and 'landscape') and font family ('sans' and 'roman')

\usepackage{tikz,mwe}

% moderncv themes
\moderncvstyle{banking}                            % style options are 'casual' (default), 'classic', 'oldstyle' and 'banking'
\moderncvcolor{red}                                % color options 'blue' (default), 'orange', 'green', 'red', 'purple', 'grey' and 'black'
%\renewcommand{\familydefault}{\sfdefault}         % to set the default font; use '\sfdefault' for the default sans serif font, '\rmdefault' for the default roman one, or any tex font name
%\nopagenumbers{}                                  % uncomment to suppress automatic page numbering for CVs longer than one page

% character encoding
\usepackage[utf8]{inputenc}                       % if you are not using xelatex ou lualatex, replace by the encoding you are using
%\usepackage{CJKutf8}                              % if you need to use CJK to typeset your resume in Chinese, Japanese or Korean

% adjust the page margins
\usepackage[scale=0.75]{geometry}
%\setlength{\hintscolumnwidth}{3cm}                % if you want to change the width of the column with the dates
%\setlength{\makecvtitlenamewidth}{10cm}           % for the 'classic' style, if you want to force the width allocated to your name and avoid line breaks. be careful though, the length is normally calculated to avoid any overlap with your personal info; use this at your own typographical risks...

% personal data
\name{John}{Doe}
\title{Resumé title}                               % optional, remove / comment the line if not wanted
\address{street and number}{postcode city}{country}% optional, remove / comment the line if not wanted; the "postcode city" and and "country" arguments can be omitted or provided empty
\phone[mobile]{+1~(234)~567~890}                   % optional, remove / comment the line if not wanted
\phone[fixed]{+2~(345)~678~901}                    % optional, remove / comment the line if not wanted
\phone[fax]{+3~(456)~789~012}                      % optional, remove / comment the line if not wanted
\email{[email protected]}                               % optional, remove / comment the line if not wanted
\homepage{www.johndoe.com}                         % optional, remove / comment the line if not wanted
\extrainfo{additional information}                 % optional, remove / comment the line if not wanted
\photo[64pt][0.4pt]{picture}                       % optional, remove / comment the line if not wanted; '64pt' is the height the picture must be resized to, 0.4pt is the thickness of the frame around it (put it to 0pt for no frame) and 'picture' is the name of the picture file
\quote{Some quote}                                 % optional, remove / comment the line if not wanted

% to show numerical labels in the bibliography (default is to show no labels); only useful if you make citations in your resume
%\makeatletter
%\renewcommand*{\bibliographyitemlabel}{\@biblabel{\arabic{enumiv}}}
%\makeatother
%\renewcommand*{\bibliographyitemlabel}{[\arabic{enumiv}]}% CONSIDER REPLACING THE ABOVE BY THIS

% bibliography with mutiple entries
%\usepackage{multibib}
%\newcites{book,misc}{{Books},{Others}}
%----------------------------------------------------------------------------------
%            content
%----------------------------------------------------------------------------------
\begin{document}
%\begin{CJK*}{UTF8}{gbsn}                          % to typeset your resume in Chinese using CJK
%-----       resume       ---------------------------------------------------------
\makecvtitle

\newcommand\logocity[3][]{
  \tikz[baseline=(n.center)]
  \node(n)[align=center,inner sep=0,outer sep=0]{\includegraphics[#1]{#2}\\[1ex]#3};
}

\section{Education}
\cventry{year--year}{Degree}{Institution}{\logocity[scale=.2]{image}{Some City}}{\textit{Grade}}{Description}  % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\end{document}

输出

在此处输入图片描述


回复评论更新

如果想要在“城市-年份-图像”组和“学院-学位/年级”组之间实现良好的对齐,则需要对样式moderncv进行一些“破解”。根据 的定义\cventry,我定义了一个名为 的新命令\cventrylogo,该命令通过允许徽标输入进行扩展\cventry。该命令定义如下:

\newcommand\minitab[2][l]{\begin{tabular}[b]{#1}#2\end{tabular}}
\newcommand\tnode[2][left]{\tikz[baseline=(n.center)]\node(n)[inner sep=0,outer sep=0,align=#1]{#2};}
\newcommand*{\cventrylogo}[8][.25em]{
  \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}%
    \tnode{\minitab[l]{
      {\bfseries #4} \\ {\itshape #3\ifthenelse{\equal{#7}{}}{}{, #7}}
    }}
    & 
    \tnode[right]{\minitab[r]{{\bfseries #6} \\ {\itshape #2} \\ #5}} 
      \\%
  \end{tabular*}%
  \ifx&#8&%
    \else{\\\vbox{\small#8}}\fi%
  \par\addvspace{#1}}

它需要 7 个参数(加上 1 个可选参数,现在我假设将使用所有 7 个参数,我还没有测试省略某些参数的情况),并以以下形式使用:

\cventrylogo{year--year}{Degree}{Institution}{\includegraphics[scale=.2]{image}}
            {City}{\textit{Grade}}{Description}

输出如下:

在此处输入图片描述


更新 2

\cventrylogo可以这样定义,使得“学院-学位/等级-描述”可以作为一个组进行中间对齐。

\newcommand\minitab[2][l]{\begin{tabular}[b]{#1}#2\end{tabular}}
\newcommand\tnode[2][left]{\tikz[baseline=(n.center)]\node(n)[inner sep=0,outer sep=0,align=#1]{#2};}
\newcommand*{\cventrylogo}[8][.25em]{
  \begin{tabular*}{\textwidth}{l@{\extracolsep{\fill}}r}%
    \tnode{\minitab[l]{
      {\bfseries #4} \\ {\itshape #3\ifthenelse{\equal{#7}{}}{}{, #7}} \\ {\small#8}
    }}
    & 
    \tnode[right]{\minitab[r]{{\bfseries #6} \\ {\itshape #2} \\ #5}} 
      \\%
  \end{tabular*}%
  \par\addvspace{#1}}

\cventrylogo因此,在第一次更新中使用as 会产生

在此处输入图片描述

(画黑线只是为了显示垂直对齐的效果。)

相关内容