尋找程式碼中錯誤位置的問題

尋找程式碼中錯誤位置的問題

編譯文件時收到以下警告:

`h' float specifier changed to `ht'.

The float specifier 'h' is too strict of a demand for LaTeX to place your float in a nice way here. Try relaxing it by using 'ht', or even 'htbp' if necessary. If you want to try keep the float here anyway, check out the float package.
Learn more

但它沒有告訴我一條線。通常它會說明程式碼中的哪一行導致了問題,因此我可以修復它,但不確定如何在此處執行此操作,除非將每個數字從 [H] 更改為 [HT] 直到找到它。有任何想法嗎?謝謝

答案1

在這種情況下(不僅僅是對於浮動),有一種暴力方法。我用它所有的時間。

在您的文件中,使用\typeout{message}命令將某些內容寫入日誌檔案。然後,您可以透過讀取日誌來追蹤處理過程中發生的情況。如果您透過命令列進行編譯,您的訊息可能就在您遇到警告(或錯誤)的位置之上。如有必要,用於%結束額外的行。

例子:

... and they lived happily ever after.
\typeout{next: image of castle}%
\includegraphics{castle.png}
But that was long ago and far away. Since then...

相關內容