
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};