TransWikia.com

Why is autoref displaying a blank space in place of the "figure" text when referencing

TeX - LaTeX Asked by UndisclosedCurtain on July 20, 2021

I am currently writing my masters thesis and ran into a little problem.

I have created a figure consisting of three smaller figures, each with their own subtexts, rendering the figures as 4.1a, 4.1b and 4.1c. When referencing these figures by the autoref command, I get the result ( 4.1a), when the expecpted result would be (Figure 4.1a).

When referencing standalone figures earlier, the referencing works as expected. Figure 4.1 does show up in my list of figures, and refs do ref to the correct figures.

Why does this happen, and what can I do to fix it?

The figure:

begin{figure}[H]
centering
subfloat[centering The evolution of the Figma market share in comparison to competitors following its release.]{includegraphics[width=0.40textwidth]{figures/prototype/tools/PrototypingNEW.PNG}
label{fig:figmaevolution}
}
qquad
subfloat[centering Figma's market share for UI Prototyping, in comparison to the market in which it competes. ]{includegraphics[width=0.49textwidth]{figures/prototype/tools/Prototyping2NEW.PNG}
label{fig:figmafourtimes}
}
qquad
 subfloat[centering Results from each individual surveyed category, showing Figma as the clear collective victor. ]{includegraphics[height=0.55textwidth]{figures/prototype/tools/FigmaDominance.PNG}
label{fig:figmadominance}
}
caption{Results of UX/UI Survey 2020. Displays Figmas relative market share and versatility.}
label{fig:figmafigure}
end{figure}

One Answer

Whatever else you do, you must delete stepcounter{fig:figmafigure} since this instruction throws an error message.

It would appear that you're using the subfig package. If this assumption is correct, you need to provide the instruction

providecommand{subfigureautorefname}{Figure}

in order to tell autoref which prefix is should use when processing autoref{fig:figmaevolution}. And, do place the subfigures' label directives inside the [...] parts.

That said, you may want to employ the cleveref package and its user-level macro cref instead of autoref. For cref can do just about anything that autoref does, just better. For instance, cref can take multiple arguments, whereas autoref can not; see the example code below for an application.

Incidentally, I can see no valid reason for using doubled sets of curly braces to enclose the includegraphics statements; single curly braces will do just fine. Last but not least, you must place label{fig:figmafigure} after caption{} if you intend the cross-reference the entire figure somewhere in the document.

enter image description here

documentclass{book} 
usepackage{subfig}
usepackage[demo]{graphicx} % remove 'demo' option in real document
usepackage[justification=centering]{caption} % optional

usepackage{hyperref}
providecommand{subfigureautorefname}{Figure} % <-- new
hypersetup{colorlinks,allcolors=blue} % optional

usepackage[nameinlink,noabbrev,capitalize]{cleveref} % optional
begin{document}

setcounter{chapter}{4} % just for this example
setcounter{section}{1} % just for this example
begin{figure}[ht!]     % '[ht!]' is safer than 'H'
centering

subfloat[Evolution of Figma's market share in comparison to its competitors', following its release.%
   label{fig:figmaevolution}]%
   {includegraphics[width=0.475textwidth]{figures/prototype/tools/PrototypingNEW}}% % no need to specify '.png' extension
hfill  % "hfill" is better (and more robust!) than "qquad"
subfloat[Figma's market share for UI Prototyping, in comparison to the market in which it competes.%
   label{fig:figmafourtimes}]%
   {includegraphics[width=0.475textwidth]{figures/prototype/tools/Prototyping2NEW}}

subfloat[Results from each individual surveyed category, showing Figma as clear collective victor.%
   label{fig:figmadominance}]%
   {includegraphics[height=0.55textwidth]{figures/prototype/tools/FigmaDominance}}

caption{} label{fig:figmafigure}
%% stepcounter{fig:figmafigure}  % this instruction throws an error 
end{figure}

A cross-reference to autoref{fig:figmaevolution}.

Cross-references to cref{fig:figmaevolution,fig:figmadominance}.
end{document}

Correct answer by Mico on July 20, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP