=======================================================
-> 更新 <-
经过半天的反复试验,可以肯定地说,这是由于
“著名”的错误Error: Float(s) lost
。
我一直在这个网站上阅读,但似乎仅有的方法是把它从mini-figure
东西里拿出来。目前没有其他有用的办法。
=======================================================
代码:
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath,amsthm,enumerate}
\usepackage{graphicx,subfigure}% for pictures
\graphicspath{{Pictures/}} % Specifies the directory where pictures are stored
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example and Solution
\usepackage[most]{tcolorbox}
\NewTColorBox[auto counter, number within=section]{example}{+O{}}{%
enhanced,
breakable,
coltitle=black,
fonttitle=\bfseries,
title={Example~\thetcbcounter:},
attach title to upper=\quad,
before lower={\textbf{Solution~\thetcbcounter:\quad}},
%lowerbox=invisible,
bicolor,
colback=black!5!white,
colbacklower=black!3!white,
#1}
%\tcbset{student/.style={lowerbox=invisible}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pdfoptionpdfminorversion 6
\begin{document}
\begin{example}
Figure~\ref{fig:conti_pdf_cdf} gives the probability density function $f(x)$ and its cumulative function $F(x)$.
\begin{figure}[!hp]
\centering
\subfigure[$f(x)$]{\includegraphics[scale=0.6]{15-1.pdf}} %1.5 version
\\[2ex]
\subfigure[$F(x)$]{\includegraphics[scale=0.6]{15-2.pdf}}
\caption{Illustration of $f(x)$ and $F(x)$ for a (continuous) piecewise function}
\label{fig:conti_pdf_cdf}
\end{figure}
\tcblower
Figure~\ref{fig:conti_pdf_cdf} gives the probability density function $f(x)$ and its cumulative function $F(x)$.
\begin{figure}[!hp]
\centering
\subfigure[$f(x)$]{\includegraphics[scale=0.6]{14-1.pdf}} %1.4 version
\\[2ex]
\subfigure[$F(x)$]{\includegraphics[scale=0.6]{14-2.pdf}}
\caption{Illustration of $f(x)$ and $F(x)$ for a (continuous) piecewise function}
\label{fig:conti_pdf_cdf}
\end{figure}
\begin{center}
\includegraphics[scale=0.4]{chap3_eg1.pdf} % 1.4 version
\end{center}
\end{example}
\end{document}
如果我在不使用环境的情况下编译它example
,它可以正常工作。
如果我随后添加example
环境,它不会编译(1.4 或 1.5 版 PDF 没有图表)。忽略警告,{chap3_eg1.pdf}
最终 PDF 中只会显示。
是否有任何特定的东西(在 PDF 中)导致 latex 无法编译 PDF?1.4 和 1.5 版本都是文件same
。我使用 Acrobat 在版本之间进行转换。
那么有什么解决办法吗?
=======================================================
旧帖
抱歉,标题太乱了。我会尽量写得简单一点。
首先,我试图实现此解决方案(见评论)。所以我用
\NewTColorBox[auto counter]{exercise}{+O{}}{%
enhanced, breakable,
coltitle=black,
fonttitle=\bfseries,
title={Exercise~\thetcbcounter:},
attach title to upper=\quad,
before lower={\textbf{Solution~\thetcbcounter:\quad}},
#1}
我收到一个错误。
! pdfTeX error (setup): \pdfminorversion cannot be changed after data is written to the PDF file.
没有生成 PDF 文件。我生成后一切正常
% \pdfoptionpdfminorversion 6
使用不同的.tex
文件时,我收到此错误,但我找到了丢失的 PDF(版本 1.5)
! LaTeX Error: Float(s) lost.
它们被编码使用
\begin{figure}[!hp]
\centering
\subfigure[$f(x)$]{\includegraphics[scale=0.6]{chap3_eg3_den.pdf}}
\\[2ex]
\subfigure[$F(x)$]{\includegraphics[scale=0.6]{chap3_eg3_cum.pdf}}
\caption{Illustration of $f(x)$ and $F(x)$ for a (continuous) piecewise function}
\label{fig:conti_pdf_cdf}
\end{figure}
做了一些研究,说与数字中的数字有关\marginpar
。但是看我的代码,我不认为这是这种情况。
我有其他 PDF(也是 1.5),运行良好。
我想我真正的问题是——是什么原因造成的?
那packages
?那Floats
(子图)?或者那PDFVersion
东西??
答案1
定义一个非浮动版本并不困难figure
。
在代码中我将其改为subfigure
(已弃用约 15 年)subfig
并因此\subfigure
改为\subfloat
。
\documentclass[12pt,a4paper]{report}
\usepackage{amsmath,amsthm,enumerate}
\usepackage{graphicx,subfig}% for pictures
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example and Solution
\usepackage[most]{tcolorbox}
\NewTColorBox[auto counter, number within=section]{example}{+O{}}{%
enhanced,
breakable,
coltitle=black,
fonttitle=\bfseries,
title={Example~\thetcbcounter:},
attach title to upper=\quad,
before lower={\textbf{Solution~\thetcbcounter:\quad}},
%lowerbox=invisible,
bicolor,
colback=black!5!white,
colbacklower=black!3!white,
#1}
%\tcbset{student/.style={lowerbox=invisible}}
\makeatletter
\newenvironment{fixedfigure}
{\def\@captype{figure}\center}
{\endcenter}
\makeatother
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%\pdfoptionpdfminorversion 6
\begin{document}
\begin{example}
Figure~\ref{fig:conti_pdf_cdf} gives the probability density function $f(x)$ and its cumulative function $F(x)$.
\begin{fixedfigure}
\subfloat[$f(x)$]{\includegraphics[width=3cm]{example-image}}\qquad
\subfloat[$F(x)$]{\includegraphics[width=3cm]{example-image}}
\caption{Illustration of $f(x)$ and $F(x)$ for a (continuous) piecewise function}
\label{fig:conti_pdf_cdf}
\end{fixedfigure}
\tcblower
Figure~\ref{fig:conti_pdf_cdf-B} gives the probability density function $f(x)$ and its cumulative function $F(x)$.
\begin{fixedfigure}
\subfloat[$f(x)$]{\includegraphics[width=3cm]{example-image}}\qquad
\subfloat[$F(x)$]{\includegraphics[width=3cm]{example-image}}
\caption{Illustration of $f(x)$ and $F(x)$ for a (continuous) piecewise function}
\label{fig:conti_pdf_cdf-B}
\end{fixedfigure}
\begin{center}
\includegraphics[width=5cm]{example-image} % 1.4 version
\end{center}
\end{example}
\end{document}
答案2
就我而言,我有很多章节,有些章节包含数十个图。当我迁移到不同的 latex 模板(从 memoir 到 kaobook)时出现了此错误,但迁移不一定是导致问题的原因,问题恰好隐藏在 memoir 模板中。以下是经过清理的代码摘录:
\begin{figure*}
\includegraphics[width=\linewidth]{example-image}
\caption[Three layers of an app]{Three layers of an app \sidenote{Image credit: First published somewhere else~\cite{harty_aymer_playbook_2016}}.}
\label{fig:3-layers}
\end{figure*}
kaobook\sidenote{...}
或\footnote{...}
memoir 导致本章后面出现 Float(s) lost 消息。其中一张图片确实没有显示在生成的 PDF 中。
我使用\clearpage
每个命令\section{...}
来帮助我追踪问题发生的位置。这让我得到了这个图。
解决方法是删除 sidenote/footnote 命令,如下所示:
\begin{figure*}
\includegraphics[width=\linewidth]{example-image}
\caption[Three layers of an app]{Three layers of an app {Image credit: First published somewhere else~\cite{harty_aymer_playbook_2016}}.}
\label{fig:3-layers}
\end{figure*}
注意:我暂时在{}
文本周围留下了,因为这样可以快速轻松地测试我的理论。一旦我看到错误已经得到解决,它们就会被删除。我希望这可以帮助其他人。