
TOC에 장 번호를 표시하려고 합니다. 현재 코드는 다음과 같습니다.
\documentclass{report}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{titletoc}
\definecolor{tbl}{HTML}{F035A3}
\contentsmargin{0cm}
\makeatletter
\titlecontents{chapter}[3.7pc]
{%
\addvspace{30pt}%
\begin{tikzpicture}[remember picture, overlay]%
\draw[fill=tbl,draw=tbl] (-7,-.1) rectangle (-0.7,.5);%
\pgftext[left,x=-3.6cm,y=0.2cm]{\color{white}\Large\sc\bfseries Lecture\ \thecontentslabel};%
\end{tikzpicture}%
\color{tbl}\large\sc\bfseries%
}%
{}
{}
{\;\titlerule\;\large\sc\bfseries Page \thecontentspage
\begin{tikzpicture}[remember picture, overlay]
\draw[fill=tbl,draw=tbl] (2pt,0) rectangle (4,0.1pt);
\end{tikzpicture}}%
\titlecontents{section}[3.7pc]
{\addvspace{2pt}}
{\contentslabel[\thecontentslabel]{2pc}}
{}
{\hfill\small \thecontentspage}
[]
\titlecontents*{subsection}[3.7pc]
{\addvspace{-1pt}\small}
{}
{}
{\ --- \small\thecontentspage}
[ \textbullet\ ][]
\makeatother
\makeatletter
\renewcommand{\tableofcontents}{%
\chapter*{%
\vspace*{-20\p@}%
\begin{tikzpicture}[remember picture, overlay]%
\pgftext[right,x=15cm,y=0.2cm]{\color{tbl}\Huge\sc\bfseries \contentsname};%
\draw[fill=tbl,draw=tbl] (13,-.75) rectangle (20,1);%
\clip (13,-.75) rectangle (20,1);
\pgftext[right,x=15cm,y=0.2cm]{\color{white}\Huge\sc\bfseries \contentsname};%
\end{tikzpicture}}%
\@starttoc{toc}}
\makeatother
\newcommand\lecture[2]{%
\setcounter{chapter}{#1}
\section*{Lecture #1: #2}
\addcontentsline{toc}{chapter}{#2}
}
\begin{document}
\tableofcontents
\lecture{5}{Hi}
\lecture{1}{Hi}
\lecture{9}{Hi}
\lecture{10}{Hi}
\lecture{2}{Hi}
\end{document}
그러면 다음 PDF가 생성됩니다.
왼쪽 옆에 장 번호를 표시하려면 어떻게 해야 합니까?강의텍스트? , 을 추가해 보았습니다 \arabic{chapter}
. \thechapter
나는 카운터와 변수를 생성하고 그것을강의문자가 왔지만 여전히 작동하지 않습니다. 어떻게 해야 하나요?
답변1
내 답변을 찾았습니다(chatgpt를 통해). 방금 다음 줄을 변경해야했습니다.
\pgftext[left,x=-3.6cm,y=0.2cm]{\color{white}\Large\sc\bfseries Lecture\ \thecontentslabel};%
에게
\pgftext[left,x=-3.7cm,y=0.2cm]{\color{white}\Large\sc\bfseries Lecture~\thecontentslabel\\*\hspace*{.7em}\ \thecontentslabel};