迷你頁 15.0pt 太寬

迷你頁 15.0pt 太寬

有時我有兩個(或更多)圖形環境,我想將它們佈局在一頁上,並在中心放置一條水平線。為了實現這一點,我在兩個環境之間放置了一個 \vfill\hrule\vfill 。但是,只有當我建立一個跨越頁面整個文字區域的小型頁面時,這才有效。

但是,如果我這樣做,我會得到水平盒或垂直盒溢出,這取決於文件​​類。對於文章來說,它是一個 15pt 的 hbox 溢出,對於 phdthesis(我從網上抓取的一個 cls),它也是一個 15pt 的 vbox 溢出。

這是一個最小的工作範例:

\documentclass{article}
\newlength{\minipagewidth}
\newlength{\minipageheight}

\begin{document}%
%results in:  Badbox, line 9: Overfull \hbox (15.0pt too wide) in paragraph at lines 9-26
\setlength{\minipagewidth}{\textwidth}%
\setlength{\minipageheight}{\textheight}%
\begin{minipage}[t][\minipageheight]{\minipagewidth}%
Top of the page

\vfill\hrule\vfill

Bottom of the page
\end{minipage}
% no vbox or hbox overflow:
\addtolength{\minipagewidth}{-15pt}%
%\addtolength{\minipageheight}{-15pt}%
\begin{minipage}[t][\minipageheight]{\minipagewidth}%
Top of the page

\vfill\hrule\vfill

Bottom of the page
\end{minipage}%
\end{document}

第二個迷你頁沒有出現這樣的警告,但我必須從寬度中減去 15pt。這15pt從哪裡來?為什麼 \textwidth 比文字區域的寬度寬?

答案1

這是預設縮排。對 LaTeX 來說,aminipage就像一個大字母。因此\begin{minipage}開始一個段落,如果還沒有在一個段落中的話。

\noindent\begin{minipage}{\textwidth}

解決了這個問題。

關於身高,我不確定你真正想要達到的目標是什麼。

對於整頁浮動,你可以這樣做

\documentclass{article}
\usepackage{graphicx}
\usepackage{lipsum} % just for the example

\begin{document}

\lipsum[1-3]

\begin{figure}[p]
\centering
\begin{minipage}[c][\dimexpr\textheight-\baselineskip+\topskip\relax][s]{\textwidth}
\centering

\includegraphics[width=8cm]{example-image-a}

\caption{A caption to the first figure}

\vfill
\hrule
\vfill

\includegraphics[width=8cm]{example-image-b}

\caption{A caption to the second figure}

\end{minipage}

\end{figure}

\lipsum[4-10]

\end{document}

相關內容