我有一個帶有大 tikz 圖像的文檔。為了使用 pdflatex 顯示此圖像,我建立了巨集來切換紙張大小,並在 pdf 檢視器中顯示時使用該pdflscape
套件來旋轉頁面。使用這種技術,我可以在旋轉的較大尺寸頁面上根據需要顯示圖形,但下一頁在頁腳中缺少頁碼(並且沒有手冊\clearpage
,文本無法正確中斷到下一頁) ,相反,它繼續穿過頁腳並進入遠處看不見的深淵)。在該圖之後的第二頁,頁碼返回。
下面的最小工作範例演示了這種現象:
\documentclass{article}
\usepackage{tikz}
\usepackage{pdflscape}
\usetikzlibrary{shapes}
% Macros for changing paper size
\newcommand{\startPaperSizeB}{%
\begingroup
\clearpage
\setlength{\pdfpagewidth}{11in}
\setlength{\pdfpageheight}{17in}
\setlength{\paperwidth}{\pdfpagewidth}
\setlength{\paperheight}{\pdfpageheight}
\setlength{\oddsidemargin}{0pt}
\setlength{\textwidth}{650pt}
\setlength{\topmargin}{0pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
\setlength{\textheight}{1084pt}
}
\newcommand{\stopPaperSizeB}{\endgroup \clearpage}
\begin{document}
Some text on the first page.
\startPaperSizeB
\begin{landscape}
\begin{figure}
\centering
\begin{tikzpicture}[]
\node [draw, rectangle, minimum height=625pt, minimum width=1000pt] (1) {};
\end{tikzpicture}
\caption{Caption for the large size figure}
\end{figure}
\end{landscape}
\stopPaperSizeB
Missing page number on this page?
\clearpage
Now the page number is back!
\end{document}
我最近問一個非常相似的問題,除了我把這個數字留在了 MWE 之外。這個問題已得到解答,但在較大的橫向頁面上插入時,解決方案不起作用tikzpicture
- 相反,沒有更大的橫向頁面,也沒有圖形 - 它們只是消失了。我收到關於盒子過滿的警告,但沒有數字。下面的 MWE 演示了這一點:
\documentclass{article}
\usepackage{tikz}
\usepackage{pdflscape}
\usetikzlibrary{shapes}
% Macros for changing paper size
\newcommand{\startPaperSizeB}{%
\setlength{\pdfpagewidth}{11in}
\setlength{\pdfpageheight}{17in}
\setlength{\paperwidth}{\pdfpagewidth}
\setlength{\paperheight}{\pdfpageheight}
\setlength{\oddsidemargin}{0pt}
\setlength{\textwidth}{650pt}
\setlength{\topmargin}{0pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
\setlength{\textheight}{1084pt}
}
\newcommand{\stopPaperSizeB}{}
\begin{document}
Some text on the first page.
\begin{landscape}
\startPaperSizeB
\begin{figure}
\centering
\begin{tikzpicture}[]
\node [draw, rectangle, minimum height=625pt, minimum width=1000pt] (1) {};
\end{tikzpicture}
\caption{Caption for the large size figure}
\end{figure}
\stopPaperSizeB
\end{landscape}
The page number is here, but the figure is not.
\end{document}
如果矩形的大小足夠減小(例如,縮小到 525 x 550),則該圖形將出現在文件末尾的頁面上,儘管該頁面是正常尺寸且圖形會超出頁面。這促使我嘗試了套餐[H]
中的選項float
,這似乎讓我更接近了,但我仍然不在那裡。有任何想法嗎?
答案1
我找到了一個可以接受的答案,使用該geometry
包來調整文字區域的大小(該geometry
包本身不允許更改文件中的紙張大小)。設定textwidth
和textheight
使用\newgeometry
命令非常重要(在不使用geometry
套件的情況下設定這些命令會產生奇怪的效果,並且在開始環境之前執行此操作landscape
。此外,\restoregeometry
必須在離開環境後調用landscape
。
下面的範例修復了頁碼問題以及消失的 tikz 數字問題。
\documentclass{article}
\usepackage{tikz}
\usepackage{pdflscape}
\usepackage[papersize={8.5in,11in}]{geometry}
\usepackage{lipsum}
\usetikzlibrary{shapes}
% Macros for changing paper size
\newcommand{\startBSizeLandscape}{%
\newgeometry{textwidth=614pt, textheight=1084pt}
\begin{landscape}
\setlength{\pdfpagewidth}{11in}
\setlength{\pdfpageheight}{17in}
\setlength{\paperwidth}{\pdfpagewidth}
\setlength{\paperheight}{\pdfpageheight}
\setlength{\oddsidemargin}{0pt}
\setlength{\evensidemargin}{0pt}
\setlength{\marginparwidth}{0pt}
\setlength{\topmargin}{0pt}
\setlength{\headheight}{0pt}
\setlength{\headsep}{0pt}
}
\newcommand{\stopBSizeLandscape}{%
\end{landscape}
\restoregeometry
}
\begin{document}
\lipsum
\startBSizeLandscape
\begin{figure}
\centering
\begin{tikzpicture}[]
\node [draw, rectangle, minimum height=589pt, minimum width=1000pt] {};
\end{tikzpicture}
\caption{Caption for the large size figure}
\end{figure}
\stopBSizeLandscape
\lipsum
\end{document}
編譯它確實會產生警告: 'tmargin' and 'bmargin' result in NEGATIVE (-289.03001pt). 'height' should be shortened in length.
當然,減小文字高度確實可以防止此警告,但會產生一個過滿的框警告。更好的解決方案是不發出警告。