Text Formattingamsbook - customizing LOT and LOF

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
n_77
Posts: 1
Joined: Thu May 19, 2016 2:26 am

amsbook - customizing LOT and LOF

Post by n_77 »

Hello,

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.

Code: Select all

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

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

amsbook - customizing LOT and LOF

Post by Johannes_B »

This was crossposted on TeX.SX, where Barbara Beeton added an answer.
Barbara Beeton wrote:here is an example that should give the results you want with amsbook.

Code: Select all

    \documentclass{amsbook}
    \usepackage{etoolbox}
    
    % Leader dots in toc
    \makeatletter
    %\renewcommand\@pnumwidth{1em} % <-- depending on total number of pages
    \patchcmd{\@tocline}
      {\hfil}
      {\leaders\hbox{\,.\,}\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}

The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply