我怎样才能获得如下的目录(三重页码)

我怎样才能获得如下的目录(三重页码)

我想排版一本带有提示和解决方案的问题书。

我想要获得目录

                TABLE OF CONTENTS

                            Problems   Hints    Solutions

    Chapter 1 Algebra          1         25        50
        problem 1.1            2         26        51
        problem 1.2            3         27        52
    .......................................................
    Chapter 2 Geometry        91        135       180
        problem 2.1           92        136       181
        problem 2.2           93        137       182
    .......................................................

我怎样才能得到结果?(我比其他人更熟悉titlesectitletoc包。)

顺便说一句,我会输入我的源代码,例如

\part{PROBLEMS}

\chapter{ALGEBRA}
\problem The first algebra question ...
\problem The second algebra question ...
...
\chapter{GEOMETRY}
\problem The first geometry question ...
\problem The second geometry question ...
...

\part{HINTS}

\chapter{ALGEBRA}
\hint The hint of the first algebra question ...
\hint The hint of the second algebra question ...
...
\chapter{GEOMETRY}
\hint The hint of the first geometry question ...
\hint The hint of the second geometry question ...
...

\part{SOLUTIONS}

\chapter{ALGEBRA}
\solution The solution of the first algebra question ...
\solution The solution of the second algebra question ...
...
\chapter{GEOMETRY}
\solution The solution of the first geometry question ...
\solution The solution of the second geometry question ...
...

或者类似

...

\chapter{ALGEBRA}
\problem The first algebra question ...
\hint The hint of the first algebra question ...
\solution The solution of the first algebra question ...

\problem The second algebra question ...
\hint The hint of the second algebra question ...
\solution The solution of the second algebra question ...
...
\chapter{GEOMETRY}
\problem The first geometry question ...
\hint The hint of the first geometry question ...
\solution The solution of the first geometry question ...

\problem The second geometry question ...
\hint The hint of the second geometry question ...
\solution The solution of the second geometry question ...
...

哪一个更好?欢迎其他人提出建议。

答案1

我提供了一个解决方案的建议,采用问题 - 提示 - 解决方案 (PHS) 方法,使用我的包中的一些编码技术(仍在建设中)

我不得不重新定义\part\chapter命令,但省略了\section等等。

基本命令是,\PHS最多需要四个参数:

第一个参数是可选的,目前仅支持NoHint=true/falseNoSolution=true/false。使用它们来隐藏提示和/或解决方案。

第二个参数:问题内容 第三个参数:提示内容 第四个参数:解决方案内容。

将提示和解决方案的内容写入外部文件,然后读取。

\MyTableOfContents根据要求显示了三重 toc 的(粗略)设置。

这些彩色盒子真是赏心悦目。

笔记 单个框的内容可能会转移到另一页,而自动标签锚点目前位于框外。标签的设置应在框内而不是框外进行,但这将留待问题/提示/解决方案外观的最终使用。

这段代码中肯定存在一些错误,但我现在还不记得了;-)

更新据 jfbu 称,有一些不必要的\expandafter声明。我已将其删除。

\documentclass[12pt,paper=a4]{scrbook}
\usepackage{morewrites}
\usepackage{longtable}
\usepackage{blindtext}
\usepackage{etoolbox}
\usepackage{tcolorbox}
\usepackage{xcolor}

\usepackage{bbding}%
\usepackage{dingbat}%
\usepackage{xkeyval}%

\usepackage[final,bookmarksopen=true,bookmarksopenlevel=4,pageanchor,pdftoolbar=true]{hyperref}%
\usepackage{bookmark}%


\hypersetup{linkbordercolor=0 0 1}%

\newcounter{phs}[chapter]%

\newwrite\hintsfile%
\newwrite\solutionfile%
\newwrite\phstocfile%

\newrobustcmd{\NoHintTocSymbol}{\Peace}%
\newrobustcmd{\NoSolutionTocSymbol}{\Peace}%

