我正在实现扫描文档的图库,但在使用 \figure + \includegraphics 时遇到问题,请参见下面的屏幕截图:
1) [紫色注释] 当前图片的标题和下一张图片的标题(通常,参见下面的问题)相互重叠
2) [紫色注释] 当前图片的标题和后面图片之间的空间是不可预测的 - 在大多数情况下,标题和后面的图片是粘在一起的,但有时会插入额外的行(这是每张图片的预期行为)
3)[蓝色评论] 这张图片和标题之间的间距太大
4)[红色注释] 尽管还有足够的空间,但页面中间却插入了意外的分页符 - 这个问题确实很严重
完整代码:
\documentclass[a4paper]{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{czech}
\usepackage{ulem}
\usepackage{spverbatim}
\usepackage[unicode]{hyperref}
\def\do#1{\appto\UrlSpecials{\do#1{\mathchar`#1 \mskip 0mu plus 1mu\penalty100\relax}}}
\do\-\do\/\do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X\do\Y\do\Z
\usepackage[]{graphicx}
\usepackage{grffile}
\usepackage{color}
\usepackage{wrapfig}
\usepackage{float}
\usepackage[section]{placeins}
\usepackage{hologo}
\usepackage{pdfpages}
\usepackage{needspace}
\intextsep=0pt
\DeclareTextFontCommand{\mytexttt}{\ttfamily\hyphenchar\font=45\relax}
\makeatletter
\renewcommand{\l@section}{\@dottedtocline{1}{1.5em}{2.6em}}
\renewcommand{\l@subsection}{\@dottedtocline{2}{4.0em}{3.6em}}
\renewcommand{\l@subsubsection}{\@dottedtocline{3}{7.4em}{4.8em}}
\setlength{\@fptop}{0pt}
\setlength{\@fpbot}{0pt plus 1fil}
\makeatother
\begin{document}
\phantomsection\label{ID_FIL_DISPLAY_DOC_507}
\begin{figure}[htp]
\centering
\rule{\textwidth}{0.231\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_507]{Dokument~508}}
\end{figure}
\FloatBarrier % Prevents error Too many unprocessed floats
\phantomsection\label{ID_FIL_DISPLAY_DOC_508}
\begin{figure}[htp]
\centering
\rule{\textwidth}{0.089\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_508]{Dokument~509}}
\end{figure}
\FloatBarrier % Prevents error Too many unprocessed floats
\phantomsection\label{ID_FIL_DISPLAY_DOC_509}
\begin{figure}[htp]
\centering
\rule{\textwidth}{0.105\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_509]{Dokument~510}}
\end{figure}
\FloatBarrier % Prevents error Too many unprocessed floats
\phantomsection\label{ID_FIL_DISPLAY_DOC_510}
\begin{figure}[htp]
\centering
\rule{\textwidth}{0.059\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_510]{Dokument~511}}
\end{figure}
\FloatBarrier % Prevents error Too many unprocessed floats
\phantomsection\label{ID_FIL_DISPLAY_DOC_511}
\begin{figure}[htp]
\centering
\rule{\textwidth}{0.264\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_511]{Dokument~512}}
\end{figure}
\FloatBarrier % Prevents error Too many unprocessed floats
\phantomsection\label{ID_FIL_DISPLAY_DOC_512}
\begin{figure}[htp]
\centering
\rule{\textwidth}{0.154\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_512]{Dokument~513}}
\end{figure}
\FloatBarrier % Prevents error Too many unprocessed floats
\phantomsection\label{ID_FIL_DISPLAY_DOC_513}
\begin{figure}[htp]
\centering
\rule{\textwidth}{0.329\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_513]{Dokument~514}}
\end{figure}
\FloatBarrier % Prevents error Too many unprocessed floats
\end{document}
你能帮我找到解决方案吗
1)如何强制标题和后面的图像之间的空间?
2)如何强制标题和后面的图像之间的间距始终相同?
3)如何减少图像和其标题之间的空间(我的文档中有数千张图像,约 4000 页,因为最后它会被打印到纸上,所以从文档中删除的每一页都是有用的)?
4)如何修复页面中间不需要的分页符(当然,图像或标题都不能溢出文本区域下方,但我希望如果图像+标题适合的话,页面上的整个空间都会被使用)?
也许 \figure + \includegraphics 对于图像库来说并不方便?
答案1
当您有图像列表而没有文本时,您就不需要浮动,因此您不应该使用figure
,或者使用[H]
来抑制浮动。
\documentclass[a4paper]{book}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{czech}
\usepackage{ulem}
\usepackage{spverbatim}
\usepackage[unicode]{hyperref}
\def\do#1{\appto\UrlSpecials{\do#1{\mathchar`#1 \mskip 0mu plus 1mu\penalty100\relax}}}
\do\-\do\/\do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9\do\a\do\b\do\c\do\d\do\e\do\f\do\g\do\h\do\i\do\j\do\k\do\l\do\m\do\n\do\o\do\p\do\q\do\r\do\s\do\t\do\u\do\v\do\w\do\x\do\y\do\z\do\A\do\B\do\C\do\D\do\E\do\F\do\G\do\H\do\I\do\J\do\K\do\L\do\M\do\N\do\O\do\P\do\Q\do\R\do\S\do\T\do\U\do\V\do\W\do\X\do\Y\do\Z
\usepackage[]{graphicx}
\usepackage{grffile}
\usepackage{color}
\usepackage{wrapfig}
\usepackage{float}
\usepackage[section]{placeins}
\usepackage{hologo}
\usepackage{pdfpages}
\usepackage{needspace}
%\intextsep=0pt
\DeclareTextFontCommand{\mytexttt}{\ttfamily\hyphenchar\font=45\relax}
\makeatletter
\renewcommand{\l@section}{\@dottedtocline{1}{1.5em}{2.6em}}
\renewcommand{\l@subsection}{\@dottedtocline{2}{4.0em}{3.6em}}
\renewcommand{\l@subsubsection}{\@dottedtocline{3}{7.4em}{4.8em}}
\makeatother
\begin{document}
\raggedbottom
\phantomsection\label{ID_FIL_DISPLAY_DOC_507}
\begin{figure}[H]
\centering
\rule{\textwidth}{0.231\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_507]{Dokument~508}}
\end{figure}
\phantomsection\label{ID_FIL_DISPLAY_DOC_508}
\begin{figure}[H]
\centering
\rule{\textwidth}{0.089\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_508]{Dokument~509}}
\end{figure}
\phantomsection\label{ID_FIL_DISPLAY_DOC_509}
\begin{figure}[H]
\centering
\rule{\textwidth}{0.105\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_509]{Dokument~510}}
\end{figure}
\phantomsection\label{ID_FIL_DISPLAY_DOC_510}
\begin{figure}[H]
\centering
\rule{\textwidth}{0.059\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_510]{Dokument~511}}
\end{figure}
\phantomsection\label{ID_FIL_DISPLAY_DOC_511}
\begin{figure}[H]
\centering
\rule{\textwidth}{0.264\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_511]{Dokument~512}}
\end{figure}
\phantomsection\label{ID_FIL_DISPLAY_DOC_512}
\begin{figure}[H]
\centering
\rule{\textwidth}{0.154\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_512]{Dokument~513}}
\end{figure}
\phantomsection\label{ID_FIL_DISPLAY_DOC_513}
\begin{figure}[H]
\centering
\rule{\textwidth}{0.329\textwidth}
\caption{\hyperref[ID_FIL_USAGELIST_DOC_513]{Dokument~514}}
\end{figure}
\end{document}