[Tex/LaTex] Indention of partial TOC (titletoc)

indentationtable of contentstitletoc

I'm happily using this solution I asked for few days ago:
Two independent TOCs

Now a follow-up question appeared:
My second TOC contains only \subsubsection and deeper nested elements till \subparagraph because of some structure I want to acchieve in my TOC and PDF-Bookmarks. I modified the appearance of those elements to match my desired layout with \renewcommand\thesubsection{\Alph{subsection}}.

So my question is how to tweak the layout of my second TOC. It looks like sections and subsections, but it doesn't behave this way in the second TOC. I want to get rid of those indentions, the second TOC should start on the left side (MWE below):

example of second TOC with heavy indentions

The first TOC should not be affected by those settings.

My last attempt was to use \renewcommand*\l@subsubsection{\bprot@dottedtocline{1}{1.5em}{2.3em}} after the \printcontents[sections]{ }{2}{} to set the subsubsection with the values of the section, but this had no effect at all.

Here is my (not so minimal) working example demonstrating the behaviour. I left some comments in it to show different approches I tried, but without success.

Thank you very much.

\documentclass[paper=A4,%
        pagesize=auto,%
        fontsize=11pt,%
        DIV=19,%
        tocleft,%
        bibliography=totocnumbered,%
        listof=numbered,
        titlepage]{scrartcl} 

\usepackage[ngerman]{babel}
\usepackage[latin1]{inputenc}   
\usepackage[babel,german=quotes]{csquotes}  %% deutsche Anfuehrungsstriche
\usepackage[T1]{fontenc}

\usepackage[titles]{tocloft}  %% Einr├╝ckungen beim Appendix im Titel

\usepackage{titletoc}  %% zwei Inhaltsverzeichnisse
\setcounter{secnumdepth}{5}
\setcounter{tocdepth}{5}

\usepackage{titlesec}
%%\titleformat{\paragraph}[hang]{\normalfont\bfseries}{}{0pt}{}
\titlespacing{\paragraph}{0mm}{15pt}{3pt}  %% 30pt


%%\titlecontents{paragraph}[1.5em]{\addvspace{1pc}\bfseries}{\contentslabel{5em}}{}
%%    {\titlerule*[0.3pc]{.}\contentspage}


%% http://www.latex-community.org/forum/viewtopic.php?f=5&t=1383
\makeatletter
\renewcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
    {-3.25ex\@plus -1ex \@minus -.2ex}%
    {1.5ex \@plus .2ex}%
    {\normalfont\normalsize\bfseries}}
\makeatother

\renewcommand{\figurename}{\textbf{Abb.}}   %% ersetzt Abbildung durch Abb.

%%%%%%%%%%%% hyperref und pdf-Einstellungen Start %%%%%%%%%%%%
\usepackage{hyperref}
\hypersetup{
        pdfauthor={xxx},%
        pdftitle={Exxx},%
        pdfsubject={xxx},%
        pdfcreator={xxx},%
        %%pdfproducer=meinproducer,%   %% ersetzt pdfTeX-Versions-Info
        pdfkeywords={xxx},%
        bookmarksnumbered=true,%
        plainpages=false,%
        linktoc=all,
        %%pdfpagelabels=true,%
        hypertexnames=false,%
        %%%pdfborder={0 0 0},%
        pdfborderstyle={/S/U/W 1},%   %% setzt Unterstrich mit Dicke 1pt
        colorlinks=true,%   %% false
}

%% farbige Links im PDF mit Unterstreichung
%% von https://tex.stackexchange.com/questions/26071/how-can-i-have-colored-and-underlined-links-with-hyperref
\makeatletter
\Hy@AtBeginDocument{%
    \def\@pdfborder{0 0 1}% Overrides border definition set with colorlinks=true
    \def\@pdfborderstyle{/S/U/W 1}% Overrides border style set with colorlinks=true
                                                                % Hyperlink border style will be underline of width 1pt
}
\makeatother


\usepackage[all]{hypcap}  %% fixt Link zum Start einer Grafik, nicht zur darunterliegenden Caption
%%%%%%%%%%%% hyperref und pdf-Einstellungen Ende %%%%%%%%%%%%


%% more space for roman numbers in TOC
%% http://www.komascript.de/node/608
\makeatletter% 
\renewcommand*{\@pnumwidth}{3.0em}
\makeatother% 

%% for appendix 
%%\makeatletter% 
%%\g@addto@macro\appendix{%
%%  \pagenumbering{Roman}%
%%  \addtocontents{toc}{\protect\renewcommand*{\protect\@pnumwidth}{2em}}%
%%}
%%\makeatother% 


\begin{document}

My document.

\pdfbookmark[1]{~~~~My TOC}{toc}

\startcontents
\printcontents{ }{1}{}

\setcounter{page}{1}

\section{first section}
foo bar
\subsection{first subsection}
foo bar
\section{last section before appendix}
foo bar
\subsection{some subsection}
foo bar
\subsection{some subsection}
voo bar
\newpage
%% START APPENDIX
\appendix  
\pagenumbering{Roman}
\renewcommand\thesubsection{\Alph{subsection}} 

\phantomsection
\addcontentsline{toc}{section}{Anhang} 
\section*{Anhang}
\markboth{Anhang}{Anhang}

\subsection{and just another subsection}

\subsection{and another subsection}

\subsection{Sources}

\stopcontents

%% START SECOND TOC
\startcontents[sections]
Here is all the sourcecode.
\printcontents[sections]{ }{2}{}

%% see https://tex.stackexchange.com/questions/33841/how-to-modify-the-indentation-before-sectioning-titles-in-the-table-of-contents
\makeatletter
\renewcommand*\l@subsubsection{\bprot@dottedtocline{1}{1.5em}{2.3em}}  %% values of section
\renewcommand*\l@paragraph{\bprot@dottedtocline{2}{1.5em}{2.3em}}      %% old values: 3.8em   3.2em     %% values of subsection
\renewcommand*\l@subparagraph{\bprot@dottedtocline{3}{7.0em}{4.1em}}   %% values of subsubsection
\makeatother

%% needs tocloft, there is no difference with these lines
%%\setlength{\cftsecindent}{2.4cm}
%%\setlength{\cftparaindent}{1.3em}  %% 2.4 cm versetzt den gesamten TOC-Eintrag (Kapitelnummer und Titel) nach links oder rechts
%%\setlength{\cftparanumwidth}{0.5cm} %% Breite der Zahl vor dem Titel
%%\setlength{\cftbeforeparaskip}{-2cm}   %% zieht das TOC insgesamt nach oben

\setcounter{subsection}{3}

\subsubsection{SQL}

\paragraph{create some tables}
bla
\subparagraph{deepest}
a lot of code

\subsubsection{PHP}
\subsubsection{JavaScript}

\stopcontents[sections]
\resumecontents

\subsection{some more}

\begingroup
    \renewcommand*\section{\subsection}  %% changing for the dynamic created 
    \listoffigures
    \listoftables
\endgroup

\subsection{last subsection}
Finally.
\stopcontents

\end{document}

Best Answer

Moving the redefinition to before \printcontents[sections]{ }{2}{} works for me.

Related Question