2

This question already has an answer here:

Since I'm using the chemstyle package by Joseph Wright a reference to a figure, or scheme (a float environment defined by the package) is always printed as:

Figure XY

or

Scheme YZ

Normally one would write someting like

Cooking bacon (see figure \ref{fig:Foo bar}) and eggs.

And get an output like

Cooking bacon (see figure XY) and eggs.

Now, with the chemstyle package, this renders to:

Cooking bacon (see figure Figure XY) and eggs.

How can I get back to the normal behaviour of \ref?

If you see this Joseph, think about implementing an option to switch the behaviour of this as some people may like the automatic output, but others, as me, don't.


MWE

\documentclass{article}

\usepackage{chemstyle}
\usepackage{graphicx}

\begin{document}

\begin{figure}[htb!]
    \centering
    \includegraphics{example-image}
    \caption{Foo figure}
    \label{fig:foo}
\end{figure}

Figure \ref{fig:foo} shows a Foo.

\end{document}

marked as duplicate by campa, Stefan Pinnow, user121799, Phelype Oleinik, Troy Aug 22 '18 at 13:01

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 4
    Can't test now but you could try with \usepackage[varioref=false]{chemstyle}. – campa Aug 22 '18 at 10:09
  • @campa It worked for me in the MWE, so you might want to write up an answer. – moewe Aug 22 '18 at 10:38
  • 1
    BTW: You probably want to write Figure~\ref{fig:foo} with a tie ~ before \ref to avoid a line break between "Figure" and the number. Of course varioref or cleveref make this easier for you because you just type \ref and the prefix pops up automatically. That is why I really like this feature, maybe you should give it a try one day. – moewe Aug 22 '18 at 10:39
  • Yes, this works just fine! I didn't see this in the documentation, maybe it should be updated. Thanks @campa :) – Sam Aug 22 '18 at 10:40
  • @Sam It is on page 3 of the chemstyle documentation. – user36296 Aug 22 '18 at 10:51
3

The package chemstyle has (lines 425-434)

\ifcst@varioref
  \RequirePackage{varioref}
  \labelformat{figure}{\figurename~#1}
  \labelformat{table}{\tablename~#1}
  \AtEndOfPackage{%
    \AtBeginDocument{%
      \labelformat{scheme}{\schemename~#1}%
    }%
  }
\fi

By default it loads varioref (which isn't the problem) and then changes \labelformat, which is a macro provided by varioref whose purpose is precisely to control the output of \ref. At this point I think you have three options:

1) You stop chemstyle from loadingvarioref` with the corresponding option

\usepackage[varioref=false]{chemstyle}

2) You "undo" what chemstyle did

\labelformat{figure}{#1}
\labelformat{table}{#1}

3) You enjoy having varioref at your disposal and use \ref{fig:foo} (or \Ref{fig:foo} at the beginning of a sentence) instead of writing Figure~\ref{fig:foo} explicitly.

Not the answer you're looking for? Browse other questions tagged or ask your own question.