
在下面的 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
按照我的理解重述這個問題,因為評論中似乎存在一些混亂:revtex4
(4-1
和4-2
) 提供turnpage
環境,以橫向模式排版內容。然而。 PDF 仍以縱向顯示橫向頁面。您希望此頁面不僅以橫向模式排版,而且還以相同的方向顯示。
我通過從這裡獲得的一些“神奇代碼”成功地實現了這一點:在 ArXiv 上使用 emulateapj 發布面向景觀的表。具體來說,相關程式碼行如下:
[...]
\clearpage
\global\pdfpageattr\expandafter{\the\pdfpageattr/Rotate 90}
[...]
此程式碼導致這兩行之後的頁面以橫向模式排版,而將這兩行之前的頁面保留為縱向模式。我還沒研究過為什麼這個巨集完全有效(如果我這樣做,我會更新這個答案),但這似乎足以實現問題中所述的目標。特別要注意的是,這\clearpage
並不重要——我希望它\pagebreak
也能工作——重點是我們可以透過\pdfpageattr
在頁面發出之前重新設定巨集來設定 PDF 頁面的旋轉。
現在,我查看了環境的定義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方向。
我透過利用發貨掛鉤(即lthooks-doc
和ltshipout-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/before
shipout/after
\appdef
* 老實說,你的問題對我來說似乎非常清楚。我不確定混亂的根源。
** 我能想到的一個邊緣情況是,當浮動sideways
完美放置時,a\pagebreak
已經自然地出現在它之前,因此頁面後而是旋轉sideways
。我不確定這是否真的會發生——通過在\pagebreak
浮點之前插入 a 來測試它仍然會產生良好的結果——但是修改我提供的用於處理特定情況的代碼應該很容易,如果有的話發生。