Graphics, Figures & TablesSupressing hyperref altering subref labels in captions

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
qwertyup
Posts: 2
Joined: Mon Sep 13, 2010 9:31 pm

Supressing hyperref altering subref labels in captions

Post by qwertyup »

Have spent all day failing to resolve this, and a search of this forum didn't prove fruitful, so hopefully someone here can help!

Basically, I want to use to get the output of \subref [eg (a) ] in my captions, without a hyperlink being imposed by hyperref. Using \subref* just results in a linked a rather than an unlinked (a). In other words I want to locally suppress the effects of hyperref, akin to the starred versions of autoref (\autoref*).

A MWE is given below:

Code: Select all

\documentclass{article}

\usepackage{caption,subfig}
\usepackage{hyperref}

\begin{document}

  \begin{figure}
 
    \subfloat[]
      {Figure A Goes Here
    \label{fig:labelone}
      }

    \subfloat[]
      {Figure B Goes Here
    \label{fig:labeltwo}
      }\\

    \subfloat[]
      {Figure C Goes Here
    \label{fig:labelthree}
      }

    \subfloat[]
      {Figure D Goes Here
    \label{fig:labelfour}
      }

  \label{fig:figureone}

  \caption{\subref{fig:labelone} This subref is linked, \subref*{fig:labeltwo} as is this, \subref{fig:labelthree} and this one, and \subref{fig:labelfour} lastly this one. I want something like this \ref*{fig:labelfour} but without the preceding number!}

  \end{figure}

\end{document}
Has anyone got any suggestions? Using the subcaptions within each subfloat isn't a viable solution, unfortunately, due to supervisor aesthetic demands!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Supressing hyperref altering subref labels in captions

Post by sommerfee »

You could use the subcaption package instead of subfig:

Code: Select all

\documentclass{article}

\usepackage{caption,subcaption}
\usepackage{hyperref}

\begin{document}

  \begin{figure}

    \subfloat[\label{fig:labelone}]
      {Figure A Goes Here}

    \subfloat[\label{fig:labeltwo}]
      {Figure B Goes Here}\\

    \subfloat[\label{fig:labelthree}]
      {Figure C Goes Here}

    \subfloat[\label{fig:labelfour}]
      {Figure D Goes Here}

  \label{fig:figureone}

  \caption{\subref{fig:labelone} This subref is linked, \subref*{fig:labeltwo} as is this, \subref{fig:labelthree} and this one, and \subref{fig:labelfour} lastly this one. I want something like this \ref*{fig:labelfour} but without the preceding number!}

  \end{figure}

\end{document}
(Please note the different label placement.)

In subcaption, \subref* is implemented analogue to \ref* and \autoref*.

Axel
qwertyup
Posts: 2
Joined: Mon Sep 13, 2010 9:31 pm

Supressing hyperref altering subref labels in captions

Post by qwertyup »

Thanks for the help.

However, when I try implementing this in my thesis file I get the following output:

Code: Select all

*****
*****     PDFLaTeX output: 
*****     cd "/home/ms547/Dropbox/Thesis"
*****     pdflatex -interaction=nonstopmode 'thesis.tex'
*****
This is pdfTeX, Version 3.1415926-1.40.10 (TeX Live 2009/Debian)
 restricted \write18 enabled.
