使用 pdfpages 时更改页面顺序,第二部分

使用 pdfpages 时更改页面顺序,第二部分

第一:这是第一个问题的后续问题这里

考虑以下示例。

文件:f1.tex

\documentclass[
  12pt,
  landscape,
  danish
]{article}

\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[
  a6paper,
  margin = 0.8cm
]{geometry}
\usepackage{lmodern}
\usepackage[sc]{mathpazo}
\usepackage{multido}
\usepackage{microtype}

\newenvironment{navn}{%
  \setlength{\topskip}{0pt}%
  \centering
  \vspace*{\fill}%
  \nointerlineskip
  \fontsize{40}{48}\selectfont
  % \sbox0{Forside}%
  % \showthe\ht0
}{%
  \par
  \vspace*{\fill}%
  % \setlength{\showboxdepth}{\maxdimen}%
  % \setlength{\showboxbreadth}{\maxdimen}%
  % \tracingonline=1 %
  % \showlists
}

\DisableLigatures[f]{encoding=T1}

\pagestyle{empty}


\begin{document}

\multido{\i = 1+1}{18}{%
\begin{navn}
  Front
\end{navn}
\newpage}

\end{document}

文件:f2.tex

\documentclass[
  12pt,
  landscape,
  danish
]{article}

\usepackage{babel}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[
  a6paper,
  margin = 1.2cm
]{geometry}
\usepackage{lmodern}
\usepackage[sc]{mathpazo}
\usepackage{mathtools}
\usepackage{microtype}

\newenvironment{navn}{%
  \setlength{\topskip}{0pt}%
  \centering
  \vspace*{\fill}%
  \nointerlineskip
  \LARGE
  % \sbox0{XYZ}%
  % \showthe\ht0
}{%
  \par
  \vspace{\fill}%
  % \setlength{\showboxdepth}{\maxdimen}%
  % \setlength{\showboxbreadth}{\maxdimen}%
  % \tracingonline=1 %
  % \showlists
}

\DisableLigatures[f]{encoding=T1}

\pagestyle{empty}


\begin{document}

\begin{navn}
  A\\[\baselineskip]
  B
\end{navn}
\newpage

\begin{navn}
  C\\[\baselineskip]
  D
\end{navn}
\newpage

\end{document}

文件:f3.tex

\documentclass[
  a4paper
]{article}

\usepackage{pdfpages}

