Q:

Incorrect page number for LoA in ToC

I want to create a list of appendices at the end of my document, and add the corresponding entry and page number to the table of contents. 
The following code is a simplified version of my code (MWE), with dummy text applied. 
\documentclass{report}
\usepackage{setspace}
\usepackage{titlesec}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage{appendix}
\usepackage{lipsum}

\makeatletter   % start of 
\newcommand{\listappendixname}{Anhangsverzeichnis}
\newlistof{appendix}{apc}{\listappendixname}
\AtBeginEnvironment{appendices}{%
    \clearpage
    \addcontentsline{toc}{chapter}{Anhangsverzeichnis}
    \write\@auxout{%
        \string\let\string\latex@tf@toc\string\tf@toc% 
        \string\let\string\tf@toc\string\tf@apc% 
    }
}
\AtEndEnvironment{appendices}{%
    \write\@auxout{%
        \string\let\string\tf@toc\string\latex@tf@toc% 
    }
}
\makeatother

\begin{document}

\tableofcontents

%\nopagebreakchapter{bla bla}
\chapter{bla bla}
\lipsum[2-3]

\section{bla bla bla}
\lipsum[2-3]

\subsection{bla bla bla}
\lipsum[2-3]

\subsection{bla bla bla}
\lipsum[2-3]

\subsection{bla bla bla}
\lipsum[2-3]

\chapter{bla bla}
\lipsum[2-3]

\section{bla bla bla}
\lipsum[2-3]

\subsection{bla bla bla}
\lipsum[2-3]

\subsection{bla bla bla}
\lipsum[2-3]

\subsection{bla bla bla}
\lipsum[2-3]

% #############################################################################

\clearpage
\listofappendix

\begin{appendices}

\section{questions}
\lipsum[1]

\section{answers}
\lipsum[1]

\end{appendices}

\end{document}

In this example I expect the page number for the LoA to be 4, not 5 (assuming you use the parameter a4paper for the report class).  It seems to me that LaTeX is always selecting the page for the first chapter of the appendix.  How can I fix that? 

A:

Remove \addcontentsline{toc}{chapter}{Anhangsverzeichnis} from \AtBeginEnvironment{appendices}{...} and add
\preto{\cftafterapctitle}{%
    \addcontentsline{toc}{chapter}{\listappendixname}%
}

to your preamble. 
\documentclass{report}
\usepackage{setspace}
\usepackage{titlesec}
\usepackage{tocloft}
\usepackage{etoolbox}
\usepackage{appendix}

\makeatletter   % start of 
\newcommand{\listappendixname}{Anhangsverzeichnis}
\newlistof{appendix}{apc}{\listappendixname}
\preto{\cftafterapctitle}{%
    \addcontentsline{toc}{chapter}{\listappendixname}%
}
\AtBeginEnvironment{appendices}{%
    \clearpage
    \write\@auxout{%
        \string\let\string\latex@tf@toc\string\tf@toc% 
        \string\let\string\tf@toc\string\tf@apc% 
    }
}
\AtEndEnvironment{appendices}{%
    \write\@auxout{%
        \string\let\string\tf@toc\string\latex@tf@toc% 
    }
}
\makeatother

\usepackage{lipsum}% only for dummy text
\begin{document}
\tableofcontents
\chapter{bla bla}
\lipsum[1]
\section{bla bla bla}
\lipsum[2]
\subsection{bla bla bla}
\lipsum[3-7]

\clearpage
\listofappendix
\begin{appendices}
\section{questions}
\lipsum[1]
\section{answers}
\lipsum[2]
\end{appendices}
\end{document}

Result:

If you are option titles is used for package tocloft you have to patch  \listofappendix to get a TOC entry for the LOA:
\patchcmd\listofappendix
  {\chapter*{\listappendixname}}
  {\chapter*{\listappendixname}{\addcontentsline{toc}{chapter}{\listappendixname}}}
  {}{\PatchFailed}

If it should work with and without option titles use
\documentclass{report}
\usepackage{setspace}
\usepackage{titlesec}
\usepackage[titles]{tocloft}
\usepackage{etoolbox}
\usepackage{appendix}

\newcommand{\listappendixname}{Anhangsverzeichnis}
\newlistof{appendix}{apc}{\listappendixname}

\makeatletter
\if@cftnctoc% with option titles
  \patchcmd\listofappendix
    {\chapter*{\listappendixname}}
    {\chapter*{\listappendixname}{\addcontentsline{toc}{chapter}{\listappendixname}}}
    {}{\PatchFailed}
\else% without option titles
  \preto{\cftafterapctitle}{%
      \addcontentsline{toc}{chapter}{\listappendixname}%
  }
\fi

\AtBeginEnvironment{appendices}{%
    \clearpage
    \write\@auxout{%
        \string\let\string\latex@tf@toc\string\tf@toc% 
        \string\let\string\tf@toc\string\tf@apc% 
    }
}
\AtEndEnvironment{appendices}{%
    \write\@auxout{%
        \string\let\string\tf@toc\string\latex@tf@toc% 
    }
}
\makeatother

\usepackage{lipsum}% only for dummy text
\begin{document}
\tableofcontents
\chapter{bla bla}
\lipsum[1]
\section{bla bla bla}
\lipsum[2]
\subsection{bla bla bla}
\lipsum[3-7]

\clearpage
\listofappendix
\begin{appendices}
\section{questions}
\lipsum[1]
\section{answers}
\lipsum[2]
\end{appendices}
\end{document}

