[Tex/LaTex] Spacing in list of figures / tables for entries from appendices

appendicesspacingtable of contentstocloft

Having made the changes Werner very helpfully suggested in the Separate table of appendices – pdf bookmarks & avoid previous chapter's format, my list is up and running but I have some spacing problems.

I now have an extra space before my figure and table numbers from the appendices. For example, A.1 in the table of contents. This means it no longer lines up with the lines from the main chapters. In the entry in the .lot file there is a space before { A.1}.

Misaglined List of Tables/Figures with entries from appendeices

Here is the a minimal working example (or at least my best shot at it):

\documentclass[]{ut-thesis}
\usepackage{tocloft}
\usepackage[colorlinks=true, allcolors=black]{hyperref}

\begin{document}


\newcommand{\listappendixname}{List of Appendices}
\newlistof{appendix}{app}{\listappendixname}
\setcounter{appdepth}{2}    
\renewcommand{\theappendix}{\Alph{appendix}}
\renewcommand{\cftappendixpresnum}{Appendix\space}
\setlength{\cftbeforeappendixskip}{\baselineskip}
\setlength{\cftappendixnumwidth}{1in}
\newlistentry[appendix]{subappendix}{app}{1}
\renewcommand{\thesubappendix}{\theappendix.\arabic{subappendix}}
\renewcommand{\cftsubappendixpresnum}{Appendix\space}
\setlength{\cftsubappendixnumwidth}{1in}
\setlength{\cftsubappendixindent}{0em}

\newcommand{\myappendix}[1]{%
  \refstepcounter{appendix}\pdfbookmark[1]{#1}{#1\theappendix}%
  \chapter*{Appendix \theappendix\space #1}%
  \addcontentsline{app}{appendix}{\protect\numberline{\theappendix}#1}%
  \markboth{}{\MakeUppercase{Appendix}\ \theappendix\space #1}\par
}

\newcommand{\subappendix}[1]{%
  \refstepcounter{subappendix}\pdfbookmark[2]{#1}{#1\thesubappendix}%
  \section*{\thesubappendix.\space #1}%
  \addcontentsline{app}{subappendix}{\protect\numberline{\thesubappendix}#1}%
}


\begin{preliminary}

\listoftables
\listoffigures

\end{preliminary}


\chapter{Objective}
\section{Get it done}
\begin{figure}
\caption[Short name for a figure]{Loooong name for the figure with lots of explanation}
\end{figure}
\begin{table}
\caption[Short name for my table]{Loooong name for the my  with lots of explanation}
\end{table}

\appendix
\clearpage \phantomsection
\addcontentsline{toc}{chapter}{Appendices}
\renewcommand{\thefigure}{ \theappendix.\arabic{figure}}
\renewcommand{\thetable}{ \theappendix.\arabic{figure}}

\myappendix{VBA code for Extension of Jaccard Measure}
\label{chap:code}
\begin{figure}
\caption[Code for functions that do this and that]{}
\end{figure}
\begin{table}
\caption[Table showing not very much]{}
\end{table}

\end{document}

Best Answer

There are spurious blank spaces in the redefinition of \thefigure and \thetable; use:

\renewcommand{\thefigure}{\theappendix.\arabic{figure}}
\renewcommand{\thetable}{\theappendix.\arabic{figure}}

(in both cases I removed the blank spaces before \theappendix).