Per my question here, I have added a \caption inside a \wrapfigure representing a sidebar so that I can later refer to it using \nameref{name}. However, I now see the caption above the sidebar title:
Is there a way I can declare a caption but not actually have it display anything, for no reason other than being able to refer users to it via a \nameref?
I thought of changing my environment so that it uses \caption*{} to output the sidebar's title, but then the \ref{} no longer picks it up correctly (it instead picks up the current chapter).
Here is a complete example:
\documentclass{book}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{hyperref}
\usepackage{color}
\newcommand{\dummy}{}
\newenvironment*{lsidebar}[2][0.5]
{
\renewcommand{\dummy}{#1}
\wrapfigure{l}{#1\textwidth}
\caption{#2}
\rule{#1\textwidth}{1pt}
\rule{#1\textwidth}{18pt}
\vspace{-18pt}
\centerline{\textcolor{white}{#2}}
\vspace{5pt}
\footnotesize
\leftskip=5pt
\rightskip=5pt
\setlength{\parskip}{0.2cm}
\setlength{\parindent}{0pt}
}
{
\leftskip=0pt
\rightskip=0pt
\setlength{\parindent}{0pt}
\rule{\dummy\textwidth}{1pt}
\rule[.19in]{\dummy\textwidth}{2.5pt}
\endwrapfigure
}
\begin{document}
\chapter{First}
\label{ch:First}
\begin{lsidebar}{Example Sidebar}
\label{sb:Example}
An example sidebar.
\end{lsidebar}
Refer to sidebar \nameref*{sb:Example}.
\end{document}
This is what gets displayed:
Note the redundant "Figure 1.1: Example Sidebar" above the sidebar.


