ハイパーリファレンスがロードされたコンテンツ行を再定義する

ハイパーリファレンスがロードされたコンテンツ行を再定義する

以下の LaTeX コードは、2 回目の pdflatex でコンパイルに失敗します。hyperref パッケージを削除すると正常にコンパイルされますが、存在する場合はコンパイルに失敗し、次のエラーが表示されます。

(./master.out) (./master.out) (./master.toc) [1{/var/lib/texmf/fonts/map/pdftex /updmap/pdftex.map}] [2] (./master.lot ! \contentsline の引数に余分な } があります。 \par l.3 \contentsline {table}{\numberline {1.1}{\ignorespaces 私の表のキャプション...

どうすれば解決できますか?

\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}

関連情報