Using moderncv
, I want to print the section number before the section name. Does anyone know how to do it?
[Tex/LaTex] Print section number with moderncv
moderncvnumberingsectioning
Related Solutions
Since you are using babel
with the english
option, , you need to add this
\addto\captionsenglish{\renewcommand\refname{Publications}}
to the preamble of your document. A complete example (I changed some settings to make the example compilable for everyone, but this is not relevant):
\begin{filecontents}{xxyy.bib}
\@misc{A,
author="Author",
year="2024"
}
\end{filecontents}
\documentclass[10pt,letter]{moderncv}
\moderncvtheme[black]{classic}
\usepackage[english]{babel}
\firstname{John}
\familyname{Doe}
\addto\captionsenglish{\renewcommand\refname{Publications}}
\begin{document}
\maketitle
\nocite{*}
\bibliographystyle{plain}
\bibliography{xxyy}
\end{document}
The relevant part of code in moderncv
to create the shown footer is:
\renewcommand*{\makeletterfooter}{%
\setlength{\footerwidth}{0.8\textwidth}%
\fancypagestyle{plain}{%
\fancyfoot[c]{%
\parbox[b]{\footerwidth}{%
\centering%
\addressfont\color{color2}%
\vspace{\baselineskip}% forces a white line to ensure space between main text and footer (as footer height can't be known in advance)
\vspace{-\baselineskip}% to cancel out the extra vertical space taken by the name (below) and ensure perfect alignment of letter and cv footers
\strut{\bfseries\upshape\@firstname~\@lastname}\\% the \strut is required to ensure the line is exactly \baselineskip tall
\ifthenelse{\isundefined{\@addressstreet}}{}{\addtofooter[]{\addresssymbol\@addressstreet}%
\ifthenelse{\equal{\@addresscity}{}}{}{\addtofooter[~--~]{\@addresscity}}% if \addresstreet is defined, \addresscity and addresscountry will always be defined but could be empty
\ifthenelse{\equal{\@addresscountry}{}}{}{\addtofooter[~--~]{\@addresscountry}}%
\flushfooter\@firstfooterelementtrue\\}%
\collectionloop{phones}{% the key holds the phone type (=symbol command prefix), the item holds the number
\addtofooter{\csname\collectionloopkey phonesymbol\endcsname\collectionloopitem}}%
\ifthenelse{\isundefined{\@email}}{}{\addtofooter{\emailsymbol\emaillink{\@email}}}%
\ifthenelse{\isundefined{\@homepage}}{}{\addtofooter{\homepagesymbol\httplink{\@homepage}}}%
\collectionloop{socials}{% the key holds the social type (=symbol command prefix), the item holds the link
\addtofooter{\csname\collectionloopkey socialsymbol\endcsname\collectionloopitem}}%
\ifthenelse{\isundefined{\@extrainfo}}{}{\addtofooter{\@extrainfo}}%
\ifthenelse{\lengthtest{\footerboxwidth=0pt}}{}{\flushfooter}% the lengthtest is required to avoid flushing an empty footer, which could cause a blank line due to the \\ after the address, if no other personal info is used
}}}%
\pagestyle{plain}}
As you can see the footer is part of the usage of package fancyhdr
, defined as a centered footer \fancyfoot[c]{...}
. \parbox[b]
creates a box, centered \centering
, with the needed informations for lastname, firstname etc.
So you can create an own footer simplified with:
\fancyfoot[c]{%
\parbox[b]{0.8\textwidth}{%
\centering%
\vspace{\baselineskip}% forces a white line to ensure space between main text and footer (as footer height can't be known in advance)
\vspace{-\baselineskip}% to cancel out the extra vertical space taken by the name (below) and ensure perfect alignment of letter and cv footers
\strut{\bfseries\upshape firstname~lastname}\\% the \strut is required to ensure the line is exactly \baselineskip tall
street number~city\\
phone~email~etc.
}%end parbox
}%end fancyfoot
Change firstname etc. to your datas.
This should give you a starting point to do it by your own ...
Best Answer
Original answer
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:The
\section
command is patched to produce a number before the section title.Complete example
This is taken from the template provided by
moderncv
Update
With the most recent version of
moderncv
the above solution won't work.The code in the top snippet should be substituted with
Complete example