# TOC Dotted line in line with heading

I am working on an article that uses the command \paragraph{Heading}, because I need a deep heading structure within my appendices, to represent a directory structure containing code. This code will be listed inside the appendices.

I include this directory structure as a tree diagram and the readers will have access to the file structure itself, which is well organised, so I have decided that (although considered, rightly, but some as untidy) adding the extra TOC level is worth it in this case.

However, the TOC appears like this:

============================================

section................ 1

subsection............. 1

subsubsection.......... 2

paragraph
3

============================================


Using this MWE:

\documentclass[a4paper]{article}
%% Language and font encodings
\usepackage[english]{babel}
\usepackage[autostyle]{csquotes}

\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\newcommand\subsubsubsection[1]{\paragraph{\textit{{#1}}~\\}}
\begin{document}
\tableofcontents
\section{this}
\subsection{that}
\subsubsection{the other}
\appendix
\section{this}
\subsection{that}
\subsubsection{the other}
\subsubsubsection{this is a pain though}
\end{document}


When I want the levels to be similar, the 'paragraph' dotted lines are below the heading. How can I fix this?

• Please provide the document that generates this. ASCII - 'Art' like above is not really useful. – user31729 Mar 27 '17 at 9:18
• Please see my edit. – user3235290 Mar 27 '17 at 10:34
• Do you really need the \\  in \subsubsubsection? – user31729 Mar 27 '17 at 10:47

As @ChristianHupfer pointed at, by adding a linebreak (\\) in your command definition, you are in fact causing the issue. By simply removing it, your ToC will behave properly.

I had the same issue with non-existing subsubsubsection so I used a custom command (found somewhere in here): \newcommand{\subsubsubsection}[1]{\paragraph{#1}\mbox{}\par}

### MWE

\documentclass{article}
\usepackage{mwe}
\setcounter{secnumdepth}{4}
\setcounter{tocdepth}{4}
\newcommand{\subsubsubsection}[1]{\paragraph{\textit{#1}}\mbox{}\par}
\begin{document}
\tableofcontents
\section{Section}
\lipsum[1]
\subsection{Subsection 1}
\lipsum[2]
\subsection{Subsection 2}
\lipsum[3]
\subsubsection{Subsubsection 1}
\lipsum[4]
\subsubsubsection{Subsubsubsection}
\lipsum[5]
\subsubsection{Subsubsection 2}
\lipsum[6]
\end{document}

• (+1) for this (since the OP does not have enough reputation yet) – user31729 Mar 27 '17 at 12:01