為 Moderncv 建立一個非常自訂的目錄

為 Moderncv 建立一個非常自訂的目錄

我的大學有一個求職平台,只允許上傳一份履歷。但是,我想上傳幾個課程,每個課程都用不同的語言(我住在歐洲,我說三種語言,每種語言都有不同的課程約定),所以我想出了一個大檔案(實際上是一個主文件,其中包含docmute以及三個可以獨立編譯的文件),其中嵌入了三個課程,以及\part提供 ToC 條目生成的不可見命令。
我見過這個答案並試圖搞亂titletoc,獲得一種經典的 LaTeX ToC,在部分標題上有超鏈接,但在頁碼上沒有。
但我更喜歡像這樣的目錄

\section{Contents}
\cvitem{Page}{Language}
\cvitem{2}{Afrikaans}
\cvitem{3}{Zulu}

(顯然有一些格式,但暫時保留)和兩個都文字和頁碼超連結。

到目前為止我的程式碼是(或多或少最小的WE):

\documentclass[a4paper,11pt,sans]{moderncv}
\usepackage{etoolbox}
\name{John}{Doe}
\title{Bank magician}
\moderncvstyle{classic}
\moderncvcolor{blue}

% For issuing \makecvtitle more than once
\patchcmd{\makecvtitle}{\newlength{\makecvtitledetailswidth}}{\let\makecvtitledetailswidth\relax\newlength{\makecvtitledetailswidth}}{}{}
\patchcmd{\makecvtitle}{\newlength{\makecvtitlepicturewidth}}{\let\makecvtitlepicturewidth\relax\newlength{\makecvtitlepicturewidth}}{}{}

\newcommand{\part}[1]{%
\clearpage%
\phantomsection%
\addcontentsline{toc}{part}{#1}%
}

\makeatletter % Table of Contents definition from Gonzalo Medina's answer
\newcommand\@pnumwidth{1.55em}
\newcommand\@tocrmarg{2.55em}
\newcommand\@dotsep{8}
\newcommand\contentsname{Contents}
\setlength\columnsep{20pt}
\setcounter{tocdepth}{0}
\newcommand\tableofcontents{%
  \addtocontents{toc}{\protect\setcounter{tocdepth}{0}}
  \newbox{\makecvtitlenamebox}
  \savebox{\makecvtitlenamebox}{%
    \namestyle{\@firstname\ \@lastname}%
  }
      \usebox{\makecvtitlenamebox}%
      \par\nobreak % don't break a page here
      \kern\the\prevdepth % don't take into account the depth of the preceding line
      \kern 4pt % space before the rule
  {   \color{gray!50}\hrule height 0.4ex width \textwidth } %1.05\wd\makecvtitlenamebox} % the rule
      \kern 0.75em % space after the rule
      \nointerlineskip % no additional space after the rule\hrule height 1ex width \wd\makecvtitlenamebox %
      \ifthenelse{\equal{\@title}{}}{}{\titlestyle{\@title}}%
  \vspace*{2\baselineskip}
  \section*{\contentsname}
  %\addtocontents{toc}{\protect\setcounter{tocdepth}{2}}
  \@starttoc{toc}%
  \clearpage
}

\usepackage{titletoc}
\titlecontents*{section}[0pt]
  {}{}{\textbullet}
  {\ \thecontentspage}[\\][]
\titlecontents{part}[0pt]
  {}{}{\hspace*{5em}\Large}
  {\leaders\hbox{\normalfont$\m@th\mkern \@dotsep mu\hbox{.}\mkern \@dotsep mu$}\hfill\Large\thecontentspage\hspace*{2em}}[]
\renewcommand\l@subsection[2]{}
\makeatother

\begin{document}
\tableofcontents
\part{Language 1}
\makecvtitle
\section{Section 1}
Some text
\part{Language 2}
\makecvtitle
\section{Section 1}
Some text
\end{document}

答案1

我找到

\newcommand\l@part[2]{\cvitem{\tocpagefont #2}{\tocentryfont #1}}
\newcommand\l@section[2]{}
\newcommand\l@subsection[2]{}

使用合適的格式化命令\tocpagefont\tocentryfont完成工作,無需加載titletoc.
下次我應該讀得更好book.cls:-)

對於標題和編號的超鏈接,只需傳遞linktoc=allmoderncv:它將傳遞到hyperref

相關內容