# Tikz matrix not working the same in a titleformat command [duplicate]

Consider the following code:

\documentclass[oneside, 10pt]{book}
\usepackage[
paperwidth=6in,
paperheight=9in,
tmargin=0.75in,
bmargin=0.75in,
lmargin=0.75in,
rmargin=0.75in
]{geometry}
\usepackage{calc}
\usepackage{tikz}
\usepackage{etoolbox}
\usepackage{transparent}
\usepackage[explicit]{titlesec}
\usepackage{tikzpagenodes}
\usepackage[table]{xcolor}
\usetikzlibrary{calc}
\usetikzlibrary{matrix}
\pagestyle{empty}

\titleformat{\part}[display]{\normalfont\filcenter}{
\thispagestyle{empty}
\tikz[remember picture, overlay] {
\matrix [column sep = 5mm] at (current page text area.center) {
\node[
inner sep = 0pt,
outer sep = 0pt,
font = \sffamily\fontsize{24}{24}\selectfont
] {Part};
&
\node [
circle,
fill = black,
font = \sffamily\fontsize{24}{24}\bf\selectfont\color{white},
outer sep = 0pt,
minimum size = 1.5cm
] {\thepart};
\\};
}
}{6em}{
}[]

\begin{document}

\tikz[remember picture, overlay]{
\matrix [column sep=5mm] at (current page text area.center) {
\node[
inner sep = 0pt,
outer sep = 0pt,
font = \sffamily\fontsize{24}{24}\selectfont
] {Part};
&
\node[
circle,
fill = black,
font = \sffamily\fontsize{24}{24}\bf\selectfont\color{white},
outer sep = 0pt,
minimum size = 1.5cm
]  (numb) {I};
\\
};
}

\part{}

\end{document}


The result is the following:

Why is the first page different than the second, and how to make the titleformat work the same way as the normal tikz command? In other words, how to center "Part I" in the page on a single line as it is done on the first page? And why does it currently fail?

• You get errors from that code, so it shouldn't be a surprise that it fails. – Torbjørn T. Oct 17 '17 at 18:49
• tex.stackexchange.com/questions/1111: add ampersand replacement=\& to the matrix options, and use \& instead of & in the matrix. – Torbjørn T. Oct 17 '17 at 18:51
• – Torbjørn T. Oct 17 '17 at 18:53
• Replacing & by \pgfmatrixnextcell also works. Thanks. You can post your answer if you want me to validate it. – Vincent Oct 17 '17 at 18:54