revtex 和 turnpage:还将 PDF 页面视图旋转 90 度至水平方向

revtex 和 turnpage:还将 PDF 页面视图旋转 90 度至水平方向

在下面的 revtex4 中,我们能否让翻页也旋转 PDF 页面视图 90 度到水平的方向(不仅仅是将内容旋转 90 度,而是保持页面不变垂直的方向)?

\documentclass[aps,pre,superscriptaddress]{revtex4-1}

\begin{turnpage}

\begin{figure} or 
\begin{table}

[...]

\end{figure} or \end{table}

\end{turnpage}

其他类似的功能有:

\usepackage{lscape} 

\begin{landscape} 

\end{landscape} 

答案1

由于评论中似乎存在一些混淆,因此按照我的理解重新表述问题:(revtex44-14-2提供turnpage环境,以横向模式排版内容。但是。PDF 仍然以纵向显示横向页面。您希望此页面不仅以横向模式排版,而且还以相同的方向显示。*

我设法通过从这里获得的一些“魔法代码”实现了这一点:使用 emulateapj 在 ArXiv 上发布横向表格具体来说,相关代码行如下:

[...]
\clearpage
\global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}
[...]

这段代码的结果是这两行之后的页面以横向模式排版,而这两行之前的页面则保持纵向模式。我还没有研究过为什么这个宏确实有效(如果我这样做,我会更新这个答案),但这似乎足以实现问题中提出的目标。特别要注意的是,这\clearpage并不重要——我希望它也能很好地工作——重点是我们可以通过在页面发送之前\pagebreak重新设置宏来设置 PDF 页面的旋转。\pdfpageattr

现在,我查看了环境的定义turnpage\ShowCommand{\turnpage};\endturnpage不执行任何操作),我们有:

\turnpage =
  \def \width@float  {\textheight}
  \def \widthd@float {\textheight}
  \appdef \@endfloatbox
  {
    \@ifxundefined \@currbox
      {\ltxgrid@warn {Cannot rotate! Not a float}}
    {
      \setbox \@currbox \vbox to\textwidth
      {\vfil \unvbox \@currbox \vfil}
      \global\setbox \@currbox \vbox
      { \rotatebox{90}{\box \@currbox} }
    }
  }

其中空格是我的,为了清楚起见。因此,我们知道环境sideways并没有做任何特别的事情,而是设置一个页面大小的浮点数,并添加一些代码来旋转浮点数的内容。(此处,即source2e第 P1 节。)

假设这个浮点数总是会被推到下一页(我不完全确定这个假设有多大,但在实践中它对我来说是有效的**),因此如果我们在下一页\pdfpageattr的开始处正确设置,我们可以让这个浮点数以横向显示,然后在下一页的开始处重置 PDF 方向。

我通过利用 shipout 钩子(即lthooks-docltshipout-doc)实现了这一点:

\appdef \turnpage {%
  % When we're declaring our turnpage float, instruct LaTeX to run
  % the following code after the current page has been finalized.
  \AddToHookNext{shipout/after}{%
    % Set the following page to be rotated by 90 degrees.
    \global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}%
    % Also, once this page is finalized (recalling that this is already
    % being called for the float's page), set the PDF attributes such that
    % the next pages are upright again.
    \AddToHookNext{shipout/after}{%
      \global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 0}%
    }%
  }%
}

我很惊讶它看起来如此强大(在日常意义上,而不是 LaTeX 意义上);它在我的文档中真的一点都没有损坏。重要的是,我将它与table*-- 星号一起使用是根本。否则,即使使用未修改的revtex4,浮动的定位也会完全被破坏。

常见的警告:我绝不是 LaTeX 专家(如果可以说明这一点的话,我从来没有费心去读 TeX 书),因此很多内容都是通过反复试验得出的。希望对 TeX 有更深理解的人可以纠正我推理中的任何错误。

为了清楚起见,下面说明了在实践中如何使用此代码:

\documentclass{revtex4-2}
\usepackage{graphicx} % Necessary to use turnpage!

\appdef \turnpage {%
  % When we're declaring our turnpage float, instruct LaTeX to run
  % the following code after the current page has been finalized.
  \AddToHookNext{shipout/after}{%
    % Set the following page to be rotated by 90 degrees.
    \global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}%
    % Also, once this page is finalized (recalling that this is already
    % being called for the float's page), set the PDF attributes such that
    % the next pages are upright again.
    \AddToHookNext{shipout/after}{%
      \global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 0}%
    }%
  }%
}

\begin{document}

Start of the document...

\begin{turnpage}
\begin{table*}
  \caption{Caption of this table.}
  The contents of the table would go here.
\end{table*}
\end{turnpage}

...rest of the document

\end{document}

在测试时,我发现如果包含环境的页面是文档中唯一的页面,它就会中断。您可以通过尝试在 中使用而不是 来turnpage快速解决这个问题。但是,只要有一些其他内容,它似乎就可以正常工作。shipout/beforeshipout/after\appdef

* 说实话,你的问题对我来说似乎非常清楚。我不确定困惑的根源是什么。

** 我能想到的一个极端情况是,当sideways浮动的位置非常完美,以至于 a\pagebreak已经自然地出现在它之前,因此页面而是sideways旋转了。我不确定这是否真的会发生——通过在\pagebreak浮点数之前插入一个进行测试仍然会产生良好的结果——但如果真的发生了,应该很容易修改我提供的代码来处理这种特定情况。

相关内容