1

When running the following MWE:

\documentclass{memoir}
\usepackage{graphicx}
\newsubfloat{figure}
\usepackage[draft]{showkeys}
%\usepackage{bookmark}
\begin{document}
\begin{figure}[htb]
    \centering
    \subbottom[A\label{fig:examplea}]{\includegraphics[width=0.49\columnwidth]{example-image-a}}
    \subbottom[B\label{fig:exampleb}]{\includegraphics[width=0.49\columnwidth]{example-image-b}}
    \caption{Example A and B}
    \label{fig:examples}
\end{figure}
\end{document}

I get: enter image description here

However if i uncomment the bookmark package (as below):

\documentclass{memoir}
\usepackage{graphicx}
\newsubfloat{figure}
\usepackage[draft]{showkeys}
\usepackage{bookmark}
\begin{document}
\begin{figure}[htb]
    \centering
    \subbottom[A\label{fig:examplea}]{\includegraphics[width=0.49\columnwidth]{example-image-a}}
    \subbottom[B\label{fig:exampleb}]{\includegraphics[width=0.49\columnwidth]{example-image-b}}
    \caption{Example A and B}
    \label{fig:examples}
\end{figure}
\end{document}

I instead end up with: enter image description here

Is there a way to show the keys on the subbottom picture while also having the bookmarks picture?

If the way is to update from TeXlive 2016 to 2017 i'll do so in a few day's, but can't do it right now

  • Is it an interaction between the \usepackage[draft]{showkeys} and the bookmarks package? – Peter Wilson Jun 10 '17 at 20:03
  • @PeterWilson same result with and without the [draft] option, only the bookmark package seems to affect it – Thorbjørn E. K. Christensen Jun 10 '17 at 21:04
  • bookmark loads hyperref, and when hyperref is active \label inside \subbottom behaves differently, they actually does not use \label at all, so the hook that showkeys adds inside \label never triggers. – daleif Jun 12 '17 at 8:20
  • 1
    Hmm, more complicated than than. We just need to inject \SK@\SK@@label{#1}} after \@bsphack in the proper version of \sf@@memsub@label. But etoolbox cannot handle this because of the #1, trying other methods – daleif Jun 12 '17 at 8:40
  • 1
    Shorter patch added – daleif Jun 12 '17 at 10:36
1

Until I find a way to make a short patch, here is something that seems to work

\makeatletter
\AtBeginDocument{
  \@ifpackageloaded{hyperref}{%
    \@ifpackageloaded{showkeys}{%
      \renewcommand*{\sf@@memsub@label}[1]{%
        \@bsphack
        \SK@\SK@@label{#1}% <-- added
        \protected@write\@auxout{}{%
          \string\newlabel{#1}%
          {{\@nameuse{p@sub\@captype}\@nameuse{@@thesub\@captype}}%
            {\thepage}%
            {\mem@currentlabelname\relax}%
            {\@currentHref}{}}}%
        \protected@write\@auxout{}{%
          \string\newlabel{sub@#1}%
          {{\@nameuse{@@thesub\@captype}}%
            {\thepage}%
            {\mem@currentlabelname\relax}%
            {\@currentHref}{}}}%
        \@esphack}
    }{}
  }{}
}
\makeatother

Update with a shorter patch

% experimental, may change
\usepackage{regexpatch}
\makeatletter
\AtBeginDocument{
\makeatletter
\regexpatchcmd{\sf@@memsub@label}{\c{@bsphack}}{%
   \c{@bsphack}\c{SK@}\c{SK@@label}\cB\{\cP\#1\cE\}
}{ \typeout{success} }{ \typeout{failure} }
\makeatother
}
\makeatother
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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