moderncv를 위한 맞춤형 ToC 만들기

moderncv를 위한 맞춤형 ToC 만들기

우리 대학에는 이력서를 하나만 업로드할 수 있는 구직 플랫폼이 있습니다. 하지만 각각 다른 언어로 된 여러 커리큘럼을 업로드하고 싶기 때문에(저는 유럽에 거주하며 세 가지 언어를 사용하며 각 언어는 커리큘럼에 대한 서로 다른 규칙이 있습니다) 큰 파일(실제로 다음이 포함된 마스터 파일)을 생각해냈습니다. ToC 항목 생성을 제공하는 docmute보이지 않는 명령이 포함된 3개의 커리큘럼이 포함된 독립 실행형으로 컴파일할 수 있는 3개의 파일).\part
나는 보았다이 답변titletoc그리고 부분 제목에는 하이퍼링크가 있지만 페이지 번호에는 하이퍼링크가 없는 일종의 고전적인 LaTeX ToC를 얻으려고 했습니다 .
하지만 나는 다음과 같은 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=all에 전달하면 moderncv에 전달됩니다 hyperref.

관련 정보