I'm writing an article and would like to section it with the same style of modernCV, but cannot find any suggestion.
1 Answer
I found this in the sources of moderncv
\strut\raggedleft\raisebox{\baseletterheight}{\color{color1}\rule{\hintscolumnwidth}{0.95ex}}
it creates the box. The full definition for the section is
\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
You just have to replace the cvitem and all the variables.
Edit(This includes all the necessary lengths, you have to insert the color yourself):
\usepackage{xparse}
\makeatletter
\newlength{\hintscolumnwidth} \setlength{\hintscolumnwidth}{0.175\textwidth}
\newlength{\baseletterheight} \settoheight{\baseletterheight}{o}
\newlength{\separatorcolumnwidth} \setlength{\separatorcolumnwidth}{0.025\textwidth}
% fonts
\newcommand*{\sectionfont}{\Large\mdseries\upshape}
% styles
\newcommand*{\sectionstyle}[1]{{\sectionfont{#1}}}
\RenewDocumentCommand{\section}{sm}{%
\par\addvspace{2.5ex}%
\addcontentsline{toc}{section}{#2}%
{\strut\raggedleft\raisebox{\baseletterheight}{\rule{\hintscolumnwidth}{0.95ex}}}\hspace*{\separatorcolumnwidth}{\strut\sectionstyle{#2}}%
\par\nobreak\addvspace{1ex}\@afterheading}% to avoid a pagebreak after the heading
\makeatother
-
I am quite new to latex, so I have to ask you further help if possible. I should copy the text (\RenewDocumentCommand...etc) before \begin{document}. Which variables have I to change and how? Instead of "\cvitem" what should I insert? Sorry for my inexpert questions :) Apr 27, 2016 at 11:12
-
You have to use \usepackage{xparse} and insert the command. You then should remove \cvitem[0ex] and replace the values of \baseletterheight, \hintscolumnwidth, color1, \sectionstyle by whatever they are set to in the original source. And then you have to fiddle around a bit until it's exactly the way you want it. Apr 27, 2016 at 11:27
\rule
titlesec
can do that.