附录编号和 includepdf

附录编号和 includepdf
\documentclass[a4paper, english, oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath, amsfonts, amssymb}
\usepackage{fancyhdr}
\usepackage{titlesec}
\usepackage{pdfpages}
\usepackage{etoolbox}
\usepackage[title,titletoc,toc,page]{appendix}
\usepackage{lipsum}

\patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{} 

% Endre på kapittelteksten
\titleformat{\chapter}[hang]
{\normalfont\huge\bfseries}{\thechapter.}{0.7em}{} 
\titlespacing*{\chapter}{0pt}{-20pt}{0pt}


\pagestyle{fancy}
\fancyhf{} 
\lhead{Left Head}
\rhead{Project}
\rfoot{Page \thepage}
\setlength{\headheight}{23pt} 

\fancypagestyle{plain}{
    \fancyhf{} 
    \lhead{Left Head}
    \rhead{Project}
    \rfoot{Page \thepage}
}

\begin{document}

\frontmatter
\tableofcontents

\mainmatter


\newpage
\begin{appendices}
\pretocmd{\chapter}{
  \pagenumbering{arabic}
  \renewcommand*{\thepage}{\thechapter\arabic{page}}
}{}{}

\chapter{Something here 1}
\lipsum[1-3]

\chapter{Something here 2}
\lipsum[1-3]

\includepdf[pagecommand={\chapter{Something here 3}\section{Part 1}}, offset=0cm -5cm]{pdf1}
\includepdf[pagecommand={\section{Part 2}}, offset=0cm -5cm]{pdf1}
\end{appendices}

\end{document}

我遇到的问题是“A”下的附录编号为 A1、A2、A3 等,但是一旦包含在 includepdf 中,并且 pagecommand 定义章节,则只会编号为 1、2、3 等,而不是 B1、B2、B3...

如何解决这个问题?pdf 是普通的 a4 页,您可以将其用于测试目的:https://www.dropbox.com/s/kmfngjx0oiart7s/pdf1.pdf?dl=0

答案1

我建议在选项appendix中明确使用页面样式。pagecommand\includepdf

\chapter每次在环境中使用时,页码都会重置appendices

当然,缩放等取决于.pdf文件的输入大小;边距设置应使用 进行更改geometry。不过,我将详细设置留给了 OP。

\documentclass[a4paper, english, oneside]{book}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage{amsmath, amsfonts, amssymb}
\usepackage{fancyhdr}
\usepackage{etoolbox}
\usepackage[title,titletoc,toc,page]{appendix}
\usepackage{lipsum}
\usepackage{blindtext}

\AtBeginDocument{
  \patchcmd{\chapter}{\thispagestyle{plain}}{\thispagestyle{fancy}}{}{} 
}

\usepackage{pdfpages}



\pagestyle{fancy}
\fancyhf{} 
\lhead{Left Head}
\rhead{Project}
\rfoot{Page \thepage}
\setlength{\headheight}{23pt} 

\fancypagestyle{plain}{
  \fancyhf{} 
  \lhead{Left Head}
  \rhead{Project}
  \rfoot{Page \thepage}
}

\fancypagestyle{appendix}{
  \fancyhf{} 
  \lhead{Left Head}
  \rhead{Project}
  \rfoot{Page \thechapter\arabic{page}}
}


\begin{document}

\frontmatter
\tableofcontents

\mainmatter


\newpage
\begin{appendices}
  \pretocmd{\chapter}{%
    \clearpage
    \pagenumbering{arabic}
    \renewcommand*{\thepage}{\thechapter\arabic{page}}
  }{}{}

\chapter{Something here 1}
\blindtext[4]

\chapter{Something here 2}
\blindtext[4]

\pagestyle{appendix}
\includepdf[pagecommand={\chapter{Something here 3}\pagestyle{appendix}}, scale=0.8,offset=0cm -8cm]{pdf1}
\includepdf[pages=1,pagecommand={\section{Part 2}\pagestyle{appendix}},offset=0cm -6cm]{pdf1}
\end{appendices}

\end{document}

在此处输入图片描述

相关内容