entering extended mode
(./thesis.tex
LaTeX2e <2009/09/24>
Babel <v3.8l> and hyphenation patterns for english, usenglishmax, dumylang, noh
yphenation, farsi, arabic, croatian, bulgarian, ukrainian, russian, czech, slov
ak, danish, dutch, finnish, french, basque, ngerman, german, german-x-2009-06-1
9, ngerman-x-2009-06-19, ibycus, monogreek, greek, ancientgreek, hungarian, san
skrit, italian, latin, latvian, lithuanian, mongolian2a, mongolian, bokmal, nyn
orsk, romanian, irish, coptic, serbian, turkish, welsh, esperanto, uppersorbian
, estonian, indonesian, interlingua, icelandic, kurmanji, slovenian, polish, po
rtuguese, spanish, galician, catalan, swedish, ukenglish, pinyin, loaded.
(./classes/thesis.cls
Document Class: classes/thesis 
(./classes/hepthesis-T.cls
Document Class: classes/hepthesis-T 2006/09/28 HEP thesis class by Andy Buckley
 (v1.3)
(/usr/share/texmf-texlive/tex/latex/base/book.cls
Document Class: book 2007/10/19 v1.4h Standard LaTeX document class
(/usr/share/texmf-texlive/tex/latex/base/bk12.clo))
(/usr/share/texmf-texlive/tex/latex/setspace/setspace.sty
Package: `setspace' 6.7 <2000/12/01>
) (/usr/share/texmf-texlive/tex/latex/graphics/color.sty
(/etc/texmf/tex/latex/config/color.cfg)
(/usr/share/texmf-texlive/tex/latex/pdftex-def/pdftex.def))
(/usr/share/texmf-texlive/tex/latex/hyperref/hyperref.sty
(/usr/share/texmf-texlive/tex/latex/graphics/keyval.sty)
(/usr/share/texmf-texlive/tex/generic/oberdiek/ifpdf.sty)
(/usr/share/texmf-texlive/tex/generic/oberdiek/ifvtex.sty)
(/usr/share/texmf-texlive/tex/generic/ifxetex/ifxetex.sty)
(/usr/share/texmf-texlive/tex/latex/oberdiek/hycolor.sty
(/usr/share/texmf-texlive/tex/latex/oberdiek/xcolor-patch.sty))
(/usr/share/texmf-texlive/tex/latex/hyperref/pd1enc.def)
(/usr/share/texmf-texlive/tex/generic/oberdiek/etexcmds.sty
(/usr/share/texmf-texlive/tex/generic/oberdiek/infwarerr.sty))
(/usr/share/texmf-texlive/tex/latex/latexconfig/hyperref.cfg)
(/usr/share/texmf-texlive/tex/latex/oberdiek/kvoptions.sty
(/usr/share/texmf-texlive/tex/generic/oberdiek/kvsetkeys.sty))
Implicit mode ON; LaTeX internals redefined
(/usr/share/texmf-texlive/tex/latex/ltxmisc/url.sty)
(/usr/share/texmf-texlive/tex/generic/oberdiek/bitset.sty
(/usr/share/texmf-texlive/tex/generic/oberdiek/intcalc.sty)
(/usr/share/texmf-texlive/tex/generic/oberdiek/bigintcalc.sty
(/usr/share/texmf-texlive/tex/generic/oberdiek/pdftexcmds.sty
(/usr/share/texmf-texlive/tex/generic/oberdiek/ifluatex.sty)
(/usr/share/texmf-texlive/tex/generic/oberdiek/ltxcmds.sty))))
(/usr/share/texmf-texlive/tex/generic/oberdiek/atbegshi.sty))
*hyperref using default driver hpdftex*
(/usr/share/texmf-texlive/tex/latex/hyperref/hpdftex.def)
(/usr/share/texmf-texlive/tex/latex/oberdiek/hypcap.sty)
(/usr/share/texmf-texlive/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/share/texmf-texlive/tex/latex/amsmath/amstext.sty
(/usr/share/texmf-texlive/tex/latex/amsmath/amsgen.sty))
(/usr/share/texmf-texlive/tex/latex/amsmath/amsbsy.sty)
(/usr/share/texmf-texlive/tex/latex/amsmath/amsopn.sty))
(/usr/share/texmf-texlive/tex/latex/base/makeidx.sty)
(/usr/share/texmf-texlive/tex/latex/booktabs/booktabs.sty)
(/usr/share/texmf-texlive/tex/latex/fancyhdr/fancyhdr.sty)
(/usr/share/texmf-texlive/tex/latex/tocbibind/tocbibind.sty

Package tocbibind Note: The document has chapter divisions.


Package tocbibind Note: Using chapter style headings, unless overridden.

) (/usr/share/texmf-texlive/tex/latex/tools/verbatim.sty)
(/usr/share/texmf-texlive/tex/latex/comment/comment.sty
Excluding comment 'comment')
(/usr/share/texmf-texlive/tex/latex/graphics/graphicx.sty
(/usr/share/texmf-texlive/tex/latex/graphics/graphics.sty
(/usr/share/texmf-texlive/tex/latex/graphics/trig.sty)
(/etc/texmf/tex/latex/config/graphics.cfg)))
(/usr/share/texmf-texlive/tex/latex/caption/caption.sty
(/usr/share/texmf-texlive/tex/latex/caption/caption3.sty))
(/usr/share/texmf-texlive/tex/latex/caption/subcaption.sty)
(/usr/share/texmf-texlive/tex/latex/rotating/rotating.sty
(/usr/share/texmf-texlive/tex/latex/base/ifthen.sty))
(/usr/share/texmf-texlive/tex/latex/multirow/multirow.sty)
(/usr/share/texmf-texlive/tex/latex/titlesec/titlesec.sty)

Package Fancyhdr Warning: \fancyhead's `E' option without twoside option is use
less on input line 414.


Package Fancyhdr Warning: \fancyhead's `E' option without twoside option is use
less on input line 415.

Special comment 'frontmatter' Special comment 'mainmatter'
Special comment 'appendices' Special comment 'backmatter'
(./classes/in-doc-refs.tex))
(/usr/share/texmf-texlive/tex/latex/tools/afterpage.sty)
(/var/lib/texmf/tex/generic/babel/babel.sty
(/usr/share/texmf-texlive/tex/generic/babel/english.ldf
(/usr/share/texmf-texlive/tex/generic/babel/babel.def)))) (./styles/thesis.sty
(./styles/mhchem.sty (/usr/share/texmf-texlive/tex/latex/tools/calc.sty)
(/usr/share/texmf-texlive/tex/latex/oberdiek/twoopt.sty))
(/usr/share/texmf-texlive/tex/latex/paralist/paralist.sty)
(./styles/subdepth.sty) (/usr/share/texmf-texlive/tex/latex/base/fontenc.sty
(/usr/share/texmf-texlive/tex/latex/base/t1enc.def))
(/usr/share/texmf-texlive/tex/latex/tools/xspace.sty)
(/usr/share/texmf-texlive/tex/latex/SIunits/SIunits.sty

(/usr/share/texmf-texlive/tex/latex/SIunits/SIunits.cfg)
Option `cdot' provided!
Option `squaren' provided!
) (/usr/share/texmf-texlive/tex/latex/natbib/natbib.sty)
(/usr/share/texmf-texlive/tex/latex/nomencl/nomencl.sty)
Writing nomenclature file thesis.nlo
Writing index file thesis.idx
(/usr/share/texmf-texlive/tex/latex/ltxmisc/threeparttable.sty)
(./styles/defs.tex)) (/usr/share/texmf-texlive/tex/latex/xstring/xstring.sty
(/usr/share/texmf-texlive/tex/generic/xstring/xstring.tex)) (./thesis.aux
(./frontmatter.aux) (./intro.aux) (./experimental-details.aux)
(./data-analysis.aux) (./backmatter.aux))
(/usr/share/texmf-texlive/tex/latex/base/ts1cmr.fd)
(/usr/share/texmf/tex/context/base/supp-pdf.mkii
[Loading MPS to PDF converter (version 2006.09.02).]
) (/usr/share/texmf-texlive/tex/latex/hyperref/nameref.sty
(/usr/share/texmf-texlive/tex/latex/oberdiek/refcount.sty)) (./thesis.out)
(./thesis.out)
Option `squaren' provided! 
 Command \squaren defined by SIunits package!

(./comment.cut

! LaTeX Error: No counter 'KVtest' defined.

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...
With the key message from what I can tell being this:

Code: Select all

! LaTeX Error: No counter 'KVtest' defined.
From checking through the forum it sounds like this may be due to a new float environment requiring a \DeclareCaptionSubType{nameOfNewFloat} but I cant find any \newfloat definitions within the main thesis style files etc. Is there any way to list all the used float types within a latex document?
User avatar
sommerfee
Posts: 503
Joined: Mon Apr 09, 2007 4:20 pm

Re: Supressing hyperref altering subref labels in captions

Post by sommerfee »

The counter KVtest will be defined by the subfig package so it seems that there is some subfig stuff left inside the auxiliary files (*.aux, *.lof, *.lot, ...) from the previous LaTeX run.

Since the error occurs inside comment.cut I assume the error will go away by either the next LaTeX run or after removing the auxiliary files (especially comment.cut).

P.S.: Unfortunately there isn't a central list of all float types. LaTeX wasn't designed that foresighted.
Post Reply