浮点数丢失?如何调试?

浮点数丢失?如何调试?

我在一种情况下收到此错误,但在另一种情况下没有收到 - 这是有效的:

\documentclass[a4paper]{report} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{stix}
\usepackage{mathtools}
\usepackage[document]{ragged2e}
\usepackage{wasysym}
\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{float}

\theoremstyle{definition}
\newtheorem{mydef}{Definition}[section]

\newfloat{defn}{thp}{def}[section]
\floatname{defn}{Definition}
\newfloat{diag}{htbp}{dia}[section]
\floatname{diag}{Diagram}

\begin{document}
    \begin{defn}[H]
        \begin{mydef}
            \caption{Exponentiation in a category}
            \label{def:ExponentiationInCategory}
            A category $\mathcal{C}$ has \textit{exponentiation} if $\forall a, b \in \mathcal{C}$ there is an object $b^a \in \mathcal{C}$ and an \textit{evaluation arrow} $ev \colon b^a \times a \rightarrow b$, such that $\forall c, (g \colon c \times a \rightarrow b) \in \mathcal{C}$, there is a unique arrow $\hat{g} \colon c \rightarrow b^a$, so the following commutes, ie there is a unique $\hat{g}$, so $ev \circ (\hat{g} \times 1_a) = g$:
            \begin{diag}[H]
                \centering
                \begin{tikzpicture}
                \node[inner sep=0pt,minimum size=4pt] (baxa) at (0,2) {$b^a \times a$};
                \node[inner sep=0pt,minimum size=4pt] (b) at (2,1) {$b$};
                \node[inner sep=0pt,minimum size=4pt] (cxa) at (0,0) {$c \times a$};
                \draw[-stealth, shorten <= 3pt, shorten >= 3pt] (baxa) to node [above=4pt] {$ev$} (b);
                \draw[-stealth, dashed, shorten <= 3pt, shorten >= 3pt] (cxa) to node [left=4pt] {$\hat{g} \times 1_a$} (baxa);
                \draw[-stealth, shorten <= 3pt, shorten >= 3pt] (cxa) to node [below=4pt] {$g$} (b);
                \end{tikzpicture}
                \caption{Exponention in a category, $\mathcal{C}$}
                \label{dia:ExponentiationInCategory}
            \end{diag}
        \end{mydef}
    \end{defn}
\end{document}

然而,这失败了:

\documentclass[a4paper]{report} 
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{stix}
\usepackage{mathtools}
\usepackage[document]{ragged2e}
\usepackage{wasysym}
\usepackage{booktabs}
\usepackage{enumitem}
\usepackage{pgfplots}
\usepackage{tikz}
\usepackage{float}

\theoremstyle{definition}
\newtheorem{mydef}{Definition}[section]

\newfloat{defn}{thp}{def}[section]
\floatname{defn}{Definition}
\newfloat{diag}{htbp}{dia}[section]
\floatname{diag}{Diagram}

\begin{document}
    \begin{defn}[H]
        \begin{mydef}
            \caption{Co-limit}
            \label{def:CoLimit}
            A co-cone for a diagram $D$ with objects $d_i, ...$, consists of an object $c$, and arrows $f_i \colon d_i \rightarrow c$. A co-limit for $D$ is a co-cone, such that for any other co-cone $f^{\prime}_i \colon d_i \rightarrow c^{\prime}$, there is exactly one arrow $f \colon c \rightarrow c^{\prime}$ that makes the following diagram commute:
            \begin{diag}
                \centering
                \begin{tikzpicture}
                \node[inner sep=0pt,minimum size=4pt] (di) at (1,2) {$d_i$};
                \node[inner sep=0pt,minimum size=4pt] (c1) at (0,0) {$c$};
                \node[inner sep=0pt,minimum size=4pt] (c2) at (2,0) {$c^{\prime}$};
                \draw[-stealth, shorten <= 3pt, shorten >= 3pt] (di) to node [above left=4pt] {$f_i$} (c1);
                \draw[-stealth, shorten <= 3pt, shorten >= 3pt] (di) to node [above right=4pt] {$f^{\prime}_i$} (c2);
                \draw[-stealth, dashed, shorten <= 3pt, shorten >= 3pt] (c1) to node [below=4pt] {$f$} (c2);
                \end{tikzpicture}
                \caption{Colimit}
                \label{dia:Colimit}
            \end{diag}
        \end{mydef}
    \end{defn}
\end{document}

出现以下错误:

! LaTeX Error: Float(s) lost.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.45 \end{document}

有什么区别——我没发现?

答案1

浮动环境将其内容标记为不是在主文档流中,可以将其重新插入到文档的不同位置,以避免分页符处出现不好的空白。

它们必须始终在主页的顶层使用,不能在任何类型的框内使用浮动,特别是不能在外部浮动环境的框内使用。

float 包中的选项[H]将环境重新定义为当前位置的一个框,该框不浮动,也不会从主文档流中移除。因此,它不受浮动位置限制,并且永远不会产生浮动丢失错误。

相关内容