缺失数字,视为零

缺失数字,视为零

这个问题的后续问题将子标题与 tikz 图片垂直对齐

这是我正在使用的代码,适用于非常简单的场景:

\documentclass{article}
\usepackage{float, tikz, subfigure, array, caption, subcaption}
\usetikzlibrary{calc}

\newcommand{\alignedsublabel}[1]{%
\node at ($(current bounding box.south west)!(#1)!(current bounding box.south east)$) [anchor=base,text depth=0pt,yshift=-3ex] {\parbox{10em}{\subcaption[]{}}};%
}

\begin{document}

\begin{figure}
\begin{tikzpicture}[level/.style={sibling distance=35mm/#1}, scale=0.8]
\node [circle,draw] (z){1} 
  child {node [circle,draw] (a) {8}
    child {node [circle,draw] (b) {6}
      child {node [circle,draw] (c) {5}}
      child[draw=white] {node [circle,draw,fill=gray] (d) {9}}
    }
    child {node [circle,draw] (g) {3}}
  }
  child {node [circle,draw] (j) {7}
    child {node [circle,draw] (k) {2}}
    child {node [circle,draw] (l) {4}}
};
\alignedsublabel{z.center}{}
\end{tikzpicture}
\caption{This is a picture of something.}
\end{figure}

\end{document}

问题出在第 26 行 ( \alignedsublabel)。这会导致Missing numbers, treated as zero错误。如果我将其删除,则一切都会编译正常。我不确定 .log 文件的哪些部分可能相关,但它是这样说的:

<snip>
("C:\Program Files (x86)\MiKTeX 2.9\tex\context\base\supp-pdf.mkii"
[Loading MPS to PDF converter (version 2006.09.02).]
\scratchcounter=\count132
\scratchdimen=\dimen181
\scratchbox=\box42
\nofMPsegments=\count133
\nofMParguments=\count134
\everyMPshowfont=\toks36
\MPscratchCnt=\count135
\MPscratchDim=\dimen182
\MPnumerator=\count136
\everyMPtoPDFconversion=\toks37
) ABD: EveryShipout initializing macros
Package caption Info: Begin \AtBeginDocument code.
Package caption Info: End \AtBeginDocument code.

! Missing number, treated as zero.
<to be read again> 
                   \caption@c@figure 
l.30 \alignedsublabel{z.center}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

! Missing = inserted for \ifnum.
<to be read again> 
                   \caption@c@figure 
l.30 \alignedsublabel{z.center}

I was expecting to see `<', `=', or `>'. Didn't.

! Missing number, treated as zero.
<to be read again> 
                   \caption@c@figure 
l.30 \alignedsublabel{z.center}

A number should have been here; I inserted `0'.
(If you can't figure out why I needed to see a number,
look up `weird error' in the index to The TeXbook.)

[1
Non-PDF special ignored!{C:/ProgramData/MiKTeX/2.9/pdftex/config/pdftex.map}

]
<snip>

有什么想法吗?如果 .log 文件中的其他内容也有帮助,请告诉我,我只认为这是最相关的信息。

答案1

如果删除该subfigure包,代码可以正常编译。我认为这是subcaption和之间的冲突subfigure

答案2

您的错误应该类似于这个:

我在 LaTeX 代码中犯了以下错误:

$\box(p\land q)$

代替

$\Box(p\land q)$

\box是由 定义的 TeX 宏\setbox,例如:

\setbox0=\hbox{mushroom}定义\box0\hbox{mushroom},每次\box0输入时它都会被替换为\hbox{mushroom}

错误信息指的是缺少一个数字,就像0在 TeX 代码中一样\box(..,因为我输入了大小写错误,而不是正确的 LaTeX 宏\Box(..

缺乏耐心的 TeX书籍,位于plain/impatient/book.pdfTeX Live 文档目录中,可以查看有关 TeX 宏的信息。

相关内容