
我正在使用pdflatex
PDF 圖像作為圖形。當我不縮放圖像時,圖形就會脫離頁面。當我縮放圖像時,它的位置非常糟糕。離頁面右側有點遠。我知道有些事情不正確,因為不僅位置看起來很糟糕,而且當我在浮動周圍放置框架時,框架會穿過圖像。
這是一個最小的工作範例。我不知道如何在此處包含 PDF 圖像。此影像是橫向長影像,不是標準尺寸。我想這可能是問題所在?人們如何處理這個問題?
\documentclass{article}
\usepackage{graphicx}
\usepackage{float}
\begin{document}
\section{Section Title}
\begin{figure}[h]
\caption{Blah blah}
\includegraphics[scale=.4]{Graph.pdf}
\end{figure}
\end{document}
答案1
使用scale
, 會導致很多問題,特別是當您有不同寬高比的圖像時,請使用 和 來限制圖像的大小,width
如下height
所示:
\includegraphics[width=\textwidth, height=\textheight, keepaspectratio]{Graph.pdf}
影像將被縮放,以免超過兩個限制中的任何一個,並保持正確的縱橫比。
您也可以使用實際尺寸來代替\textwidth
或\textheight
以及諸如 之類的值0.7\textwidth
。
textwidth
只是簡短地解釋為什麼同時包含 a和 a總是好的textheight
。浮動的數量和它們在頁面上佔據的垂直空間量由許多參數控制。例如,topfraction
控制可以被 佔據的頁面的頂部部分top float
。在我看來,預設設定設定得太低,最終導致相對較小的圖像佔據整個頁面。
嘗試下面的最小方法。然後更改\topfraction
為0.6並重試。從兩頁看起來很漂亮的頁面開始,你將以大量的空白和三頁結束。
\documentclass[crown]{octavo}
\usepackage[showframe=true]{geometry}
\usepackage{graphicx,lipsum,caption}
\renewcommand{\topfraction}{0.9} % max fraction of floats at top change to 0.6
\renewcommand{\bottomfraction}{0.9}% max fraction of floats at bottom
% Parameters for TEXT pages (not float pages):
\setcounter{topnumber}{2}
\setcounter{bottomnumber}{2}
\setcounter{totalnumber}{4} % 2 may work better
\setcounter{dbltopnumber}{2} % for 2-column pages
\renewcommand{\dbltopfraction}{0.7} % fit big float above 2-col. text
\renewcommand{\textfraction}{0.07} % allow minimal text w. figs
% Parameters for FLOAT pages
\renewcommand{\floatpagefraction}{0.7}
% floatpagefraction must be less than topfraction !!
\renewcommand{\dblfloatpagefraction}{0.7}
\begin{document}%
First page image will go to next page, if topfraction is less than 0.71
\begin{figure}[tp]
\rule{\textwidth}{0.71\textheight}
\captionof{figure}{First Figure}
\end{figure}
\lipsum[1]
\begin{figure}[tp]
\rule{\textwidth}{0.3\textheight}
\captionof{figure}{Second Figure}
\end{figure}
\end{document}
第二個原因在規格中包含高度更明顯,是為了避免導致底部溢出,就像我設定的下圖一樣width=\textwidth
。這種情況非常明顯,但如果您的數字或多或少是方形的,這可能會讓您絆倒。
對於包含大量圖形的書籍,最佳策略是標準化多個圖像尺寸並仔細設定所有參數。
答案2
你有沒有嘗試過使用\centering
\begin{figure}[h]
\centering
\caption{Blah blah}
\includegraphics[scale=.4]{Graph.pdf}
\end{figure}
答案3
下面的程式碼可讓您將圖像縮放到文字區塊的整個寬度(這是在圖像不向左、向右或兩側突出的情況下可以獲得的最大寬度):
\begin{figure}[ht]
\includegraphics[width=\textwidth]{Graph.pdf}
\caption{Blah blah} \label{fig:blahblah}
\end{figure}
如果文字區塊的寬度不足以正確顯示圖像,您可以嘗試將整個figure
浮動旋轉 90 度(紙上的「肖像模式」)。為此,您可以使用套件sidewaysfigure
提供的環境rotating
。您可以輸入\usepackage{rotating}
序言,然後再輸入
\begin{sidewaysfigure}
\includegraphics[width=\textwidth]{Graph.pdf}
\caption{Blah blah} \label{fig:blahblah}
\end{sidewaysfigure}
橫向圖形會自動放置在單獨的頁面上,因此無需新增[h]
或[ht]
位置說明符。