Graphics, Figures & TablesText in reference labels

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
Matrix
Posts: 3
Joined: Mon Feb 05, 2018 12:32 pm

Text in reference labels

Post by Matrix »

Hi,

First post here :)

I have one document where all my \ref commands are including the category label as well. I don't want this, as I've written the text already, and this is resulting in text such as 'in Figure Figure 1, blah...'

What could be causing this? This is the list of packages loaded for the document:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{graphicx}
\usepackage{tabularx}
\usepackage{multirow}
\usepackage{multicol}
\usepackage{textcomp}
%\usepackage{tikz}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
%\usepackage{natbib}
\usepackage{url}
\usepackage{lineno}
\usepackage{xcolor}
\usepackage{colortbl}
\usepackage{ellipse}
\usepackage{booktabs}
\usepackage{pdflscape}
\usepackage{mhchem}
\usepackage{chemstyle}
\usepackage[shortlabels]{enumitem}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org
TikZ book
User avatar
Stefan Kottwitz
Site Admin
Posts: 10311
Joined: Mon Mar 10, 2008 9:44 pm

Text in reference labels

Post by Stefan Kottwitz »

With these packages,
  • the chemstyle package may cause a problem
  • reference numbering is "1" not "Figure 1"
so I get with

See figure \ref{test}

the result "See figure 1".

Perhaps post code that produces the output with the issue (Infominimal working example).

Stefan
LaTeX.org admin
Matrix
Posts: 3
Joined: Mon Feb 05, 2018 12:32 pm

Text in reference labels

Post by Matrix »

Here's a minimal working example.

Thanks for the tip - it is indeed the chemstyle package that's causing it. Do you have any ideas for a fix?

The code below gives the output

"This is a test.
Reference to figure Figure 1"

(At least, it does on my system - TexWorks 0.6.2, on Windows - and using a png file as the figure.)

Code: Select all

\documentclass[12pt]{article}
\usepackage{chemstyle}

\begin{document}

\begin{figure}
  \includegraphics{no-figure}
  \caption{Caption here}  \label{test}
\end{figure}

This is a test.

Reference to figure \ref{test}

\end{document}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

Text in reference labels

Post by Johannes_B »

Code: Select all

\listfiles
\documentclass[12pt]{article}
\usepackage[varioref=false]{chemstyle}% <-----

\begin{document}
\begin{figure}
\includegraphics{example-image}% this file exists on your system
\caption{Caption here}  \label{test}
\end{figure}

This is a test.

Reference to figure \ref{test}

\end{document}
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Matrix
Posts: 3
Joined: Mon Feb 05, 2018 12:32 pm

Text in reference labels

Post by Matrix »

Works perfectly - thanks!

:D
Post Reply