在下面给出的代码中,我想更改章节缩略图中显示的文本以显示当前的小节标题。目前,章节缩略图显示章节名称。
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage{xcolor}
\definecolor{ultramarine}{RGB}{0,45,97}
\definecolor{mybluei}{RGB}{0,173,239}
\usetikzlibrary{calc}
\pagestyle{plain}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcommand\BoxColor{ultramarine}
\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}
\usepackage{etoolbox,fancyhdr}
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}}
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize\thesection\hspace{5pt}#1}{}}
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage}
\fancyhead[LO]{\textcolor{mybluei} \rightmark%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{white}{\bfseries\scshape\leftmark}}}};
\end{tikzpicture}}
\fancyhead[RE]{\textcolor{mybluei}\leftmark%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north west]
at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{white}{\bfseries\scshape\leftmark}}}};
\end{tikzpicture}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\renewcommand{\footrulewidth}{.5pt}
\fancyfoot[LE,RO]{\footnotesize\bfseries\itshape LF Foot}
\fancyfoot[C]{\footnotesize\bfseries CTR FOOT}
\fancyfoot[RE,LO]{\footnotesize\bfseries\itshape RT Foot}
\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\patchcmd{\@makechapterhead}
{\vskip 40\p@}
{\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother
\usepackage{fourier}
\usepackage[explicit]{titlesec}
\begin{document}
\chapter{Chap 1 Problems}
\section{Problem 1}
\subsection{Problem 1}
\lipsum[1]
\subsection{Solution 1}
\lipsum[1-7]
\newpage
\section{Problem 2}
\subsection{Problem 2}
\lipsum[1]
\subsection{Solution 2}
\lipsum[1-4]
\chapter{Chap 2 Problems}
\section{Problem 1}
\subsection{Problem 1}
\lipsum[1]
\newpage
\subsection{Solution 1}
\lipsum[1]
\newpage
\section{Problem 2}
\subsection{Problem 2}
\lipsum[1]
\subsection{Solution 2}
\lipsum[1]
\end{document}
您能帮助我让当前子部分显示在章节缩略图中吗?例如,在 下\section{Problem 1}
,我想显示
- 第 1 行 - 问题 1
- 第 2 行 - 解决方案 1
在章节缩略图中。然后对于下一节(问题 2),显示问题 2、解决方案 2 等等。
谢谢。
答案1
这是一个选项:
\documentclass{book}
\usepackage[T1]{fontenc}
\usepackage{tikz}
\usetikzlibrary{calc}
\usepackage{lipsum}
\usepackage{xcolor}
\definecolor{ultramarine}{RGB}{0,45,97}
\definecolor{mybluei}{RGB}{0,173,239}
\usetikzlibrary{calc}
\pagestyle{plain}
\newcounter{chapshift}
\addtocounter{chapshift}{-1}
\newcommand\BoxColor{ultramarine}
%\renewcommand\chaptermark[1]{\markboth{\thechapter.~#1}{}}
\usepackage{etoolbox,fancyhdr}
\pagestyle{fancy}
%\renewcommand{\chaptermark}[1]{\markboth{\sffamily\normalsize\bfseries \ #1}{}}
\def\subsectiontitle{}
\renewcommand{\sectionmark}[1]{\markright{\sffamily\normalsize#1}{}}
\renewcommand{\subsectionmark}[1]{\def\subsectiontitle{#1}}
\fancyhf{} \fancyhead[LE,RO]{\sffamily\normalsize\thepage}
\fancyhead[LO]{\textcolor{mybluei} \rightmark%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north east]
at ($ (current page.north east) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{white}{\bfseries\scshape\rightmark \\ \subsectiontitle}}}};
\end{tikzpicture}}
\fancyhead[RE]{\textcolor{mybluei}\leftmark%
\begin{tikzpicture}[overlay,remember picture]
\node[fill=\BoxColor,inner sep=0pt,rectangle,text width=1cm,
text height=4cm,align=center,anchor=north west]
at ($ (current page.north west) + (-0cm,-2*\thechapshift cm) $)
{\rotatebox{90}{\parbox{4cm}{%
\centering\textcolor{white}{\bfseries\scshape\rightmark \\ \subsectiontitle}}}};
\end{tikzpicture}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\newcommand{\footrulecolor}[1]{\patchcmd{\footrule}{\hrule}{\color{#1}\hrule}{}{}}
\renewcommand{\headrulewidth}{.5pt}
\addtolength{\headheight}{2.5pt}
\renewcommand{\footrulewidth}{.5pt}
\fancyfoot[LE,RO]{\footnotesize\bfseries\itshape LF Foot}
\fancyfoot[C]{\footnotesize\bfseries CTR FOOT}
\fancyfoot[RE,LO]{\footnotesize\bfseries\itshape RT Foot}
\fancypagestyle{plain}{%
\fancyhf{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\makeatletter
\renewcommand{\cleardoublepage}{
\clearpage\ifodd\c@page\else
\hbox{}
\vspace*{\fill}
\thispagestyle{empty}
\newpage
\fi}
\patchcmd{\@makechapterhead}
{\vskip 40\p@}
{\vskip 40\p@\stepcounter{chapshift}}{}{}
\makeatother
\usepackage{fourier}
\usepackage[explicit]{titlesec}
\begin{document}
\chapter{Chap 1 Problems}
\section{Problem 1}
\subsection{Problem 1}
\lipsum[1]
\subsection{Solution 1}
\lipsum[1-7]
\newpage
\section{Problem 2}
\subsection{Problem 2}
\lipsum[1]
\subsection{Solution 2}
\lipsum[1-4]
\chapter{Chap 2 Problems}
\section{Problem 1}
\subsection{Problem 1}
\lipsum[1]
\newpage
\subsection{Solution 1}
\lipsum[1]
\newpage
\section{Problem 2}
\subsection{Problem 2}
\lipsum[1]
\subsection{Solution 2}
\lipsum[1]
\end{document}