當浮子太高時的視覺指示器

當浮子太高時的視覺指示器

在草稿模式下,如果文字無法換行並且延伸到邊距(過滿的水平盒),LaTeX 會列印黑色標記。如果浮動對於頁面來說太高並延伸到頁腳區域,是否可以有類似的視覺指示器?

答案1

LaTeX 在日誌中發出警告,你可以讓它同時列印一些內容:

在此輸入影像描述

\documentclass{article}

\usepackage{color}
\makeatletter


\def \@largefloatcheck{%
  \ifdim \ht\@currbox>\textheight
    \@tempdima -\textheight
    \advance \@tempdima \ht\@currbox
    \@latex@warning {Float too large for page by \the\@tempdima}%
    \global\setbox\@currbox\hbox{%
      \box\@currbox
      {\color{red}\smash{\llap{FLOAT TOO BIG}}\vrule width 5pt}}%
    \ht\@currbox \textheight
  \fi
}

\makeatother
\begin{document}


\begin{figure}

\rule{2cm}{19cm}
\caption{a figure}
\end{figure}

\end{document}

請注意,\smash添加此處是為了解決註釋中提出的問題,即原始程式碼可能會針對某些字體循環。如果沒有,\smash我假設大寫文字FLOAT TOO BIG沒有深度,但某些字體的字體規格確實給大寫字母非零深度。

答案2

溢位規則僅適用於水平框。

如果正文區域周圍有一個框,則也可以更容易看到頁腳區域的違規行為。套件geometry如果與選項一起使用,則用框標記頁面佈局showframe。如果geometry不以其他方式使用,選項pass通知geometry不要觸摸佈局參數:

\usepackage[pass, showframe]{geometry}

相關內容