ミニページ 15.0pt 幅が広すぎます

ミニページ 15.0pt 幅が広すぎます

2 つ (またはそれ以上) の図環境を 1 ページにレイアウトし、中央に水平線を配置したい場合があります。これを実現するには、2 つの環境の間に \vfill\hrule\vfill を配置します。ただし、これは、ページのテキスト領域全体にまたがるミニページを作成する場合にのみ機能します。

ただし、これを行うと、ドキュメント クラスに応じて hbox または vbox のオーバーフローが発生します。article の場合は 15pt の hbox オーバーフロー、phdthesis (Web から取得したクラス) の場合は 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}

2 番目のミニページではそのような警告は表示されませんが、幅から 15pt を減算する必要がありました。この 15pt はどこから来るのでしょうか? \textwidth がテキスト領域の幅よりも広いのはなぜでしょうか?

答え1

これはデフォルトのインデントです。LaTeX に関する限り、a はminipage大きな文字と同じです。したがって、\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}

関連情報