# image { } problem

\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}


I other image with similar syntax in the same folder work completely correct, but with this one I always get:

! 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>
}


I really do not know whats meant by "try typing 2 now"? where do I type this?

-
Do you really have your definition of \mic as \def \mic {\unit{\micro\meter}} (with the spaces)? If you remove them, does it solve your problem? –  Werner Dec 31 '12 at 1:58
No, removing them doesnt help, but Ive used this \mic in ten pictures before, and compiling was no problem... –  Pierre Dec 31 '12 at 2:10
You haven't provided a complete document so I have to guess (and I don't know where \unit is defined, but I suspect it is a fragile command in which case use \protected\def\mic{\unit{\micro\meter}} delete the .toc file and try again. –  David Carlisle Dec 31 '12 at 2:14
Do you also have underscore _ in other file names too? –  percusse Dec 31 '12 at 2:20
Back when running a TeX document would typically take several minutes, you could interactively alter the input when given an error message to allow TeX to carry on without having to stop fix the file and re-run. Such interactive changes at the commandline are not saved back to the file so if you are using a TeX distribution from this century, it's probably best to ignore the suggestion of typing to the error prompt. –  David Carlisle Dec 31 '12 at 2:20

I don't know in which package \unit is defined, given the absence of a complete example. But declaring new units/short hand units is easy with siunitx package.

# Code:

\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}


# Edit:

To answer the comment by OP:

The command \unit should be used like: \unit{120}{\kilo\meter\per\hour} according to the documentation. Hence the definition \def \mic {\unit{\micro\meter}} proves to be wrong. Instead use something like: \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}

-
I have used the rather outdated package \usepackage[Gray,squaren,thinqspace,thinspace]{SIunits} throughout whole my report (70+pages) but found out siunitx is better now at the end. However I cant use both together and there are a ton of declarations I do not want to start changing manually –  Pierre Dec 31 '12 at 11:12

EDIT: using the xspace package, you can define your command with \xspace (see the adapted example), which will recognize whether there needs to be a space after the command or not.

Here to give you a working example:

\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}


Giving you:

-
Indeed, this solved the problem. however, now I have to add the {} to every \mic because otherwise the text that follows is just pasted right on top. What can I put in between these "{}" ? I am quite new to Latex. –  Pierre Dec 31 '12 at 11:13
Thank you all for your help, it has been very appreciated:)! –  Pierre Dec 31 '12 at 11:14
I am also really wondering why it stopped working after all this time. I did completely similar thinks in other captions –  Pierre Dec 31 '12 at 11:16
You could define \mic like this \newcommand{\mic}{\micro\meter~}`, but then you'll always have a space behind it. –  xfoo Dec 31 '12 at 11:17
ok, that is indeed also tricky, to bad you can't do it by \mic, would have been easier by just using spaces. Thanks man:) –  Pierre Dec 31 '12 at 11:35