I have a problem with combining titlesec and etoc, are they compatible? I want to use formating from titlesec and then after part title, on the same page, I want to add local table of contents. However my result for now is an empty Content. I have the following formating from titlesec:

 \titleformat{\part}[frame]
{\normalfont\color{gray}}
{\filright
\enspace \large PART \thepart\enspace}
{20pt}
{\Huge\bfseries\filcenter\color{black}}
[{\localtableofcontents*
}]


It works when I put manualy \localtableofcontents* after \part{...} command. However then \localtableofcontents* is on the next page, I want it on the same page just after part title. Thanks in advance!

Testing with this mwe:

\documentclass{article}
\usepackage{color}
\definecolor{gray}{gray}{0.75}
\usepackage{titlesec}
\usepackage{etoc}\etocsettocstyle{}{}
\titleformat{\part}[frame]
{\normalfont\color{gray}}
{\filright
\enspace \large PART \thepart\enspace}
{20pt}
{\Huge\bfseries\filcenter\color{black}}
[\localtableofcontents]
\begin{document}
%\errorcontextlines5
%\tracingmacros1
\part{first part}
\section{A}
\section{B}
\section{C}

\part{second part}
\section{U}
\section{V}
\section{W}

\end{document}


shows two problems:

1. titlesec complains about "nested titles", because \localtableofcontents will use some \section*. I added \etocsettocstyle{}{} to suppress that.

2. the more serious problem is that titlesec's version of \part will do \addcontentsline{toc}{part}... after executing the "after-code" part, i.e. after \localtableofcontents gets executed. This means that etoc mechanism to delimit local table of contents is broken, because etoc can not know it is after a \part.

Thus, 2. looks definitive. You can't do this. Simply insert \localtableofcontents manually in the appropriate locations after having forcibly convinced titlesec by whatever means you find most convenient to not do a \clearpage (according to your question which did not say which document class you are using). There is no problem with article class as in this example:

\documentclass{article}
\usepackage{color}
\definecolor{gray}{gray}{0.75}
\usepackage{titlesec}
\usepackage{etoc}\etocsettocstyle{\color{gray}}{}
\titleformat{\part}[frame]
{\normalfont\color{gray}}
{\filright
\enspace \large PART \thepart\enspace}
{20pt}
{\Huge\bfseries\filcenter\color{black}}
\begin{document}
\part{first part}
\localtableofcontents
\section{A}
\section{B}
\section{C}

\part{second part}
\localtableofcontents
\section{U}
\section{V}
\section{W}

\end{document}