Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Using moderncv, I want to print the section number before the section name. Does anyone know how to do it?

share|improve this question
    
Welcome to TeX.sx! Please add a minimal working example (MWE) that shows what you have done so far. –  lockstep Dec 25 '12 at 22:52

1 Answer 1

up vote 6 down vote accepted

The moderncv class has no provision for numbering sections; it uses a modified \section command, so no counter and so on.

You can still modify the \section command to produce a number, by adding code such as this in the preamble:

\usepackage{etoolbox}
\newcounter{secnumber}
\newcommand{\numbersec}{\refstepcounter{secnumber}\thesecnumber~}
\patchcmd{\section}{\sectionstyle{#1}}{\sectionstyle{\numbersec #1}}{}{}

The \section command is patched to produce a number before the section title.

Complete example

This is taken from the template provided by moderncv

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

\moderncvstyle{casual}
\moderncvcolor{blue}
\usepackage[scale=0.75,footskip=40pt]{geometry}

\usepackage{etoolbox}
\newcounter{secnumber}
\newcommand{\numbersec}{\refstepcounter{secnumber}\thesecnumber~}
\patchcmd{\section}{\sectionstyle{#1}}{\sectionstyle{\numbersec #1}}{}{}

% personal data
\firstname{John}
\familyname{Doe}
\title{Resum\'e title}
\address{street and number}{postcode city}
\mobile{+1~(234)~567~890}
\phone{+2~(345)~678~901}
\fax{+3~(456)~789~012}
\email{john@doe.org}
\homepage{www.johndoe.com}
\extrainfo{additional information}
%\photo[64pt][0.4pt]{picture}
\quote{Some quote}

\begin{document}
\makecvtitle

\section{Education}
\cventry{year--year}{Degree}{Institution}{City}{\textit{Grade}}{Description}
\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}

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

\section{Computer skills}
\cvdoubleitem{category 1}{XXX, YYY, ZZZ}{category 4}{XXX, YYY, ZZZ}
\cvdoubleitem{category 2}{XXX, YYY, ZZZ}{category 5}{XXX, YYY, ZZZ}
\cvdoubleitem{category 3}{XXX, YYY, ZZZ}{category 6}{XXX, YYY, ZZZ}

\section{Interests}
\cvitem{hobby 1}{Description}
\cvitem{hobby 2}{Description}
\cvitem{hobby 3}{Description}

\end{document}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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