代码:

代码:
\def \mic {\unit{\micro\meter}}

\begin{figure}[h]

\includegraphics[scale=0.8]{C:/Users/21_12_test10}

\caption[6 nozzles working in parallel at 40V with 20~\mic drop spacing.]{6 nozzles working in parallel at 40V with 20~\mic drop spacing.\newline
top row images: line widths of 158 - 170 - 160 - 173~\mic ;\newline bottom row images: uniform spacings of 109 - 71 - 74~\mic}

\label{IJ_2_8}

\end{figure}

同一文件夹中具有类似语法的其他图像完全正常工作,但对于这个我总是得到:

! Missing } inserted.
<inserted text>
}
l.1399 ...e widths of 158 - 170 - 160 - 173~\mic }
; \newline bottom row imag...
I've inserted something that you may have forgotten.
(See the <inserted text> above.)
With luck, this will get me unwedged. But if you
really didn't forget anything, try typing `2' now; then
my insertion and my current dilemma will both disappear.
! Missing } inserted.
<inserted text>
}

我真的不知道“现在尝试输入 2”是什么意思?我在哪里输入这个?

答案1

\unit由于没有完整的示例,我不知道在哪个包中定义。但使用siunitx包声明新单位/简写单位很容易。

代码:

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage{siunitx}
\DeclareSIUnit{\mic}{\micro\meter} %% declare a new unit
\begin{document}
\noindent
 {\small
\begin{tabular}{lll}
 \verb|12\si{\mic}|                    & : & 12\si{\mic}                    \\ %% this is how we use it or
 \verb|\SI{12}{\mic}|                  & : & \SI{12}{\mic}                  \\ %% or
 \verb|\SIrange{10}{20}{\mic}|         & : & \SIrange{10}{20}{\mic}         \\ %% or
 \verb|\SIlist{158;170;160;173}{\mic}| & : & \SIlist{158;170;160;173}{\mic} \\ 
 \verb|\SIlist{109;71;74}{\mic}|       & : & \SIlist{109;71;74}{\mic}                          
\end{tabular} 
}

\begin{figure}[h]

\includegraphics[scale=0.8]{C:/Users/21_12_test10}

\caption[6 nozzles working in parallel at 40V with 20\si{\mic} drop spacing.]{\parbox[t]{.86\textwidth}{6 nozzles working in parallel at 40V with 20\si{\mic} drop spacing. \\
top row images: line widths of \SIlist{158;170;160;173}{\mic} ; \\
bottom row images: uniform spacings of \SIlist{109;71;74}{\mic}}}

\label{IJ_2_8}

\end{figure}
\end{document}

在此处输入图片描述

编辑:

回答OP的评论:

根据文档,该命令\unit应按如下方式使用: 。因此,该定义被证明是错误的。请改用如下方式:\unit{120}{\kilo\meter\per\hour}\def \mic {\unit{\micro\meter}}\newcommand*{\mic}[1]{\unit{#1}{\micro\meter}}

\documentclass{article}
\usepackage[demo]{graphicx}
\usepackage[Gray,squaren,thinqspace,thinspace]{SIunits}
%\def\mic{\micro\meter}
\newcommand*{\mic}[1]{\unit{#1}{\micro\meter}}

\begin{document}
\begin{figure}[h]

\includegraphics[scale=0.8]{C:/Users/21_12_test10}

\caption[6 nozzles working in parallel at 40V with \mic{20}\ drop spacing.]{6 nozzles working in parallel at 40V with \mic{20} drop spacing.\newline
top row images: line widths of 158 - 170 - 160 - \mic{173} ;\newline bottom row images: uniform spacings of 109 - 71 - \mic{74}}

\label{IJ_2_8}

\end{figure}
\end{document}

答案2

编辑:使用该xspace包,您可以定义您的命令\xspace(参见改编的示例),它将识别命令后是否需要空格。

这里给你一个工作示例:

\documentclass{article}
\usepackage{graphicx}
\usepackage{SIunits}
\usepackage{xspace}
\newcommand{\mic}{\micro\meter\xspace}

\begin{document}

\begin{figure}[h]
\includegraphics[scale=0.8]{texlogo}
\caption{6 nozzles working in parallel at 40V with 20\mic drop spacing.\newline
top row images: line widths of 158 - 170 - 160 - 173\mic;
\newline bottom row images: uniform spacings of 109 - 71 - 74\mic}
\label{IJ_2_8}
\end{figure}

\end{document}

为您提供:

输出

相关内容