\newcount\maxpages
\newcount\curpage
\newcount\untilpage
\makeatletter
\newif\if@pdfdingsunbalance
\newcount\@testmaxpages
\newcommand{\@incpdfdings}[3]{%
  \includepdf[
    nup = 3x6,
    pages = {#1-#2},
    frame = true
  ]{#3}}
\newcommand{\incpdfdings}[3][]{%
    \ifx\relax#1\relax%
        \pdfximage{#2}%
        \maxpages=\pdflastximagepages%
        \pdfximage{#3}%
        \@testmaxpages=\pdflastximagepages%
        \ifnum\maxpages<\@testmaxpages%
            \@pdfdingsunbalancetrue%
            \def\@pdfdingsmore{#3}%
        \else\ifnum\@testmaxpages<\maxpages%
            \@pdfdingsunbalancetrue%
            \def\@pdfdingsmore{#2}%
            \maxpages=\@testmaxpages%
        \fi\fi%
    \else%
        \maxpages=#1%
    \fi%
    \curpage=0%
    \loop\ifnum\maxpages>\curpage%
        \advance\curpage by 1%
        \untilpage=\numexpr\curpage+17\relax%
        \ifnum\maxpages>\untilpage\else%
            \untilpage=\maxpages%
        \fi%
        \@incpdfdings{\the\curpage}{\the\untilpage}{#2}%
        \@incpdfdings{\the\curpage}{\the\untilpage}{#3}%
        \advance\curpage by 17%
    \repeat%
    \if@pdfdingsunbalance%
        \advance\maxpages by 1%
        \@incpdfdings{\the\maxpages}{}{\@pdfdingsmore}%
    \fi%
}
\makeatother

\begin{document}

\incpdfdings%
{f1.pdf}%
{f2.pdf}

编译以下示例后,将在 中生成三页f3.pdf;它将 中的 18 页放在 的f1.pdf第三页上f3.pdf,然后每当 中的f2.pdf第二页上放置新的页面时,它将第三页中的每一页移动到第一页f3.pdf

问题

我如何从头开始将 中的 18 页f1.pdf移到组装文档的前面,然后从 中移动 18 页,然后再从 中移动 18 页,依此类推?f3.pdff2.pdff1.pdf

也就是说,我希望拥有与pdfpages但 和的f3.pdf输出之间的页面发生了改变。f1.pdff2.pdf

我希望这是有意义的。

答案1

f3.tex应该可以满足您的要求(我希望):

\documentclass[
  a4paper
]{article}

\usepackage{pdfpages}

\newcount\firstmaxpages
\newcount\secondmaxpages
\newcount\curpage
\newcount\untilpage
\makeatletter
\newif\if@pdfdingsSecondFin
\newcommand{\@incpdfdings}[4][]{%
    \includepdf[%
        nup = 3x6,
        pages = {#2-#3},
        #1
    ]{#4}}
\newcommand{\incpdfdings}[3][]{%
    \ifx\relax#1\relax%
        \pdfximage{#2}%
        \firstmaxpages=\pdflastximagepages%
        \pdfximage{#3}%
        \secondmaxpages=\pdflastximagepages%
        \ifnum\firstmaxpages<\secondmaxpages%
            \@latex@error{incpdfdings: Second file has more pages than first}{}
        \fi%
    \else%
        \firstmaxpages=#1%
    \fi%
    \curpage=0%
    \loop\ifnum\firstmaxpages>\curpage%
        \advance\curpage by 1%
        \untilpage=\numexpr\curpage+17\relax%
        \ifnum\untilpage>\firstmaxpages%
            \untilpage=\firstmaxpages%
        \fi%
        \@incpdfdings[frame=true]{\the\curpage}{\the\untilpage}{#2}%
        \ifnum\secondmaxpages>\untilpage\else%
            \untilpage=\secondmaxpages%
        \fi%
        \if@pdfdingsSecondFin\else%
            \@incpdfdings{\the\curpage}{\the\untilpage}{#3}%
        \fi%
        \ifnum\secondmaxpages=\untilpage%
            \@pdfdingsSecondFintrue%
        \fi%
        \advance\curpage by 17%
    \repeat%
}
\makeatother

\begin{document} 
\incpdfdings%
{f1.pdf}%
{f2.pdf}
\end{document}

编辑:对于 2x4 页面:

  • 定义改变\@incpdfdingsnup = 3x6nup = 2x4

  • 在定义中\incpdfdings:将数字的所有 (2) 次出现更改177

nupEDIT2:我稍微改变了一切,所以只要它们遵循方案,您不必为不同的选项进行任何更改<num>x<num>

\documentclass[
  a4paper
]{article}

\usepackage{pdfpages}

\newcount\firstmaxpages
\newcount\secondmaxpages
\newcount\curpage
\newcount\untilpage
\makeatletter
\newif\if@pdfdingsSecondFin
\newcount\@pdfdingsPages
\newcommand{\@incpdfdings}[5][]{%
    \includepdf[%
        nup = #5,
        pages = {#2-#3},
        #1
    ]{#4}}
\newcommand{\@@incpdfdings}{}%
\def\@@incpdfdings#1x#2;{%
    \@pdfdingsPages=#1%
    \multiply\@pdfdingsPages by #2%
    \advance\@pdfdingsPages by -1%
}
\newcommand{\incpdfdings}[4][]{%
    \ifx\relax#1\relax%
        \pdfximage{#3}%
        \firstmaxpages=\pdflastximagepages%
        \pdfximage{#4}%
        \secondmaxpages=\pdflastximagepages%
        \ifnum\firstmaxpages<\secondmaxpages%
            \@latex@error{incpdfdings: Second file has more pages than first}{}%
        \fi%
    \else%
        \firstmaxpages=#1%
    \fi%
    \curpage=0%
    \@@incpdfdings#2;%
    \loop\ifnum\firstmaxpages>\curpage%
        \advance\curpage by 1%
        \untilpage=\numexpr\curpage+\@pdfdingsPages\relax%
        \ifnum\untilpage>\firstmaxpages%
            \untilpage=\firstmaxpages%
        \fi%
        \@incpdfdings[frame=true]{\the\curpage}{\the\untilpage}{#3}{#2}%
        \ifnum\secondmaxpages>\untilpage\else%
            \untilpage=\secondmaxpages%
        \fi%
        \if@pdfdingsSecondFin\else%
            \@incpdfdings{\the\curpage}{\the\untilpage}{#4}{#2}%
        \fi%
        \ifnum\secondmaxpages=\untilpage%
            \@pdfdingsSecondFintrue%
        \fi%
        \advance\curpage by \@pdfdingsPages%
    \repeat%
}
\makeatother

\begin{document} 
\incpdfdings{3x6}%
{f1.pdf}%
{f2.pdf}
\end{document}

现在该命令接受一个指定选项的附加参数nup

相关内容