注意:我正在使用sharelatex
我想知道是否有任何方法可以设置使用的文件的标题部分(包含个人信息的部分)的背景颜色moderncv
为了在视觉上区分标题和内容。
我尝试过minipage
,\hfill
等等,但我猜想这moderncv
使用了一个高度定制的模板,并且我迄今为止尝试过的所有方法都会导致编译错误。
\section{\includegraphics{../static/32x32/image.png}Expériences Professionnelles}
错误:
Error in fr/source.tex (line 54): Use of \@newline doesn't match its definition.
\@ifnextchar ... \reserved@d =#1\def \reserved@a {
#2}\def \reserved@b {#3}\f...
l.54 ...image.png}Expériences Professionnelles}
If you say, e.g., `\def\a1{...}', then you must always
put `1' after `\a', since control sequence names are
made up of letters only. The macro here has not been
followed by the required stuff, so I'm ignoring it.
答案1
这是一个选项。我将其重新定义\section
为针对classic
样式实现的,因此现在您有了第三个可选参数,允许您在部分之前放置任何内容(特别是图像):
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
\firstname{John}
\familyname{Smith}
\title{Curriculum Vitae}
\address{Street}{City, St. 1111}
\mobile{(000) 000 0000}
\email{[email protected]}
\makeatletter
\RenewDocumentCommand{\section}{smo}{%
\par\addvspace{2.5ex}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{section}{#2}%
\IfNoValueTF{#3}
{}
{\leavevmode\llap{#3\hspace{10pt}}}%
\parbox[t]{\hintscolumnwidth}{\strut\raggedleft\raisebox{\baseletterheight}{\color{color1}\rule{\hintscolumnwidth}{0.95ex}}}%
\hspace{\separatorcolumnwidth}%
\parbox[t]{\maincolumnwidth}{\strut\sectionstyle{#2}}
\par\nobreak\addvspace{1ex}\@afterheading%
}
\makeatother
\begin{document}
\makecvtitle
\section{Coursework}[\includegraphics[height=20pt]{example-image-a}]
\section{Coursework}[\includegraphics[height=20pt]{example-image-b}]
\section{Coursework}
\end{document}
如果图像必须出现在彩色条和标题之间,则重新定义会略有不同:
\documentclass[11pt,a4paper,sans]{moderncv}
\moderncvstyle{classic}
\moderncvcolor{blue}
\usepackage[scale=0.75]{geometry}
\firstname{John}
\familyname{Smith}
\title{Curriculum Vitae}
\address{Street}{City, St. 1111}
\mobile{(000) 000 0000}
\email{[email protected]}
\makeatletter
\RenewDocumentCommand{\section}{smo}{%
\par\addvspace{2.5ex}%
\phantomsection{}% reset the anchor for hyperrefs
\addcontentsline{toc}{section}{#2}%
\parbox[t]{\hintscolumnwidth}{\strut\raggedleft\raisebox{\baseletterheight} {\color{color1}\rule{\hintscolumnwidth}{0.95ex}}}%
\hspace{\separatorcolumnwidth}%
\IfNoValueTF{#3}
{\parbox[t]{\maincolumnwidth}{\strut\sectionstyle{#2}}}
{\parbox[t]{\maincolumnwidth}{\strut#3\ \sectionstyle{#2}}}%
\par\nobreak\addvspace{1ex}\@afterheading%
}
\makeatother
\begin{document}
\makecvtitle
\section{Coursework}[\includegraphics[height=20pt]{example-image-a}]
\section{Coursework}[\includegraphics[height=20pt]{example-image-b}]
\section{Coursework}
\end{document}