我想要创建一个tufte-book
样式 ToC,与 Gonzalo Medina 在此请求中所做的事情非常相似:漂亮的目录
到目前为止我得到的是:
\documentclass[letterpaper]{article}
\usepackage{geometry}
\usepackage{xcolor}
\usepackage{amsmath}
\usepackage[some]{background}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{shadows}
\definecolor{col2}{HTML}{80B2FF}
\DeclareFixedFont{\bigsf}{T1}{phv}{b}{n}{1.5cm}
\backgroundsetup{
scale=1,
angle=0,
opacity=1,
contents={\begin{tikzpicture}[remember picture,overlay]
\path [fill=col2] (-0.5\paperwidth,5) rectangle (0.5\paperwidth,10);
\end{tikzpicture}}
}
\begin{document}
\begin{titlepage}
\BgThispage
\newgeometry{left=1cm,right=4cm}
\vspace*{2cm}
\noindent
\textcolor{white}{\bigsf Reader analyse} \begin{tikzpicture}[overlay]
\def\nodeshadowed[#1]#2;{\node[scale=6,above,#1]{#2};\node[scale=6,
above,#1,yscale=-1,scope fading=south,opacity=0.3]{#2};}
\nodeshadowed [at={(4.5,-.5 )},yslant=-.08]
{\Huge \textcolor{blue}{R}};
\end{tikzpicture}
\vspace*{2.5cm}\par
\noindent
\begin{minipage}{0.35\linewidth}
\begin{flushright}
I wish the chapter numbers were here
\end{flushright}
\end{minipage} \hspace{15pt}
%
\begin{minipage}{0.02\linewidth}
\textcolor{col2}{\rule{1pt}{300pt}}
\end{minipage} \hspace{-10pt}
%
\begin{minipage}{0.6\linewidth}
\vspace{5pt}
I wish the chapter titles were here
\end{minipage}
\end{titlepage}
\restoregeometry
\lipsum[1-2]
\end{document}
任何方式都可以实现与下面的示例相同的效果,但是在article
课堂上:
\documentclass{tufte-book}
\usepackage{lmodern}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\newcounter{chapmark}
\setcounter{tocdepth}{1}
\colorlet{mycolor}{BrickRed}
\titlecontents{chapter}%
[0em]
{\vspace{1.5\baselineskip}\begin{fullwidth}\LARGE\rmfamily\itshape}
{\hspace*{0em}\thecontentslabel}
{\hspace*{0em}\llap{%
\parbox[b]{40pt}{%
\fontsize{25}{30}\sffamily\bfseries\color{mycolor}%
\hfill\thecontentspage%
}\hspace{20pt}%
}%
}
{\rmfamily\upshape\qquad}
[\end{fullwidth}]
\titlecontents{section}
[0em]
{\vspace{0\baselineskip}\begin{fullwidth}\Large\rmfamily\itshape}
{\hspace*{0em}\contentslabel{2em}}
{\llap{\parbox[b]{40pt}{\hfill\thecontentspage}\hspace{20pt}}\hspace*{0em}}
{\rmfamily\upshape\qquad}
[\end{fullwidth}]
\titlecontents{subsection}
[0em]
{\vspace{-.15\baselineskip}\begin{fullwidth}\large\rmfamily\itshape}
{\hspace*{0em}\contentslabel{4em}}
{\llap{\parbox[b]{40pt}{\hfill\small\thecontentspage}\hspace{20pt}}\hspace*{0em}}
{\rmfamily\upshape}
[\end{fullwidth}]
\newcommand\StartMark{%
\addtocontents{toc}{\protect\label{st\thechapmark}%
\par\protect\begin{tikzpicture}[overlay,remember picture,baseline]
\protect\node [anchor=base] (s\thechapmark) {};%
\ifnum\getpagerefnumber{st\thechapmark}=\getpagerefnumber{en\thechapmark}
\else
\protect\draw[mycolor,line width=3pt]
let \protect\p3= (s\thechapmark),%
\protect\p4 = (current page text area.south) in %
( $ (0em,\protect\y3) + (-20pt,-5ex) $ ) --
( $ (0em,\protect\y4) + (-20pt,-5pt) $ );
\fi
\protect\end{tikzpicture}\par}%
}
\newcommand\EndMark{%
\addtocontents{toc}{\protect\label{en\thechapmark}%
\par\protect\begin{tikzpicture}[overlay,remember picture,baseline]
\protect\node [anchor=base] (e\thechapmark) {};
\ifnum\getpagerefnumber{st\thechapmark}=\getpagerefnumber{en\thechapmark}
\protect\draw[mycolor,line width=3pt]
let \protect\p1= (s\thechapmark),
\protect\p2=(e\thechapmark) in %
( $ (0em,\protect\y1) + (-20pt,-5ex) $ ) --
( $ (0em,\protect\y2) + (-20pt,2ex) $ );
\else%
\protect\draw[mycolor,line width=3pt]
let \protect\p1= (e\thechapmark),
\protect\p2=(current page text area.north) in
( $ (0em,\protect\y2) + (-20pt,5pt) $ ) --
( $ (0em,\protect\y1) + (-20pt,2ex) $ );
\fi
\protect\end{tikzpicture}\par}%
\stepcounter{chapmark}%
}
\setcounter{page}{123}% just for the example
\begin{document}
\tableofcontents
\StartMark
\chapter{Beginning to learn design with \LaTeX}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\EndMark
\StartMark
\chapter{Beginning to learn design with HTML}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\EndMark
\StartMark
\chapter{Beginning to learn design with \LaTeX\ again}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\EndMark
\StartMark
\chapter{Beginning to learn design with \LaTeX\ again}
\section{This is a test section}
\section{This is a test section}
\section{This is a test section}
\EndMark
\end{document}
答案1
有一种可能性是:
\documentclass[dvipsnames,svgnames,x11names]{article}
\usepackage{refcount}
\usepackage{titletoc}
\usepackage{tikzpagenodes}
\usetikzlibrary{calc}
\newcounter{chapmark}
%\setcounter{tocdepth}{1}
\colorlet{mycolor}{BrickRed}
\titlecontents{section}%
[0em]
{\vspace{1.5\baselineskip}\LARGE\rmfamily\itshape}
{\hspace*{0em}\llap{\parbox[t]{40pt}{\hfill\color{mycolor}\thecontentspage}\hspace*{10pt}}}
{\thecontentspage}
{\rmfamily\upshape\qquad}
\titlecontents{subsection}%
[0em]
{\vspace{.3\baselineskip}\large\rmfamily\itshape}
{\hspace*{0em}\llap{\parbox[t]{40pt}{\hfill\color{mycolor}\thecontentspage}\hspace*{10pt}}}
{\thecontentspage}
{\rmfamily\upshape\qquad}
\titlecontents{subsubsection}%
[0em]
{\vspace{.3\baselineskip}\normalsize\rmfamily\itshape}
{\hspace*{0em}\llap{\parbox[t]{40pt}{\hfill\color{mycolor}\thecontentspage}\hspace*{10pt}}}
{\thecontentspage}
{\rmfamily\upshape\qquad}
\newcommand\StartMark{%
\addtocontents{toc}{\protect\label{st\thechapmark}%
\par\protect\begin{tikzpicture}[overlay,remember picture,baseline]
\protect\node [anchor=base] (s\thechapmark) {};%
\ifnum\getpagerefnumber{st\thechapmark}=\getpagerefnumber{en\thechapmark}
\else
\protect\draw[mycolor,line width=3pt]
let \protect\p3= (s\thechapmark),%
\protect\p4 = (current page text area.south) in %
( $ (0em,\protect\y3) + (-20pt,-5ex) $ ) --
( $ (0em,\protect\y4) + (-20pt,5pt) $ );
\fi
\protect\end{tikzpicture}\par}%
}
\newcommand\EndMark{%
\addtocontents{toc}{\protect\label{en\thechapmark}%
\par\protect\begin{tikzpicture}[overlay,remember picture,baseline]
\protect\node [anchor=base] (e\thechapmark) {};
\ifnum\getpagerefnumber{st\thechapmark}=\getpagerefnumber{en\thechapmark}
\protect\draw[mycolor,line width=3pt]
let \protect\p1= (s\thechapmark),
\protect\p2=(e\thechapmark) in %
( $ (0em,\protect\y1) + (-20pt,-5ex) $ ) --
( $ (0em,\protect\y2) + (-20pt,2ex) $ );
\else%
\protect\draw[mycolor,line width=3pt]
let \protect\p1= (e\thechapmark),
\protect\p2=(current page text area.north) in
( $ (0em,\protect\y2) + (-20pt,5pt) $ ) --
( $ (0em,\protect\y1) + (-20pt,2ex) $ );
\fi
\protect\end{tikzpicture}\par}%
\stepcounter{chapmark}%
}
\setcounter{page}{123}% just for the example
\begin{document}
\tableofcontents
\StartMark
\section{A test section}
\subsection{This is a test subsection}
\subsubsection{This is a test subsubsection}
\subsubsection{This is another test subsubsection}
\subsection{This is a test subsection}
\subsection{This is a test subsection}
\subsection{This is a test subsection}
\EndMark
\StartMark
\section{Another test section}
\subsection{This is a test subsection}
\subsection{This is a test subsection}
\subsubsection{This is a test subsubsection}
\subsubsection{This is another test subsubsection}
\EndMark
\StartMark
\section{Yet another test section}
\subsection{This is a test subsection}
\subsection{This is a test subsection}
\subsubsection{This is a test subsubsection}
\subsubsection{This is another test subsubsection}
\subsection{This is a test subsection}
\subsubsection{This is a test subsubsection}
\subsubsection{This is another test subsubsection}
\subsection{This is a test subsection}
\subsubsection{This is a test subsubsection}
\subsubsection{This is another test subsubsection}
\subsection{This is a test subsection}
\subsubsection{This is a test subsubsection}
\subsubsection{This is another test subsubsection}
\EndMark
\end{document}