1

I am using this academic CV template from Overleaf: https://www.overleaf.com/latex/examples/academic-cv-template/hvjpfjnyggbf. Please, consider that template as the MWE.

I want to modify the \cvsection and \cvsubsection commands so that they act like the standard \section and \subsection commands in LaTeX.

This means that they should have numbers, be included in the table of contents, but keeping the same formatting as in the template.

How can I do this?

The \cvsection and \cvsubsection are defined as follows:

\newcommand{\cvsection}[1]{%
  \vspace{\acvSectionTopSkip}
  \sectionstyle{#1} 
  \phantomsection
  \color{gray}\vhrulefill{0.9pt}
}

\newcommand{\cvsubsection}[1]{%
  \vspace{\acvSectionContentTopSkip}
  \vspace{-3mm}
  \subsectionstyle{#1}
  \phantomsection
}
2
  • Is your goal to actually have a numbered CV with a table of contents, or do you just like the format of these sections and want to use them in a regular document?
    – Alan Munn
    Jun 30, 2023 at 19:42
  • You are right, @AlanMunn. My aim is to have an indexed CV so it is easy to access to each of the sections of the CV. I don't actually care the solution... change the format of the sections.... or make the cvsection behave like a section. I just need the cvsection forma to be indexed as a section.
    – scd
    Jul 3, 2023 at 8:33

1 Answer 1

3

The academic-cv class defines its own sectioning commands, so you are right that these are what need to be changed. So the following additions need to be made to the class:

First, we make some counters for the sections:

\newcounter{cvsection}
\newcounter{cvsubsection}[cvsection]
\renewcommand\thecvsubsection{\thecvsection.\arabic{cvsubsection}}

Next we redefine the sectioning commands to write to the TOC. Notice that although the commands are called \cvsection and \cvsubsection when we write to the TOC, we use section and subsection since these correspond to levels of the TOC format, not actual command names.

\newcommand{\cvsection}[1]{%
  \vspace{\acvSectionTopSkip}
  \refstepcounter{cvsection}
  \addcontentsline{toc}{section}{\thecvsection.\quad#1}
  \sectionstyle{\thecvsection.\quad#1} 
  \phantomsection
  \color{gray}\vhrulefill{0.9pt}
}

\newcommand{\cvsubsection}[1]{%
  \vspace{\acvSectionContentTopSkip}
  \vspace{-3mm}
  \refstepcounter{cvsubsection}
  \addcontentsline{toc}{subsection}{\normalfont\thecvsubsection.~#1}
  \subsectionstyle{\thecvsubsection.\quad #1}
  \phantomsection
}

Finally we use the tocloft package to adjust the TOC format as needed.

\RequirePackage{tocloft}
\setlength{\cftbeforesecskip}{0pt}
\setlength{\cftsubsecindent}{2em}

Now in the main document, we can simply add \tableofcontents and we get the following output. Obviously you may want to issue a \clearpage command after the TOC. Any further formatting of the TOC can be done using tocloft as needed.

first page of outpu

1
  • Thanks a lot! It works!
    – scd
    Jul 5, 2023 at 13:09

You must log in to answer this question.

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