Redefinindo a linha de conteúdo com hiperref carregado

Redefinindo a linha de conteúdo com hiperref carregado

O código latex abaixo não é compilado na 2ª rodada do pdflatex. Se eu remover o pacote hyperref ele compila bem, porém se estiver lá, ele falha na compilação e reclama dando esse erro

(./master.out) (./master.out) (./master.toc) [1{/var/lib/texmf/fonts/map/pdftex /updmap/pdftex.map}] [2] (./ master.lot ! O argumento de \contentsline tem um } extra \par l.3 \contentsline {table}{\numberline {1.1}{\ignorespaces Legenda da minha tabela...

Como posso resolver isso?

\documentclass[twoside,a4paper]{memoir}
\usepackage{hyperref}

\renewcommand\mempostaddchaptertotochook{%
  \addchaptertoloft{lof}%
  \addchaptertoloft{lot}%
}
\def\addchaptertoloft#1{% 
   \addtocontents{#1}{% 
     \protect\xcontentsline{chapter} 
      {\chaptername\ \thechapter\protect\nopagebreak\protect\vspace{1ex}}{}}}
\makeatletter
\def\xcontentsline#1#2#3{\@ifnextchar\contentsline 
  {\contentsline{#1}{#2}{#3}}{}} 
\makeatother


\begin{document}

\cleardoublepage
\tableofcontents
\cleardoublepage
\listoftables
\cleardoublepage

\chapter{Chapter}

\begin{table}
  \centering
  \caption{My table's caption}
    \begin{tabular}{l c c} 
        \hline
        column 1 & column 2 & column 3 \\
        \hline
        r1 & r2 & r3 \\
        r1 & r2 & r3 \\
        r1 & r2 & r3 \\
        r1 & r2 & r3 \\
        \hline
    \end{tabular}
\end{table}

\end{document}

informação relacionada