谢谢制作 \textcircled 数字的好方法?,我找到了一种在图形图例中圈出数字的方法。这是命令代码:
\newcommand{\circled}[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=1.5pt](char){#1}}}
这是我的代码:
\begin{figure}[t!]
\centering
\begin{minipage}[b]{.75\linewidth}
\centering
\centerline{\includegraphics[width=0.9\linewidth]{./Introduction/images/tirf}}
\centerline{\scriptsize{(a)}}\medskip
\end{minipage}
\caption{(Cis-)total internal reflection fluorescence microscope (TIRFM) diagram Specimen Evanescent wave range Cover slip Immersion oil Objective Emission beam (signal) Excitation beam.
\circled{1} Specimen.
\circled{2} Evanescent wave range.
\circled{3} Cover slip.
\circled{4} Immersion oil.
\circled{5} Objective.
\circled{6} Emission beam (signal).
\circled{7} Excitation beam.
Illustration created and released in public domain by Dawid Kulik.}
\label{fig:tirf}
\end{figure}
问题是,我在编译时遇到这些错误。
! Undefined control sequence.
<recently read> \tikz@origsemi
l.1123 ...leased in public domain by Dawid Kulik.}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
<recently read> \tikz@origcolon
l.1123 ...leased in public domain by Dawid Kulik.}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Undefined control sequence.
\tikz@deactivatthings ...kz@nonactivecolon }\def |
{\tikz@nonactivebar }\def ...
l.1123 ...leased in public domain by Dawid Kulik.}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
! Argument of \tikz@style@parseA has an extra }.
<inserted text>
\par
l.1123 ...leased in public domain by Dawid Kulik.}
I've run across a `}' that doesn't seem to match anything.
For example, `\def\a#1{...}' and `\a}' would produce
this error. If you simply proceed now, the `\par' that
I've just inserted will cause me to report a runaway
argument that might be the root of the problem. But if
your `}' was spurious, just type `2' and it will go away.
Runaway argument?
(char.base)]{\node [shape=circle,draw,inner sep=2pt](char){1}} Specim\ETC.
! Paragraph ended before \tikz@style@parseA was complete.
<to be read again>
\par
l.1123 ...leased in public domain by Dawid Kulik.}
I suspect you've forgotten a `}', causing me to apply this
control sequence to too much text. How can we recover?
My plan is to forget the whole thing and hope for the best.
奇怪的是,PDF 中的所有内容看起来都很好,数字也正确圈出了。我已经调查了几个小时,但仍然找不到问题所在。我尝试删除和/或更改 中的参数\newcommand
,搜索丢失的 {},将\circled
命令移到图片图例之外,在我的主程序中明确添加 TikZ 包等。什么都没有告诉我发生了什么,我迷路了。
我想到了一个软件包不兼容的问题,但我不知道哪一个可能导致了问题。仅供参考,这些是我使用的:
\usepackage{amsfonts}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{algorithm}
\usepackage[noend]{algpseudocode}
\usepackage{ntheorem}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}
TikZ 包似乎已经包含在我正在使用的模板中。
答案1
虽然您没有发布 MWE(下次!),但可能您只需要\protect
您的命令(或使用circledsteps
!):
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{tikz}
\usepackage{circledsteps}
\newcommand{\circled}[1]{\tikz[baseline=(char.base)]{\node[shape=circle,draw,inner sep=1.5pt](char){#1}}}
\begin{document}
\begin{figure}[htpb]
\centering
\fbox{Fake figure}
\caption{This has a \protect\circled{1}}
\label{fig:lalla}
\end{figure}
\begin{figure}[htpb]
\centering
\fbox{Another fake figure}
\caption{This has a (circledsteps) \Circled{1}}
\label{fig:lilla}
\end{figure}
\end{document}