When trying to pass name to \label I'm getting 'bad character' error. Is it possible to use \label like this, or should I just manually specify it outside of \img macro?
% Usage: \img[name]{caption}
\newcommand{\img}[2][image]{%
\begin{figure}[H]
\includegraphics[width=\textwidth]{img/#1.png}
\caption[Long caption]{#2}
% and here it says: bad character in label
\label{#1}
\end{figure}
}
Example call:
% some text
See example ~\ref{main.char}
% image itself
\img[main.char]{Chart example}
I'm using xelatex and the document compiles, but the reference to specified label does not work. It's lacheck that gives me that error and the document actually compiles - but the reference does not work. So, I assume that there's really an error.
Resolved: recompiled document twice in row, reference now works as it should.
#1? A complete minimal working example (MWE) would be helpfull ... – Kurt Oct 3 '12 at 14:58lacheckon the document and receiving this error? Not sure how old or reliable it is since the archive on CTAN is dated 1998. This compiles under pdfLaTeX (or any compiler for that matter, I'm sure). The "bad character error" could stem from a space in your\label, but that shouldn't cause a compiler error. Regardless, it's best to not use spaces in labels or filenames. – Werner Oct 3 '12 at 15:04lacheckthat gives me that error and the document actually compiles - but the reference does not work. So, I assume that there's really is error. – Xifax Oct 3 '12 at 15:23??? Did you compile at least twice? – Werner Oct 3 '12 at 15:47