0

To match a required format, I need to remove the space between numbers and captions in a list of figures and tables.

i.e. Turn this: table x:    Caption into this: table x: Caption

I already found the tocloft package and feel like it can do what I want, but altering \cftXaftersnumb seems to move the entire list of captions and I need to adjust each line individually.

\documentclass{report}
\usepackage{tocloft}
\usepackage{booktabs}

%%% Add Table XX: to list of tables
\renewcommand\cfttabpresnum{Table }
\renewcommand{\cfttabaftersnum}{:}
\renewcommand{\cfttabaftersnumb}{\hspace{-.5em}} % move caption to end of 100:
\setlength{\cfttabindent}{0pt}  % remove indentation from tables in lot

%%% Handle extra space in tof
\newlength{\mylenb} % a "scratch" length
\settowidth{\mylenb}{\cfttabpresnum\cfttabaftersnum} % extra space
\addtolength{\cfttabnumwidth}{\mylenb} % add the extra space

\begin{document}

\listoftables

\begin{table}[!ht]
    \centering
    \begin{tabular}{lllll }     
        \toprule        \footnotesize 
        One& Two  & Three  & Four  & Five  \\
        \midrule        
        2.35& 45.87  & 9.00  & 1.00  &0.33  \\
        \bottomrule
    \end{tabular}
    \caption{Another Table.}
    \label{tab:exp1}
\end{table}

\setcounter{table}{99} % blow up counter to triple digits
\begin{table}[!ht]
    \centering
    \begin{tabular}{ lllll}     
        \toprule    \footnotesize 
        One& Two  & Three  & Four  & Five  \\
        \midrule        
        2.35& 45.87  & 9.00  & 1.00  &0.33  \\
        \bottomrule
    \end{tabular}
    \caption{Another Table.}
    \label{tab:exp2}
\end{table}

\end{document}

Any help would be greatly appreciated. Thanks!

  • You would probably be happier with a tocloft solution. Otherwise, use {\def\numberline#1{Table #1:~}\listoftables}. – John Kormylo May 14 at 1:34
  • Thanks John Kormylo! That definitely does the desired thing! – Thad Haines May 14 at 18:50
  • On second thought, use {\def\numberline#1{\tablename~#1:\space}\listoftables}. Not that a break is likely, but you never know. – John Kormylo May 15 at 3:19

Your Answer

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

Browse other questions tagged or ask your own question.