如何防止目录中的章节标题打印 3 次

如何防止目录中的章节标题打印 3 次

我使用了交叉引用包含标签中的计数器和参数的 PDF以及来自贝茨编号多个 PDF 文件,并附有页码标签

在我对贝茨编号的探索中,现在似乎所有编号都有效,但目录除外:

在此处输入图片描述

各部分看上去不错,如下所示:

在此处输入图片描述

我使用的 LaTeX 代码(使用 quickcode.tex 文档第一个参考创建pdf 10.pdf和18.pdf)制作以下示例:

\documentclass[12pt,letterpaper,fleqn,parskip=half]{scrartcl}
\usepackage{bookman}
\usepackage{lscape}
\usepackage[latin1]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[demo]{graphicx}
\usepackage[scaled]{helvet}
\usepackage{caption}
\usepackage[breaklinks=true,colorlinks=true,linkcolor=black,citecolor=black,urlcolor=black]{hyperref}
\usepackage{xargs}                                          

%---------------------------------------------------------------------
%   % Macro to include PDF document with page numbers in caption and label
%---------------------------------------------------------------------
\newcounter{imagepage}

\makeatletter
\newcommandx{\picTEST}[5][1=0.9, 2=0]
{\pdfximage{#4}
\setcounter{imagepage}{0} 
\@whilenum\value{imagepage}<\pdflastximagepages\do{%
    \stepcounter{imagepage}
    \begin{figure}[h!]
     \centering
     \includegraphics[width=#1\textwidth,page=\value{imagepage},angle=#2]{#4}
     \caption{#5 - Page \arabic{imagepage} of {\the\pdflastximagepages}}
     \label{#3\theimagepage}
    \end{figure}
    \clearpage}}
\makeatother

\usepackage{fmtcount}
\renewcommand{\thesection}{\ORDINALstring{section} POINT}
\renewcommand{\thesubsection}{\arabic{subsection}}

\usepackage{xpatch} \makeatletter 
\xpatchcmd{\tableofcontents}{\contentsname \@mkboth}{\LARGE\uppercase\contentsname\@mkboth}{}{} 
\makeatother


\addtokomafont{disposition}{\rmfamily}


\begin{document}

\Large
\clearpage
\begingroup
\areaset{\paperwidth}{\paperheight}
\renewcommand{\figurename}{RECORD PAGE}
\picTEST{Transcript1_Label_Page}{10.pdf}{Transcript, September 1, 2010}
\picTEST{Transcript2_Label_Page}{18.pdf}{Transcript, February 23, 2011}


\endgroup

\tableofcontents

\newpage

 \setcounter{page}{1}

 \section{~} 

\subsection{All Cows Eat Grass}

Here is reference to page \ref{Transcript2_Label_Page3} of the included PDF document, proving that:

The grass is greener...
\section{~}

]5

因此,如果有人知道如何消除目录中重复的章节标题,那就太好了。

答案1

您还会收到一堆错误,因此输出本质上是任意的。

该命令\ORDINALstring很脆弱,但更重要的是,它不能完全扩展。因此,您必须\ORDINALstringnum{\arabic{section}}在强化fmtcount命令后使用:

\usepackage{etoolbox} % loaded by xpatch
\renewcommand{\thesection}{\ORDINALstringnum{\arabic{section}} POINT}
\robustify{\ORDINALstringnum}

最好先加载所有包,然后应用自定义。

还要注意,\Large一开始就发布并不是最好的选择。结果根本不令人满意。而且\pdfximage直接使用似乎不太方便。

最后\uppercase\contentsname是寻找麻烦的一个非常好的方法,因为\uppercase宏不接受参数。它应该是

\MakeUppercase{\contentsname}

我还修复了包加载的顺序。

\documentclass[12pt,letterpaper,fleqn,parskip=half]{scrartcl}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage{lscape}
\usepackage{graphicx}

\usepackage{bookman}
\usepackage[scaled]{helvet}

\usepackage{caption}
\usepackage{xargs}                                          
\usepackage{fmtcount}
\usepackage{xpatch}
\usepackage[breaklinks=true,colorlinks=true,linkcolor=black,citecolor=black,urlcolor=black]{hyperref}

%---------------------------------------------------------------------
%   % Macro to include PDF document with page numbers in caption and label
%---------------------------------------------------------------------
\newcounter{imagepage}

\makeatletter
\newcommandx{\picTEST}[5][1=0.9, 2=0]
{\pdfximage{#4}
\setcounter{imagepage}{0} 
\@whilenum\value{imagepage}<\pdflastximagepages\do{%
    \stepcounter{imagepage}
    \begin{figure}[h!]
     \centering
     \includegraphics[width=#1\textwidth,page=\value{imagepage},angle=#2]{#4}
     \caption{#5 - Page \arabic{imagepage} of {\the\pdflastximagepages}}
     \label{#3\theimagepage}
    \end{figure}
    \clearpage}}
\makeatother

\renewcommand{\thesection}{\ORDINALstringnum{\arabic{section}} POINT}
\renewcommand{\thesubsection}{\arabic{subsection}}
\robustify{\ORDINALstringnum}

\makeatletter 
\xpatchcmd{\tableofcontents}{\contentsname \@mkboth}{\LARGE\MakeUppercase{\contentsname}\@mkboth}{}{} 
\makeatother


\addtokomafont{disposition}{\rmfamily}


\begin{document}

\begingroup
\Large
\areaset{\paperwidth}{\paperheight}
\renewcommand{\figurename}{RECORD PAGE}
\picTEST{Transcript1_Label_Page}{example-image.pdf}{Transcript, September 1, 2010}
\picTEST{Transcript2_Label_Page}{example-image.pdf}{Transcript, February 23, 2011}

\endgroup

\tableofcontents

\newpage

 \setcounter{page}{1}

 \section{~} 

\subsection{All Cows Eat Grass}

Here is reference to page \ref{Transcript2_Label_Page3} of the included PDF document, proving that:

The grass is greener...
\section{~}

\end{document}

在此处输入图片描述

相关内容