# amsbook - customizing LOT and LOF

I have modified the LOT and LOF within the amsbook class so that the numbering reads, e.g., "Table 1.1" instead of just "1". My MWE below does this. However, it messes up the alignment of the captions: the first and second lines are not indented the same amount.

My questions are:

1. How can I align the captions in the LOT and LOF?
2. How can I also put in dots ... leading to the page numbers? (e.g., \@dottedtocline)

Please note that I must use amsbook, so I cannot use the tocloft package. Thank you for your advice.

\documentclass[12pt, oneside]{amsbook}

% Customize list of tables and list of figures
\usepackage{chngcntr} \counterwithin{figure}{chapter}
\counterwithin{table}{chapter}
\makeatletter
\def\l@figure#1#2{\@tocline{0}{3pt plus2pt}{0pt}{3pc}{}{Figure #1}{#2}}
\def\l@table#1#2{\@tocline{0}{3pt plus2pt}{0pt}{3pc}{}{Table #1}{#2}}
\makeatother

\begin{document}

\listoffigures

\begin{figure}
\caption[Caption in the LOF extends beyond one line, but the second line is not aligned with the first line.]{Long caption...}
\end{figure}

\end{document}

• What is the problem with the tocloft package when using the amsbook class? – user94293 May 19 '16 at 4:51
• Does tocloft work by adding in the preamble: \makeatletter \renewcommand{\@starttoc}[1]{\begingroup \makeatletter \@input {\jobname .#1}\if@filesw \expandafter \newwrite \csname tf@#1\endcsname \immediate \openout \csname tf@#1\endcsname \jobname .#1\relax \fi \@nobreakfalse \endgroup} \makeatother – user94293 May 19 '16 at 5:10
• Crosspost – Johannes_B May 19 '16 at 5:36
• @user94293 -- tocloft was developed to adapt the "standard" latex toc conventions for a particular purpose. other document classes use different conventions for the toc and related lists; the koma and ams classes are examples of classes using different conventions. tocloft incorporates code to deal with the differences in the koma classes, but there is no evidence that similar checks have been made for the ams classes. so basically, any existing incompatibilities are not known. if an ams author tries to use it and has problems, no support will be offered. – barbara beeton May 19 '16 at 15:03
• @user94293 -- i have just made a test with amsbook plus tocloft. it fails ignominiously with ! Missing } inserted. at the first encounter with actual text after \begin{document}. i am not inclined to try to figure out why. – barbara beeton May 19 '16 at 15:58

here is an example that should give the results you want with amsbook.

\documentclass{amsbook}
\usepackage{etoolbox}

\makeatletter
%\renewcommand\@pnumwidth{1em} % <-- depending on total number of pages
\patchcmd{\@tocline}
{\hfil}
{}{}
% Insert "Figure" or "Table" in "list of" entries
\newcommand\numberprefix{}
\def\numberline#1{\hb@xt@\@tempdima{\numberprefix #1\hfil}}
\def\l@figure#1#2{\@tocline{0}{3pt plus2pt}{0pt}{5pc}{}%
{\renewcommand\numberprefix{Figure~}#1}{#2}}
\def\l@table#1#2{\@tocline{0}{3pt plus2pt}{0pt}{5pc}{}%
{\renewcommand\numberprefix{Table~}#1}{#2}}
\makeatother

\begin{document}

\tableofcontents
\listoffigures
\listoftables

\chapter{test}

For TeX.sx question \#310359.

\section{section}
some text

\begin{figure}
some figure stuff
\caption{Test figure.  Make this a very long caption so that it will
be forced to a second line in the list of figures, to check
alignment.}
\end{figure}

\begin{table}
\caption{Test table}
some table stuff
\end{table}
\end{document}