나는 사용자 정의를 만들기 위해 tocloft
및 를 사용하고 있습니다 . 아래에서 내 MWE를 찾으세요.tikz
table of contents
\documentclass{book}
\usepackage{tocloft,refcount}
\usepackage[colorlinks,linkcolor=black]{hyperref}
\usepackage{tikz,lipsum}
\usetikzlibrary{calc}
\definecolor{rulecolor}{cmyk}{0,1,0.29,0}
\newcommand{\tocchpnumfont}{\fontsize{15}{18}\selectfont\color{chapternumcolor}}
\newcommand{\tocchptextfont}{\fontsize{11}{14}\selectfont\color{white}}
\definecolor{chapternumcolor}{cmyk}{0.40,1,0,0}
\makeatletter
% redefinitions for part entries
\renewcommand\cftpartfont{\Huge\sffamily\bfseries}
\renewcommand*{\l@part}[2]{%
\ifnum \c@tocdepth >-2\relax
\cftpartbreak
\begingroup
{\interlinepenalty\@M
\leavevmode
\settowidth{\@tempdima}{\cftpartfont\cftpartname}%
\addtolength{\@tempdima}{\cftpartnumwidth}%
\let\@cftbsnum \cftpartpresnum
\let\@cftasnum \cftpartaftersnum
\let\@cftasnumb \cftpartaftersnumb
\advance\memRTLleftskip\@tempdima \null\nobreak\hskip -\memRTLleftskip
}
\nobreak
\global\@nobreaktrue
\everypar{\global\@nobreakfalse\everypar{}}%
\endgroup
\fi}
\newcommand\chapternumberline[1] {\mbox{\Large\@chapapp~#1}\par\noindent}
\cftsetindents{chapter}{0pt}{0pt}
\newcommand\cftchapterpagefont{\tocchpnumfont}
\newcommand*{\l@mychap}[3]{%
\def\@chapapp{#3}\vskip1ex%
\par\noindent\begin{minipage}{\textwidth}%
\parbox{4.7em}{%
\hfill{\cftchapterpagefont #2}%
}\hspace*{1.5em}%
\parbox{\dimexpr\textwidth-4.7em-15pt\relax}{%
\tocchptextfont #1%
}%
\end{minipage}\par\vspace{2ex}%
}
\renewcommand*{\l@chapter}[2]{%
\l@mychap{#1}{#2}{}%
}
\newcommand*{\l@appendix}[2]{%
\l@mychap{#1}{#2}{\appendixname}%
}
\newcommand\cftsectionfont{\sffamily}
\newcommand\cftsectionpagefont{\hfill\color{myred}}
\newcommand{\cftsectionleader}{\nobreak}
\newcommand{\cftsectionafterpnum}{\cftparfillskip}
\cftsetindents{section}{9.5em}{2.5em}
\newcommand\cftsectionformatpnum[1]{%
\hskip1em\hbox to 4em{{\cftsectionpagefont #1\hfill}}}
\newcommand\cftsubsectionfont{\sffamily}
\newcommand\cftsubsectionpagefont{\hfill\color{myred}}
\newcommand\cftsubsectionleader{\nobreak}
\newcommand{\cftsubsectionafterpnum}{\cftparfillskip}
\newcommand\cftsubsectiondotsep{\cftnodots}
\cftsetindents{subsection}{10.5em}{3em}
\newcommand\cftsubsectionformatpnum[1]{%
\hskip1em\hbox to 4em{{\cftsubsectionpagefont #1\hfill}}}
\makeatother
\newlength\Myhead
\setlength\Myhead{\dimexpr\headheight+\headsep+1in+\voffset+5ex\relax}
\newlength\Myfoot
\setlength\Myfoot{\dimexpr\paperheight-\Myhead-\textheight-\footskip+5ex\relax}
\newcounter{chapmark}
\newcommand\StartMark{%
\addtocontents{toc}{\protect\label{st\thechapmark}%
\protect\begin{tikzpicture}[overlay,remember picture,baseline]
\protect\node [anchor=base] (s\thechapmark) {};%
\ifnum\getpagerefnumber{st\thechapmark}=\getpagerefnumber{en\thechapmark} \else
\protect\draw[myyellow,line width=3pt] let \protect\p3= (s\thechapmark),%
\protect\p4 = (current page.south) in %
($ (4em,\protect\y3) + (0,-1ex) $) -- ($ (4em,\protect\y4) + (0, \protect\the\Myfoot)$);\fi
\protect\end{tikzpicture}\par}%
}
\newcommand\EndMark{
\addtocontents{toc}{\protect\label{en\thechapmark}%
\protect\begin{tikzpicture}[overlay,remember picture,baseline]
\protect\node [anchor=base] (e\thechapmark) {};
\ifnum\getpagerefnumber{st\thechapmark}=\getpagerefnumber{en\thechapmark}
\protect\draw[myyellow,line width=1pt] let \protect\p1= (s\thechapmark), \protect\p2=(e\thechapmark) in ($ (4em,\protect\y1) + (0,-1ex) $) -- ($ (4em,\protect\y2) + (0,2ex) $);
\else%
\protect\draw[myyellow,line width=1pt] let \protect\p1= (e\thechapmark), \protect\p2=(current page.north) in ($(4em,\protect\y2) + (0,-\protect\the\Myhead)$) -- ($ (4em,\protect\y1) + (0,1.5ex) $);
\fi
\protect\end{tikzpicture}}\stepcounter{chapmark}%
}
\renewcommand{\cftdot}{}
\begin{document}
\contentsline {chapter}{\chapternumberline {}Negative numbers}{8} {chapter.1}
\StartMark
\label {st0}\begin {tikzpicture}[overlay,remember picture,baseline] \node [anchor=base] (s0) {};\end {tikzpicture}\par
\contentsline {section}{\numberline {8A}Integers}{00}{section.1.1}
\contentsline {section}{\numberline {8B}Adding and subtracting positive integers }{00}{section.1.2}
\contentsline {section}{\numberline {8C}Adding and subtracting negative integers}{00}{section1.3}
\contentsline {section}{\numberline {8D}Multiplication and division of integers}{00}{section.1.3}
\contentsline {section}{\numberline {8E}Order of operation}{00} {section*.2}
\contentsline {section}{\numberline {8F}Substituting integers}{00} {section*.3}
\contentsline {section}{\numberline {8G}The number plane}{00} {section.1.4}
\contentsline {section}{Investigation}{00}{section.1.5}
\contentsline {section}{Review: Chapter summary}{00}{section.1.6}
\contentsline {subsection}{Multiple-choice questions}{00}{subsection.1.6}
\contentsline {subsection}{Short-answer questions}{00}{subsection.1.6}
\contentsline {subsection}{Extended response questions}{00} {subsection.1.6}
\label {en0}\begin {tikzpicture}[overlay,remember picture,baseline] \node [anchor=base] (e0) {}; \draw [rulecolor,line width=1pt] let \p 1= (s0), \p 2=(e0) in ($ (7em,\y 1) + (0,1ex) $) -- ($ (7em,\y 2) + (0,2.24ex) $); \end {tikzpicture}
\EndMark
\contentsline {section}{1 Counting}{}{}
\contentsline {section}{2 Numeration}{}{}
\contentsline {section}{3 fractions}{}{}
\contentsline {section}{7 Calculation}{}{}
\contentsline {section}{8 Number patterns}{}{}
\contentsline {section}{3 Place value}{}{}
\contentsline {section}{4 Addition and subtraction}{}{}
\end{document}
나는 출력이 다음과 같기를 기대하고 싶습니다 :
나는 사용했다두 열의 서로 다른 레이아웃의 목차패키지를 사용하려고 했지만 paracol
올바른 출력을 얻을 수 없습니다. 그래서 나는 로 이사했지만 tikz
여전히 예상되는 결과를 얻지 못했습니다.
답변1
작업은 다음과 같은 형식입니다. 입력(s 집합 \contentsline
)이 주어지고 이 입력을 읽고 원하는 출력을 생성하기 위한 매크로를 생성해야 합니다. 나는 전형적인 일반 TeX 솔루션을 보여줍니다. 코드가 간결하고 단순하다는 것을 알 수 있습니다. 오직 필요한 것은 TeX 기본 수준에서 \hbox
/ 산술을 아는 것입니다. \vbox
외부 패키지는 필요하지 않습니다(TeXgyre Heros Narrow 글꼴을 로드하는 데 하나의 외부 파일만 사용됩니다).
이 매크로를 LaTeX 코드에 삽입할 수 있지만 Helvetica 또는 Heros Narrow 글꼴을 로드하려면 첫 번째 줄을 LaTeX 명령으로 변경해야 합니다.
\input cs-heros \narrow % this is plain TEX specific, replace this if you needed
\def\dimA{80mm}
\def\dimB{7mm}
\def\dimC{12mm}
\def\dimD{10mm}
\def\dimE{.8pt}
\def\dimF{2mm}
\def\dimG{65mm}
\def\dimH{45mm}
\def\Magenta {\pdfliteral{0 .9 .1 .3 K 0 1 .2 .3 k}}
\def\Black {\pdfliteral{0 g 0 G}}
\def\White {\pdfliteral{1 g 1 G}}
\def\Blue {\pdfliteral{1 .3 0 .3 k}}
\def\LightBlue {\pdfliteral{.2 .16 0 .12 k}}
\def\contentsline #1{\csname TOC#1\endcsname}
\def\TOCchapter #1#2#3{%
\hbox to\dimA{\bf\llap{\Magenta#2\Black\kern\dimF}\rlap{\chaprule\hss}%
\kern\dimF\White #1\hss 00\Black\kern\dimB}
\nointerlineskip\baselineskip=0pt
\hbox{\kern\dimD \Magenta\vrule height1ex width\dimE}\nointerlineskip
}
\def\TOCsection #1#2#3{\hbox to\dimA{\kern\dimD\secrule #1\hss #2\kern\dimB}}
\def\TOCsubsection #1#2#3{\hbox to\dimA{\kern\dimD\secrule \kern\dimC #1\hss #2\kern\dimB}}
\def\TOCchapterA #1#2#3{\hbox to\dimA{\bf\rlap{\chaprule\hss}
\kern\dimF\Magenta #1\hss}\medskip}
\def\TOCsectionA #1#2#3{\hbox{\kern\dimF\tocstrut#1}\hrule width\dimH}
\def\secrule {\Magenta\vrule height2.1ex depth.6ex width\dimE\Black\kern2mm}
\def\chaprule{\Blue\vrule height2.3ex depth.7ex width\dimA\Black}
\def\tocstrut{\vrule height2.3ex depth.7ex width0pt}
\def\chapternumberline{}
\def\numberline#1{\hbox to0pt{\hss#1\kern4mm}}
\def\StartContents{\hbox\bgroup \offinterlineskip \vtop\bgroup}
\def\StartMark{}
\def\EndMark{\egroup\kern2mm\vtop\bgroup
\let\TOCchapter=\TOCchapterA \let\dimA=\dimG \let\TOCsection=\TOCsectionA
\let\Blue=\LightBlue}
\def\EndContents{\Black\egroup\egroup}
\StartContents
\contentsline {chapter}{\chapternumberline {}Negative numbers}{8} {chapter.1}
\StartMark
\contentsline {section}{\numberline {8A}Integers}{00}{section.1.1}
\contentsline {section}{\numberline {8B}Adding and subtracting positive integers }{00}{section.1
\contentsline {section}{\numberline {8C}Adding and subtracting negative integers}{00}{section1.3
\contentsline {section}{\numberline {8D}Multiplication and division of integers}{00}{section.1.3
\contentsline {section}{\numberline {8E}Order of operation}{00} {section*.2}
\contentsline {section}{\numberline {8F}Substituting integers}{00} {section*.3}
\contentsline {section}{\numberline {8G}The number plane}{00} {section.1.4}
\contentsline {section}{Investigation}{00}{section.1.5}
\contentsline {section}{Review: Chapter summary}{00}{section.1.6}
\contentsline {subsection}{Multiple-choice questions}{00}{subsection.1.6}
\contentsline {subsection}{Short-answer questions}{00}{subsection.1.6}
\contentsline {subsection}{Extended response questions}{00} {subsection.1.6}
\EndMark
\contentsline {chapter}{Statistic and Probability}{} {}
\contentsline {section}{1 Counting}{}{}
\contentsline {section}{2 Numeration}{}{}
\contentsline {section}{3 Fractions}{}{}
\contentsline {section}{7 Calculation}{}{}
\contentsline {section}{8 Number patterns}{}{}
\contentsline {section}{3 Place value}{}{}
\contentsline {section}{4 Addition and subtraction}{}{}
\EndContents
\end
결과: