
이 질문에 대한 답변을 기반으로 스타일이 지정된 목차를 만들려고 합니다.목차의 스타일과 색상을 변경하는 방법은 무엇입니까?
내가 가지고 있는 TeX는 다음과 같습니다.
\definecolor{secnum}{RGB}{241,129,39}
\definecolor{ptcbackground}{RGB}{247,247,247}
\definecolor{ptctitle}{RGB}{177,177,177}
\pretocmd{\tableofcontents}{\begin{mdframed}[backgroundcolor=ptcbackground,hidealllines=true]}{}{}
\apptocmd{\tableofcontents}{\end{mdframed}}{}{}
\patchcmd{\tableofcontents}{\begin{mdframed}[backgroundcolor=ptctitle,hidealllines=true]}{}{}
\titlecontents{section}
[3.3em]{\sffamily}
{\color{secnum}\contentslabel{2.3em}\normalcolor}{}
{\titlerule*[1000pc]{.}\contentspage\\\hspace*{-3em}\vspace*{-3pt}%
\color{white}\rule{\dimexpr\textwidth-20pt\relax}{0pt}}
\titlecontents{lsection}
[3.3em]{\sffamily}
{\color{secnum}\contentslabel{2.3em}\normalcolor}{}
{\titlerule*[1000pc]{.}\contentspage\\\hspace*{-5.8em}\vspace*{-3pt}%
\color{white}\rule{\dimexpr\textwidth-15.5pt\relax}{0pt}}
\titlecontents{lsubsection}
[5.8em]{\sffamily}
{\color{secnum}\contentslabel{2.3em}\normalcolor}{}
{\titlerule*[1000pc]{.}\contentspage\\\hspace*{-5.8em}\vspace*{-3pt}%
\color{white}\rule{\dimexpr\textwidth-15.5pt\relax}{0pt}}
\titlecontents{subsection}
[5.8em]{\sffamily}
{\color{secnum}\contentslabel{2.3em}\normalcolor}{}
{\titlerule*[1000pc]{.}\contentspage\\\hspace*{-5.8em}\vspace*{-3pt}%
\color{white}\rule{\dimexpr\textwidth-15.5pt\relax}{0pt}}
\makeatletter
\renewcommand*\l@chapter[2]{%
\ifnum \c@tocdepth >\m@ne
\addpenalty{-\@highpenalty}%
\vskip 0em \@plus\p@
\setlength\@tempdima{0em}%
\begingroup
\parindent \z@ \rightskip \@pnumwidth
\parfillskip -\@pnumwidth
\leavevmode
\advance\@tempdima
\hskip
\colorbox{ptctitle}{\strut%
\makebox[\dimexpr\textwidth\fboxsep100pt\relax][l]{%
\color{white}\bfseries\sffamily#1%
\nobreak\hfill\nobreak\hb@xt@\@pnumwidth{\hss #2}}}\par\smallskip
\penalty\@highpenalty
\endgroup
\fi}
\makeatother
\newcommand\PartialToC{%
\startcontents[chapters]%
\begin{mdframed}[backgroundcolor=ptcbackground,hidealllines=true]
\printcontents[chapters]{1}{1}{\colorbox{ptctitle}{%
\parbox[t][][t]{\dimexpr\textwidth-2\fboxsep\relax}{%
\strut\color{white}\bfseries\sffamily\makebox[.5em]{%
}\large Contents}}\vskip5pt}
\end{mdframed}%
}
문제는 아래 이미지에 표시된 것처럼 '콘텐츠' 막대의 배경이 배경과 같은 높이가 아니라는 것입니다.
이상적으로는 어두운 회색 직사각형이 밝은 배경의 높이와 너비와 일치하도록 하고 싶습니다. 나는 한동안 노력했지만 그것을 알아낼 수 없는 것 같습니다(솔직히 말해서 이전 답변에 제공된 코드를 완전히 이해하지 못합니다). 너무 사소한 것 같습니다. 어떤 도움이라도 주시면 감사하겠습니다.
건배.
답변1
그래서 당신은 게시한 적이 없습니다최소한의 작업 예, 하지만 문제가 꽤 간단해 보였기 때문에당신이 언급한 질문. 한 줄을 추가해야 합니다.
\mdfsetup{innerleftmargin=0pt,innerrightmargin=0pt}
그러면 TOC의 모든 상자에 적용됩니다. 문서를 읽는 것만으로 mdframed
도 이 문제가 해결될 것입니다. 명령 을 수행하기 전에 이를 추가하면 mdframed
다음이 생성됩니다.
내 생각에는 당신이 원하는 것입니다. 도움이 되길 바랍니다. 그러나 MWE 생성 과정을 읽어 보십시오. 당신은 아마도많이더욱 빠르고 정확한 답변을 드립니다.