如何在讲义(handoutWithNotes)中添加页码或页眉?

如何在讲义(handoutWithNotes)中添加页码或页眉?

我一直在尝试使用 Guido 的风格化讲义beamerhandoutWithNotes我现在有的只是 4 个带框的讲义,但我想将页码放在讲义页面的底部,并将页眉放在顶部。

以下是一些简单的例子:

\documentclass[12pt,xcolor=pdftex,dvipsnames,handout]{beamer}
\usetheme{Darmstadt}  

\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}
\usepackage[portuges,brazil]{babel}
\newcommand{\Autor}{Arthur Alvim}
\newcounter{countpag}
\setcounter{countpag}{0}
\title{Title}
\author{Author}
\date{\today}
%%%% Handouts
\usepackage{pgfpages}
% \usepackage{handoutWithNotes}
\include{style4x}
\pgfpagesuselayout{4 on 1 with notes}[a4paper,border shrink=5mm]

\begin{document}
\begin{frame}[plain]
  \titlepage
\end{frame}

\section{First section}
\subsection{First subsection}
\begin{frame}{First frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\begin{frame}{Second frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\subsection{Second subsection}
\begin{frame}{Third frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\begin{frame}{Fourth frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\section{Second section}
\subsection{First subsection}
\begin{frame}{First frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\begin{frame}{Second frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\subsection{Second subsection}
\begin{frame}{Third frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\begin{frame}{Fourth frame}
    \begin{block}{First Block}
        First Block
    \end{block}
    \begin{block}{Second Block}
        Second Block
    \end{block}
    \begin{block}{Third Block}
        Third Block
    \end{block}
\end{frame}
\end{document}

\include{style4x}是我提取的包内代码的一部分handoutWithNotes。如下所示:

   \pgfpagesdeclarelayout{4 on 1 with notes}{
       \edef\pgfpageoptionheight{\the\paperheight}
       \edef\pgfpageoptionwidth{\the\paperwidth}
       \edef\pgfpageoptionborder{0pt}
   }
   {
   \pgfpagesphysicalpageoptions{%
       logical pages=8,%
       physical height=\pgfpageoptionheight,%
       physical width=\pgfpageoptionwidth,%
       %last logical shipout=3%
       last logical shipout=4%
   }
   \pgfpageslogicalpageoptions{1}{%
       scale=.70,
       center=\pgfpoint{.25\pgfphysicalwidth}{.875\pgfphysicalheight}%
   }%
   \pgfpageslogicalpageoptions{2}{%
       scale=.70,
       center=\pgfpoint{.25\pgfphysicalwidth}{.625\pgfphysicalheight}%
   }%
   \pgfpageslogicalpageoptions{3}{%
       scale=.70,
       center=\pgfpoint{.25\pgfphysicalwidth}{.375\pgfphysicalheight}%
   }%
   \pgfpageslogicalpageoptions{4}{%
       scale=.70,
       center=\pgfpoint{.25\pgfphysicalwidth}{.125\pgfphysicalheight}%
   }%
   \pgfpageslogicalpageoptions{5}{%
       border shrink=\pgfpageoptionborder,%
       resized width=.5\pgfphysicalwidth,%
       resized height=.3333\pgfphysicalheight,%
       center=\pgfpoint{.75\pgfphysicalwidth}{.875\pgfphysicalheight},%
       copy from=5
   }%
   \pgfpageslogicalpageoptions{6}{%
       border shrink=\pgfpageoptionborder,%
       resized width=.5\pgfphysicalwidth,%
       resized height=.3333\pgfphysicalheight,%
       center=\pgfpoint{.75\pgfphysicalwidth}{.625\pgfphysicalheight},%
       copy from=6
   }%
   \pgfpageslogicalpageoptions{7}{%
       border shrink=\pgfpageoptionborder,%
       resized width=.5\pgfphysicalwidth,%
       resized height=.3333\pgfphysicalheight,%
       center=\pgfpoint{.75\pgfphysicalwidth}{.375\pgfphysicalheight},%
       copy from=7
   }%
   \pgfpageslogicalpageoptions{8}{%
       border shrink=\pgfpageoptionborder,%
       resized width=.5\pgfphysicalwidth,%
       resized height=.3333\pgfphysicalheight,%
       center=\pgfpoint{.75\pgfphysicalwidth}{.125\pgfphysicalheight},%
       copy from=8
   }%
   \AtBeginDocument{
       \newbox\notesbox
       \setbox\notesbox=\vbox{
           \hsize=\paperwidth
           \vskip-1in\hskip-1in\vbox{
               \color{black}{
                   \vskip1cm
                   Notes:\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth
               }
           }
       }
       \newbox\notesboxInitial
       \setbox\notesboxInitial=\vbox{
           \hsize=\paperwidth
           \vskip-1in\hskip-1in\vbox{
               \color{black}{
                   \vskip1cm
                   \centering{\Large{\textbf{\Autor => the rest do not appear \title - \author}}}
                   \vskip1cm
                   Notes:\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
               }
           }
       }
       \newbox\notesboxFinal
       \setbox\notesboxFinal=\vbox{
           \hsize=\paperwidth
           \vskip-1in\hskip-1in\vbox{
               \color{black}{
                   \vskip1cm
                   Notes:\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \hrule width\paperwidth\vskip1cm
                   \thepage \hfill -> do not increment \stepcounter{countpag} Page\arabic{countpag} 
               }
           }
       }
     \pgfpagesshipoutlogicalpage{5}\copy\notesboxInitial
     \pgfpagesshipoutlogicalpage{6}\copy\notesbox
     \pgfpagesshipoutlogicalpage{7}\copy\notesbox
     \pgfpagesshipoutlogicalpage{8}\copy\notesboxFinal
   }
}

我尝试了所有这些变量 -> ( \thepage\insertpagenumber\insertframenumber\insertpresentationendpage和 created countpag),但它们却没有改变。我认为这是我使用的变量范围的问题。那么,伙计们,我们该怎么做才能让这些变量增加呢?

答案1

这是一个“概念证明”。它需要完善并适应您想要的特定情况。我在未完善的阶段发布它,看看是否有人在花时间完善之前对如何改进它有任何建议 - 因为如果这是完全错误的方法,那么提前知道这一点会很好!

它通过在 pgfpages 布局中定义一个“额外”页面来实现。这实际上与“带注释”部分的工作方式相同。此页面位于所有其他页面的顶部(将其放在它们后面也很容易,但我第一次尝试将其放在前面,因为这样对我的模板代码的更改较少),除了页眉和页脚外,其余部分都是空白的。这有点笨拙的地方是页眉和页脚的构造方式。可以通过仅提供一个框来以这种方式指定“额外”页面,但是每次发货时都会丢弃该框,因此我们需要再次构造它。我们可以将它从一个复制到另一个,但这是一个文字复制,不允许我们再次更改它(无需解构和重构,但我宁愿不这样做!)。所以我们将它设为一个空框,并利用 pgfpages 允许我们为页面的“边框”指定一些代码这一事实。这可以是任意的 pgf 代码,因此我们丢弃边框,然后插入一些节点。我对尺寸做了一些猜测,但这是一个需要改进的地方。

我认为,这种“逐字复制”就是您尝试的问题的根源(如果我没有看错的话)。方框\notesboxInitial等设置在文档的开头,不要换之后,即使你更改了其中出现的命令,它们也会被删除。这是因为它们已经被 TeX 处理过,并且所有命令都已展开。

为这些节点(页眉和页脚)获取正确的内容也有点复杂。最好的方法是以某种方式从内页复制页眉和页脚,但弄清楚到底要复制什么可能很复杂。可能,应该挂接到命令,例如\section并保存参数以供以后插入,或者使用诸如\insertframetitle或任何你想要的东西。同样,这是为了以后完善。

代码如下:

\documentclass{article}

\pagestyle{empty}
\usepackage{lipsum}
\usepackage{pgf}
\usepackage{pgfpages}

\pgfpagesdeclarelayout{2 on 1 with header}
{
  \edef\pgfpageoptionheight{\the\paperwidth} % landscaped by default
  \edef\pgfpageoptionwidth{\the\paperheight}
  \def\pgfpageoptionborder{0pt}
  \def\pgfpageoptionfirstshipout{1}
}
{
  \pgfpagesphysicalpageoptions
  {%
    logical pages=3,%
    last logical shipout=2,
    physical height=\pgfpageoptionheight,%
    physical width=\pgfpageoptionwidth,%
    current logical shipout=\pgfpageoptionfirstshipout%
  }
  \ifdim\paperheight>\paperwidth\relax
    % put side-by-side
    \pgfpageslogicalpageoptions{1}
    {%
      border shrink=\pgfpageoptionborder,%
      resized width=.5\pgfphysicalwidth,%
      resized height=\pgfphysicalheight,%
      center=\pgfpoint{.25\pgfphysicalwidth}{.5\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{2}
    {%
      border shrink=\pgfpageoptionborder,%
      resized width=.5\pgfphysicalwidth,%
      resized height=\pgfphysicalheight,%
      center=\pgfpoint{.75\pgfphysicalwidth}{.5\pgfphysicalheight}%
    }%
  \else
    % stack on top of one another
    \pgfpageslogicalpageoptions{1}
    {%
      border shrink=\pgfpageoptionborder,%
      resized width=\pgfphysicalwidth,%
      resized height=.5\pgfphysicalheight,%
      center=\pgfpoint{.5\pgfphysicalwidth}{.75\pgfphysicalheight}%
    }%
    \pgfpageslogicalpageoptions{2}
    {%
      border shrink=\pgfpageoptionborder,%
      resized width=\pgfphysicalwidth,%
      resized height=.5\pgfphysicalheight,%
      center=\pgfpoint{.5\pgfphysicalwidth}{.25\pgfphysicalheight}%
    }%
  \fi
    \pgfpageslogicalpageoptions{3}
    {%
      resized width=\pgfphysicalheight,%
      resized height=\pgfphysicalwidth,%
      center=\pgfpoint{.5\pgfphysicalheight}{.5\pgfphysicalwidth},%
      border code={\setheaders},
      copy from=3,%
    }%
}
\pgfpagesuselayout{2 on 1 with header}

\newcounter{physpage}
\setcounter{physpage}{0}
\def\setheaders{%
\pgfusepath{discard}
\stepcounter{physpage}
\pgftransformshift{\pgfpoint{0pt}{\pgfphysicalheight - (1in + \voffset + \topmargin)}}
\pgfscope
\pgftransformshift{\pgfpoint{.7 * (1in + \hoffset + \oddsidemargin + \marginparsep)}{0pt}}
\pgfnode{rectangle}{north west}{Section}{}{}
\endpgfscope
\pgfscope
\pgftransformshift{\pgfpoint{.5\pgfphysicalwidth}{.7*(-\headheight -\headsep -\textheight - \footskip)}}
\pgfnode{rectangle}{south}{Page \thephyspage}{}{}
\endpgfscope
}
\pgfpagesshipoutlogicalpage{3}\vbox{}%


\begin{document}
\section {Introduction}
\lipsum
\section {Main Part}
\lipsum
\section {Conclusion}
\lipsum
\end{document}

这是第二页的样子,显示页码是正确的!

带背景页面的 pgfpages

相关内容