更新至 class moderncv,版本 2.0.0(当前版本):

更新至 class moderncv,版本 2.0.0(当前版本):

使用moderncv如下;

\documentclass{moderncv}

\moderncvtheme[black]{casual}

我想从输出中删除与部分标题相邻的彩色支柱/矩形/框。

有人能告诉我怎么做吗?我以前只用乳胶来写文章。

答案1

在给定的两行后面写入以将前导框的颜色更改为白色:

\definecolor{mycolor}{rgb}{255,255,255}   % color white
\makeatletter                             % make @ a letter
\renewcommand*{\section}[1]{%
  \par\addvspace{2.5ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{section}{#1}%
  \parbox[t]{\hintscolumnwidth}{\strut\raggedleft\raisebox{\baseletterheight}{\color{mycolor}\rule{\hintscolumnwidth}{0.95ex}}}%
  \hspace{\separatorcolumnwidth}%
  \parbox[t]{\maincolumnwidth}{\strut\sectionstyle{#1}}%
  \par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother

此解决方法适用于样式casual和,classic但不适用于banking。我仅将使用的颜色从更改\color{color1}\color{mycolor}并设置mycolorwhite。您可以在文件中找到宏部分的原始定义moderncvstyleclassic.sty

您检查过样式了吗banking?此样式不使用彩色框。

更新至 class moderncv,版本 2.0.0(当前版本):

对于当前版本 2.0.0 的类moderncv,其样式定义casual已更改为:

\RenewDocumentCommand{\section}{sm}{%
  \par\addvspace{2.5ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{section}{#2}%
  \cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{color1}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}%
  \par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading

因此我们需要使用命令\RenewDocumentCommand重新定义\color{color1}\color{white}。请注意,带有命令的补丁\patchcmd不工作,用 定义的命令\RenewDocumentCommand不可修补!

我们需要在序言中添加以下代码(因为代码使用了),所以是必需\makeatletter的:\makeatother@

\makeatletter
\RenewDocumentCommand{\section}{sm}{%
  \par\addvspace{2.5ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{section}{#2}%
  \cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{white}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}%
  \par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother

附完整代码

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

\moderncvstyle{casual} % casual, classic, banking, oldstyle and fancy  % head 2, body 1, foot 1
\moderncvcolor{black} 

\usepackage[utf8]{inputenc}

\usepackage[scale=0.75]{geometry}

\makeatletter
\RenewDocumentCommand{\section}{sm}{%
  \par\addvspace{2.5ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{section}{#2}%
  \cvitem[0ex]{\strut\raggedleft\raisebox{\baseletterheight}{\color{white}\rule{\hintscolumnwidth}{0.95ex}}}{\strut\sectionstyle{#2}}%
  \par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother

% 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}

\setlength{\footskip}{70pt}


\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{Master thesis}
\cvitem{title}{\emph{Title}}
\cvitem{supervisors}{Supervisors}
\cvitem{description}{Short thesis abstract}

\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}

\end{document}

你得到了你想要的结果:

生成的 pdf

答案2

添加

\usepackage{etoolbox}% http://ctan.org/pkg/etoolbox
\patchcmd{\section}% <cmd>
  {\strut}% <search>
  {\strut\renewcommand{\raisebox}[2]{}}% <replace>
  {}{}% <success><failure>

文档前言部分将通过使\raisebox命令等同于无操作来完全删除框,从而吞噬其两个参数。 的重新定义\raisebox是局部的,因为它是在 内部执行的\parbox

下面的输出是使用casual模板获得的(template.tex)使用black样式并使用图像example-image-16x10(来自mwe包裹) 为了\photo

在此处输入图片描述

相关内容