\newrobustcmd{\ProblemName}{Problem}%
\newrobustcmd{\HintName}{Hint}%
\newrobustcmd{\SolutionName}{Solution}%


\newrobustcmd{\PHSKeyFamily}{PHSKeys}%

\newrobustcmd{\ProvideBool}[2][false]{%
\providebool{#2}%
\setbool{#2}{#1}
\long\csgdef{Enable#2}{%
\booltrue{#2}%
}%
\long\csgdef{Disable#2}{%
\boolfalse{#2}%
}%
}%


\makeatletter

\ProvideBool{NoHint}%
\define@boolkey{\PHSKeyFamily}{NoHint}[false]{%
\ifKV@PHSKeys@NoHint%
\EnableNoHint%
\else%
\DisableNoHint%
\fi%
}%

\ProvideBool{NoSolution}%
\define@boolkey{\PHSKeyFamily}{NoSolution}[false]{%
\ifKV@PHSKeys@NoSolution%
\EnableNoSolution%
\else%
\DisableNoSolution%
\fi%
}%


\makeatother


\AtBeginDocument{%
\immediate\openout\phstocfile=\jobname.phstoc%
\immediate\openout\hintsfile=\jobname.hin%
\immediate\openout\solutionfile=\jobname.sol%
}

\AtEndDocument{%
\immediate\closeout\phstocfile%
\immediate\closeout\hintsfile%
\immediate\closeout\solutionfile%
}%

\renewcommand{\thephs}{\arabic{chapter}.\arabic{phs}}%

\newrobustcmd{\problemnumberref}[3][]{%
\expandafter{\textbf{\ProblemName\ #2.#3}}%
}

\newrobustcmd{\problempageref}[3][]{%
\pageref{\unexpanded{phs::#2::#3}}%
}%


\newrobustcmd{\hintpageref}[3][]{%
\setkeys{\PHSKeyFamily}{#1}%
\ifboolexpr{bool{NoHint}}{\textcolor{blue}{\NoHintTocSymbol}}{%
\pageref{\unexpanded{hint::#2::#3}}
}%
}%

\newrobustcmd{\solutionpageref}[3][]{%
\setkeys{\PHSKeyFamily}{#1}%
\ifboolexpr{bool{NoSolution}}{\textcolor{blue}{\NoHintTocSymbol}}{%
\pageref{\unexpanded{solution::#2::#3}}%
}%
}%



\newrobustcmd{\WritePHSTocInfo}[3][]{%
\setkeys{\PHSKeyFamily}{#1}%
\immediate\write\phstocfile{%
\string\hspace{1em}\problemnumberref{#2}{#3} & \problempageref[#1]{#2}{#3} & \hintpageref[#1]{#2}{#3} & \solutionpageref[#1]{#2}{#3}%
\tabularnewline%
}%
}%




\newrobustcmd{\PHS}[4][]{%
\setkeys{\PHSKeyFamily}{#1}%
\refstepcounter{phs}%
\phantomsection%
\label{phs::\number\value{chapter}::\number\value{phs}}%
\WritePHSTocInfo[#1]{\number\value{chapter}}{\number\value{phs}}%
\begin{tcolorbox}[width=\textwidth,coltitle=black,colbacktitle=yellow,title=\textbf{\ProblemName\ \thephs}]
#2
\end{tcolorbox}
\immediate\write\hintsfile{%
\string\PHSHint[#1]{\unexpanded\expandafter{#3}}% 
}%
\immediate\write\solutionfile{%
\string\PHSSolution[#1]{\unexpanded\expandafter{#4}}% 
}%
}%

\newrobustcmd{\PHSHint}[2][]{%
\setkeys{\PHSKeyFamily}{#1}%
%\refstepcounter{phshint}%
\refstepcounter{phs}%
\phantomsection%
\label{hint::\number\value{chapter}::\number\value{phs}}%
\ifboolexpr{bool{NoHint}}{}{%
\begin{tcolorbox}[width=\textwidth,colbacktitle=red,coltitle=black,title=\textbf{{\HintName\ \thephs}}]%
#2%  
\end{tcolorbox}%
}%
\DisableNoHint%  
}%


\newrobustcmd{\PHSSolution}[2][]{%
\setkeys{\PHSKeyFamily}{#1}%
%\refstepcounter{phssolution}%
\refstepcounter{phs}%
\phantomsection%
\label{solution::\number\value{chapter}::\number\value{phs}}%
\ifboolexpr{bool{NoSolution}}{}{%
\begin{tcolorbox}[width=\textwidth,colbacktitle=cyan,coltitle=black,title=\textbf{{\SolutionName\ \thephs}}]%
#2%
\end{tcolorbox}%
}%
\DisableNoSolution%
}%


\newcommand*{\ListOfProblemsName}{List of Problems}%

\newrobustcmd{\MyTableOfContents}{%
\cleardoublepage%
\phantomsection%
%\pdfbookmark[0]{\ListOfProblemsName}{bookmark::mytableofcontents}%

\pagestyle{plain}
\phantomsection
\addcontentsline{toc}{chapter}{\protect{\ListOfProblemsName}}
\begin{longtable}{lrrr}
& \multicolumn{1}{c}{\large{\textbf{Problems}}} & \multicolumn{1}{c}{\large{\textbf{Hints}}} & \multicolumn{1}{c}{\large{\textbf{Solutions}}}   \tabularnewline
\WritePreChapterEmptyLine%
\endhead%
\IfFileExists{\jobname.phstoc}{%
\input{\jobname.phstoc}%
}{}%
\end{longtable}
}%


\makeatletter
\newcounter{InternalChapterCounter}

\newrobustcmd{\hintsfilechapterstartup}[2]{%
  \phantomsection%
  \pdfbookmark{#1}{hint::chapter::\number\value{#2}}%
  \begingroup
  \setcounter{InternalChapterCounter}{\number\value{#2}}%
  \addtocounter{InternalChapterCounter}{-1}
  \bookmarksetup{depth=-1}
  \addcontentsline{toc}{chapter}{\protect{\arabic{InternalChapterCounter}.\ #1}}%
  \endgroup
  \LaTeXStandardChapter[]{#1}%

}%


\newrobustcmd{\postponedfilechapterstartup}[3]{%
  \cleardoublepage%
  \phantomsection%
  \begingroup%
  \setcounter{InternalChapterCounter}{\number\value{#2}}%
  \addtocounter{InternalChapterCounter}{1}%
  \bookmarksetup{depth=-1}%  Prevent bookmarking by \addcontentsline
  \addcontentsline{toc}{chapter}{\protect{\number\value{InternalChapterCounter}.\ #1}}%
  \endgroup%
  \LaTeXStandardChapter[]{#1}%
  \phantomsection
  \pdfbookmark{#1}{#3::chapter::\number\value{chapter}}%
}%


\newrobustcmd{\WritePreChapterEmptyLine}{%
\ifnumgreater{\number\value{chapter}}{0}{%
\immediate\write\phstocfile{%
\string & & & \tabularnewline%
}}{%
% Do nothing
}%
}%

\newcounter{dummychaptercounter}%
\let\LaTeXStandardChapter\chapter%

\newrobustcmd{\@phschapter@noopt}[1]{%
\LaTeXStandardChapter{#1}%
\immediate\write\hintsfile{%
  \string\postponedfilechapterstartup{#1}{chapter}{hint}%
}%
\immediate\write\solutionfile{%
  \string\postponedfilechapterstartup{#1}{chapter}{solution}%
}%
\WritePreChapterEmptyLine%
\immediate\write\phstocfile{%
\string\expandafter\unexpanded{{\Large\textbf{\chaptername{} #1}}} & & & \tabularnewline%
\string  & & & \tabularnewline
}%
}%

\newrobustcmd{\@phschapter@opt}[2][]{%
%%%% Do not use this, it is not correct so far!!!
\setcounter{dummychaptercounter}{\number\value{chapter}}%
\addtocounter{dummychaptercounter}{1}%
\renewcommand{\thedummychaptercounter}{\arabic{dummychaptercounter}.}%
\immediate\write\hintsfile{%
  \string\phantomsection%
  \string\pdfbookmark{#2}{hint::chapter::\number\value{chapter}}%
  \string\LaTeXStandardChapter[]{#2}%
}%
\immediate\write\solutionfile{%
 \string\phantomsection%
 \string\pdfbookmark{#2}{solution::chapter::\number\value{chapter}}%
 \string\LaTeXStandardChapter[]{#2}%
}%
\immediate\write\phstocfile{%
\string\expandafter\unexpanded{{\Large\textbf{\chaptername{} #2}}} & & & \tabularnewline%
}%
\LaTeXStandardChapter[#1]{#2}% This is the problem chapter
}%




\newrobustcmd{\phschapter}{%
\@ifnextchar[{\@phschapter@opt}{\@phschapter@noopt}
}%

\newrobustcmd{\phsstarredchapter}[1]{%
\LaTeXStandardChapter*{#1}%
}%

\renewcommand{\chapter}{%
\@ifstar{\phsstarredchapter}{\phschapter}%
}%


\let\LaTeXStandardPart\part%

\renewcommand{\part}[1]{%
\immediate\write\hintsfile{%
  \string\setcounter{chapter}{0}%
}%
\immediate\write\solutionfile{%
  \string\setcounter{chapter}{0}%
}%
\LaTeXStandardPart{#1}%
}%


\makeatother


\setcounter{secnumdepth}{2}%

\begin{document}
\cleardoublepage%
\phantomsection%
\tableofcontents % Normal table of contents

\MyTableOfContents % List of problems etc. 


\part{Problems}

\chapter{Algebra}
\PHS[NoHint=true]{Show that \(\left({a+b}\right)^2 = a^2 + 2\cdot a \cdot b +b^2\)}{Multiply!!!}{Solution to be done}
\PHS[NoHint=false]{Show that \(\left({a-b}\right)^2 = a^2 - 2\cdot a \cdot b +b^2\)}{Multiply!!!}{Solution to be done}
\PHS{Show that \[\left({a-b}\right)\cdot\left({a+b}\right)  = a^2 - b^2 \]} {Multiply!!!}{Solution to be done}
\PHS[NoHint=true]{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%
\PHS{Dummy Algebra}{Dummy Algebra}{Dummy Algebra}%


\chapter{Geometry}

\PHS{Show that \(c^2 =  a^2 + b^2\)}{Tricky partitioning of a square}{Solution to be done}
\PHS[NoSolution=true]{Show that \Huge\[\sin^2\left({\alpha}\right) + \cos^2\left({\alpha}\right) \equiv 1 \]\normalsize}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%
\PHS{Dummy Geometry}{Dummy Geometry}{Dummy Geometry}%

\chapter{Calculus}
\PHS{Dummy Calculus}{Dummy Calculus}{Dummy Calculus}%
\PHS{Dummy Calculus}{Dummy Calculus}{Dummy Calculus}%

\chapter{Matrix calculations}

\PHS{Dummy Matrix}{Dummy Matrix}{Dummy Matrix}%
\PHS{Dummy Matrix}{Dummy Matrix}{Dummy Matrix}%


\clearpage

\part{Hints}

\IfFileExists{\jobname.hin}{\input{\jobname.hin}}{}

\part{Solutions}

\IfFileExists{\jobname.sol}{\input{\jobname.sol}}{}


\end{document}

在此处输入图片描述 在此处输入图片描述 在此处输入图片描述 在此处输入图片描述

相关内容