You are referring to a label which has been externalized to a separate pdf - which is a complex task.
Here, "complex" means "too complex for the standard -shell-escape image externalization". In order to reference something inside of some external image, you have to take special steps.
To quote from the pgfplots manual: "For point a), a \ref
inside of an externalized graphics works only if you issue the required system call
manually or by make. The initial configuration mode=convert with system call
does not support
\ref
. But you can copypaste the system call generated by mode=convert with system call
and
issue it manually. The reason is that \ref
information is stored in the main .aux
file but this
auxiliary file is not completely written when mode=convert with system call
is invoked (there is a
race condition). Note that \pageref
is not supported (sorry). Thus: if you have \ref
inside of external
graphics, consider using mode=list and make
or copypaste the system call for the image(s) and issue
it manually."
Alternatively, you can wait (say) one week until the next version of pgfplots is released. It supports layered graphics such that the first legend will not appear behind the second axis.
Another altivernative solution might be to insert a legend entry for the first plot into the legend of the second image using \addlegendimage{<style>}
:
\documentclass{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.3}
\begin{document}
\begin{tikzpicture}
\pgfplotsset{
plot 0/.style={
ybar, ybar legend, draw=gray, fill=gray, color=gray
}
}
\begin{axis}[
legend cell align=left,
bar width=7pt,
xmin=0, xmax=1,
axis y line*=left,
xlabel=Laser current,
ylabel=Tuning range,
nodes near coords align=left,
nodes near coords,]
\addplot[plot 0] {rand};
% \addlegendentry{Abstimmbereich};
% \label{Abstimmbereich};
\end{axis}
\begin{axis}[
every axis legend/.append style={fill=white, anchor=north west, at={(0.35,0.18)}},
legend cell align=left,
ybar=5pt,
ybar interval=0.6,
bar width=7pt,
xmin=0, xmax=1,
ymin=30, ymax=60,
axis y line*=right,
axis x line=none,
ylabel=SMSR,
nodes near coords align=left,
nodes near coords,]
\addlegendentry{Abstimmbereich}
\addlegendimage{plot 0}
\addplot[ybar, ybar legend, draw=black, color=black] {30 + rand*30};
\label{SMSR};
\addlegendentry{SMSR};
\end{axis}
\end{tikzpicture}
\end{document}
Note that I have deliberately stripped the example from your data files and some other stuff - the only point here is the special legend construction.
This does also work with image externalization.
In order to share the common options, I extracted the style for your first plot and used it at two places (this has the same effect as \label{Abstimmbereich}
and refstyle={Abstimmbereich}
, but it integrates seamlessly into the image externalization workflow).
The Journal of Web Engineering's LaTeX code completely redefines the sectional units in such a way that referencing them is not possible using the default \label
-\ref
system. Here's a view on what the sectioning commands look like:
%--------------------------------------------------------------------------
% section commands
\newcounter{sectionc}\newcounter{subsectionc}\newcounter{subsubsectionc}
\renewcommand{\section}[1] {\vspace{12pt}\addtocounter{sectionc}{1}
\setcounter{subsectionc}{0}\setcounter{subsubsectionc}{0}\noindent
{\bf\thesectionc. #1}\par\vspace{5pt}}
\renewcommand{\subsection}[1] {\vspace{12pt}\addtocounter{subsectionc}{1}
\setcounter{subsubsectionc}{0}\noindent
{\bf\thesectionc.\thesubsectionc. {\kern1pt \bfit #1}}\par\vspace{5pt}}
\renewcommand{\subsubsection}[1] {\vspace{12pt}\addtocounter{subsubsectionc}{1}
\noindent{\rm\thesectionc.\thesubsectionc.\thesubsubsectionc.
{\kern1pt \it #1}}\par\vspace{5pt}}
\newcommand{\nonumsection}[1] {\vspace{12pt}\noindent{\bf #1}
\par\vspace{5pt}}
Not only do they use old font declarations, there's no proper \refstepcounter
to capture \label
s. Instead, the package uses \addtocounter{<cntr>}{1}
. For starters, you'd have to redefine \section
to use \refstepcounter
instead of \addtocounter
. However, since this is for a journal submission, you should really question whether this is intended.
Here's a proper redefinition of \section
included in a minimal example:
\documentclass{article}
\usepackage{jwe}
\makeatletter
\@addtoreset{subsectionc}{sectionc}
\@addtoreset{subsubsectionc}{subsectionc}
\makeatother
\renewcommand{\section}[1]{%
\par\vspace{12pt}%
\refstepcounter{sectionc}% This allows you to use \label and \ref properly
\noindent{\bfseries\thesectionc. #1}%
\par\vspace{5pt}}
\begin{document}
\section{Intro}\label{s1}
\noindent I am a boy.
\section{Two}
\noindent Related Works referring to Section~\ref{s1}.
\end{document}
My thought on this is that the journal probably wants people to do these references manually, which seems awkward.
Contact the journal and tell them they need to change things. Or at least ask them why they do it this way.
Best Answer
You are referencing nothing, since there is no counter increased with
\refstepcounter
for that small document.\label
needs\refstepcounter
, since that macro defines\@currentlabel
, which holds the counter value (or better: reference format) (Of course,\@currentlabel
can be defined beforehand in order to create 'fake' labels)Now,
latex.ltx
defines an empty\@currentlabel
before\begin{document}
and that information is used by\label
, so you're seeingReference
and notReference 1
.The
.aux
file of that tiny OP document is tiny too:There is the label name
a
and the cross-reference information after the name, i.e.{{}{1}}
. The first brace-pair inside there is empty here whereas the second one has1
as content, this is the page number, but not the reference number as requested --LaTeX
wrote an empty\@currentlabel
content to the.aux
file.Here is the relevant code from
latex.ltx
(lines 4089f), comments by me.Assuming a standard document class like
article
, for example\section
(not\section*
) uses\refstepcounter{section}
internally (actually it is\@sect
that calls that macro, but let us ignore this for a moment, also the fact thatsecnumdepth
must have the appropiate value) and following example will provide a reference: