2

I want to get rid of the colored boxes that appear when starting a new section in moderncv. I found this question here but none of the presented solutions achieved what I wanted.

See the MWE below for the solutions in one document for testing.

Solution 1 worked fine at doing what it is meant to do, setting the color of the bar to white. But it is still present and consumes space, while I would prefer a formatting pretty similar to the "standard"-section with the sectionname flushed left (but no number as this does not make any sense in a cv).

Solution 2 gives the error

File `moderncvcolorwhite.sty' not found. ^^M

Also this solution would also just set the color to white.

And Solution 3 does not give an error but also does not have any (visible) effect.

I found on this site (sadly in german) the definition of the sections in moderncv.cls (Careful, I am not sure how trustworthy this is!). My attempts to simply remove the box produced lots of errors.

Can anyone help?

MWE

\documentclass[12pt,a4paper]{moderncv}
\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[left=2.4cm, right=1.0cm, top=1.7cm, bottom=2.0cm]{geometry}
\usepackage{comment}
\moderncvtheme[black]{classic}

%===============================================
%Solution 1
\begin{comment}
\definecolor{white}{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{white}\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
\end{comment}

%====================================================
%Solution 2
%\begin{comment}
\AtBeginDocument{%
\definecolor{white}{rgb}{1,1,1}
}
\moderncvcolor{white}
%\end{comment}

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


%=======================================
%Snippet from moderncv.cls
\begin{comment}
\newcommand*{\section}[1]{%
    \vspace*{2.5ex \@plus 1ex \@minus .2ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{part}{#1}%
  \parbox[m]{\hintscolumnwidth}{\raggedleft\hintfont{\color{sectionrectanglecolor}\rule{\hintscolumnwidth}{1ex}}}%
  \hspace{\separatorcolumnwidth}%
  \parbox[m]{\maincolumnwidth}{\sectionstyle{#1}}\\[1ex]}
\end{comment}
%====================================

\firstname{Homer Jay}
\familyname{Simpson}
\title{Curriculum Vitae}
\address{742 Evergreen Terrace}{Springfield}
\mobile{1234/56789}
\email{homerjaysimpson@groening.com}
\begin{document}
  \makecvtitle

\section{Personal Data}
  \cvitem{Family status}{married}
  \cvitem{Nationality}{US-American}
  \cvitem{Date of birth}{1956-05-12}
  \cvitem{Place of birth}{Springfield}

\section{Education}
  \cventry{1960 -- 1970}{Elementary School}{}{}{}{}


  \vfill
  Homer Jay Simpson\\
  Springfield, \today
\end{document}
  • 1
    What about this post ? – Jérôme Dequeker Jul 29 '16 at 12:19
  • Oh I haven´t found that post, this is what I am looking for. Thank you. But there is one issue that disturbs me a bit: When starting a new section, the spacing is different from the default one; now it looks a bit scrambled. Do you have an idea for that? – Enno Jul 29 '16 at 12:38
  • You want to add space between section ? : \RenewDocumentCommand{\section}{sm}{% \vspace{1cm}\strut\sectionstyle{#2\hfill}% \par\nobreak\addvspace{1ex}\@afterheading } where you can change the value of the argument of the \vspace command. – Jérôme Dequeker Jul 29 '16 at 13:18
  • Hmm this gives me the error You can't use "\spacefactor" in vertical mode \section{Personal Data} – Enno Jul 29 '16 at 13:42
1

Well, the problem here is that moderncv is designed to have a first and a second column (see red line in the following resulting pdf).

What you want to do is to break the good design completely. I would not recommend this.

For a workaround you can define the following new command \mysection:

\newcommand*{\mysection}[1]{%
  \vspace{2.5ex}% \@plus 1ex \@minus .2ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{part}{#1}%
  % ... deleted
  \parbox[m]{\textwidth}{\sectionstyle{#1}}\\[1ex]}

Please notice the changes in line two and the last line, also see that I deeted some lines.

With the following complete MWE

\documentclass[12pt,a4paper]{moderncv}

\usepackage[ngerman]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[%
  left=2.4cm, right=1.0cm, top=1.7cm, bottom=2.0cm,
  showframe
]{geometry}

\moderncvtheme[black]{classic} % banking classic casual

%===============================================
%Solution 1
\definecolor{white}{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{white}\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

\newcommand*{\mysection}[1]{%
  \vspace{2.5ex}% \@plus 1ex \@minus .2ex}%
  \phantomsection{}% reset the anchor for hyperrefs
  \addcontentsline{toc}{part}{#1}%
  \parbox[m]{\textwidth}{\sectionstyle{#1}}\\[1ex]}


\firstname{Homer Jay}
\familyname{Simpson}
\title{Curriculum Vitae}
\address{742 Evergreen Terrace}{Springfield}
\mobile{1234/56789}
\email{homerjaysimpson@groening.com}


\begin{document}
\makecvtitle

\section{Personal Data}
\cvitem{Family status}{married}
\cvitem{Nationality}{US-American}
\cvitem{Date of birth}{1956-05-12}
\cvitem{Place of birth}{Springfield}

\section{Education}
\cventry{1960 -- 1970}{Elementary School}{}{}{}{}

\vspace{2.5ex}
\mysection{Personal Data to test a longer line to see what happens if the line breaks into two lines}
\cvitem{Family status}{married}
\cvitem{Nationality}{US-American}
\cvitem{Date of birth}{1956-05-12}
\cvitem{Place of birth}{Springfield}

\mysection{Education}
\cventry{1960 -- 1970}{Elementary School}{}{}{}{}

\vfill
Homer Jay Simpson\\
Springfield, \today
\end{document} 

you can see the resulting typing area (option showframe) in the resulting pdf:

resulting pdf

That does not look pretty and I suggest to use another class or use article with own designs ...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.