更改文件 modercvcolorgreen.sty 中的颜色

更改文件 modercvcolorgreen.sty 中的颜色

如何更改部分和栏标题的颜色?我尝试修改文件moderncvcolorgreen.sty中的以下行

\definecolor{color0}{rgb}{0,0,0}% black
\definecolor{color1}{rgb}{0,100,0}%Mygreen
%\definecolor{color1}{rgb}{0.35,0.70,0.30}% green
\definecolor{color2}{rgb}{0.45,0.45,0.45}% dark grey

但结果并不如预期:

在此处输入图片描述

答案1

您不需要更改文件moderncvcolorgreen.sty,您只需在序言中为颜色添加新的定义即可。

要定义条形图和部分标题的颜色,您需要更改颜色,color1例如

\definecolor{color1}{rgb}{100,0,0} % Mygreen defined as red 

为了使更改更容易被看到,我在 RGB 颜色模型中使用了红色。texdoc xcolor更多信息请参见...

的定义color1不仅用于部分中,正如您在以下 MWE 中看到的那样

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

\moderncvstyle{casual} % casual, classic, banking, oldstyle and fancy
\moderncvcolor{green}  % <=============================================

\usepackage[utf8]{inputenc}

\usepackage[scale=0.75]{geometry}

% personal data
\name{John}{Doe}
\title{Resumé title}
\address{street and number}{postcode city}{country}
\phone[mobile]{+1~(234)~567~890}
\phone[fixed]{+2~(345)~678~901}
\phone[fax]{+3~(456)~789~012}
\email{[email protected]}
\homepage{www.johndoe.com}
\social[linkedin]{john.doe}
\social[twitter]{jdoe}
\social[github]{jdoe}
\extrainfo{additional information}
\photo[64pt][0.4pt]{example-image-a}
\quote{Some quote}

\definecolor{color1}{rgb}{100,0,0}%Mygreen defined as red <=============


\begin{document}

\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution--3}{City--4}{\textit{Grade}--5}{Description--6}  % arguments 3 to 6 can be left empty
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}

\section{Experience}
\subsection{Vocational}
\cventry{year--year}{Job title}{Employer}{City}{}{General description 
  no longer than 1--2 lines.\newline{}%
Detailed achievements:%
\begin{itemize}%
\item Achievement 1;
\item Achievement 2, with sub-achievements:
  \begin{itemize}%
  \item Sub-achievement (a);
  \item Sub-achievement (b), with sub-sub-achievements (don't do this!);
    \begin{itemize}
    \item Sub-sub-achievement i;
    \item Sub-sub-achievement ii;
    \item Sub-sub-achievement iii;
    \end{itemize}
  \item Sub-achievement (c);
  \end{itemize}
\item Achievement 3.
\end{itemize}}
\cventry{year--year}{Job title}{Employer}{City}{}{Description 
  line 1\newline{}Description line 2}
\subsection{Miscellaneous}
\cventry{year--year}{Job title}{Employer}{City}{}{Description}

\section{Languages}
\cvitemwithcomment{Language 1}{Skill level}{Comment}
\cvitemwithcomment{\textbf{Language} 2}{\textbf{Skill} level}{Comment}
\cvitemwithcomment{Language 3}{Skill level}{Comment}

\end{document}

以及其第一页的结果:

在此处输入图片描述

如果你仅有的想要更改条形图和部分文本的颜色,您必须重新定义命令,\section例如

\makeatletter
\definecolor{mycolor}{rgb}{100,0,0} % My color for bar and section
\RenewDocumentCommand{\section}{sm}{%
  \par\addvspace{2.5ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{section}{#2}%
  \parbox[t]{\hintscolumnwidth}{\strut\raggedleft\raisebox{\baseletterheight}{\color{mycolor}\rule{\hintscolumnwidth}{0.95ex}}}%
  \hspace{\separatorcolumnwidth}%
  \parbox[t]{\maincolumnwidth}{\strut\sectionstyle{#2}}%
  \par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading

\renewcommand*{\sectionstyle}[1]{{\sectionfont\textcolor{mycolor}{#1}}}
\makeatother

并在你的序言中添加此代码。

相关内容