2

I searched in the code and in the forums, but I can't seem to find how to pull such a trick. Help me, please.

And, in advance, thank you !

1
  • Are you referring to the blocks next to "Education", "Master thesis" and "Experience" in this orange example?
    – Werner
    Apr 30, 2014 at 23:45

1 Answer 1

3

The rules used by moderncv to the left of the section titles are nothing else but simple colored \rules inside a \parbox, so you can imitate them quite easily, using for example (the \parbox in the original definition can be omitted and if no additional space to the right is required \hspace{\separatorcolumnwidth} can also be omitted):

\newlength\hintscolumnwidth
\newlength\separatorcolumnwidth
\setlength\hintscolumnwidth{3cm}
\setlength\separatorcolumnwidth{10pt}

\newcommand\MCVrule{%
  {\color{color1}\rule{\hintscolumnwidth}{5pt}%
  \hspace{\separatorcolumnwidth}}%
}

If you want to incorporate this to a document (not using moderncv.cls) to decorate the section titles, the above definition can be used with the help of the titlesec package to produce something like

\documentclass{article}
\usepackage{xcolor}
\usepackage{titlesec}

\definecolor{color1}{rgb}{0.22,0.45,0.70}% light blue

\newlength\hintscolumnwidth
\newlength\separatorcolumnwidth
\setlength\hintscolumnwidth{3cm}
\setlength\separatorcolumnwidth{10pt}

\newcommand\MCVrule{%
  {\color{color1}\rule{\hintscolumnwidth}{5pt}%
  \hspace{\separatorcolumnwidth}}%
}

\titleformat{\section}
  {\normalfont\Large\bfseries}
  {\llap{\MCVrule}\thesection}
  {1em}
  {}
\titleformat{name=\section,numberless}
  {\normalfont\Large\bfseries}
  {\llap{\MCVrule}}
  {0em}
  {}

\begin{document}

\section{A test numbered section}
Some test text test text test text test text test text test text test text test text test text test text test text test text test text
\section*{A test unnumbered section}
Some test text test text test text test text test text test text test text test text test text test text test text test text test text 

A single rule \MCVrule

\end{document}

enter image description here

1
  • Thank you very much ! I'm new to teX and this is a bit confusing. But you were of great help !
    – kino
    May 1, 2014 at 13:45

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .