Does a (nice) centerless group always have a centerless profinite completion?

This is an extension of a question I asked here on Math.SE

Assume that I have a finitely generated residually finite centerless group $$G$$. Is it true that the profinite completion $$\hat{G}$$ also has trivial center?

In the linked question, user YCor was able to show that this fails in general if you do not assume either finite generation or residually finite. However, the result happens to be true if $$G$$ is a surface group. I’d like to know if this is a phenomenon specific to surface groups, or if this is a more general fact.

The answer is No in general. Let $$n\geq 3$$ be odd (it is not necessary that $$n$$ be odd) and suppose $$G=\mathrm{SL}_n({\mathbb Z})$$. There exists a subgroup $$\Gamma \subset \mathrm{SL}_n({\mathbb Z})$$ of finite index which is torsion-free and centreless (the centre can only be $$\pm 1$$ and because $$n$$ is odd the centre can only be trivial). However, $$\mathrm{SL}_n({\mathbb Z})$$ has the congruence subgroup property which means that we have the following inclusion of the profinite completions:
$$\widehat {\mathrm{SL}_n({\mathbb Z})}= \prod _{q \; \mathrm{prime}} \mathrm{SL}_n({\mathbb Z}_q)\supset \widehat {\Gamma} \supset \prod _{p\in S} U_p \times \prod _{ \ell \notin S} \mathrm{SL}_n({\mathbb Z}_\ell),$$ where $$S$$ is a finite set of primes, $$U_p$$ is an open subgroup of finite index in $$\mathrm{SL}_n({\mathbb Z}_p)$$, and $$\ell$$ runs through primes in the complement of $$S$$. Since for infinitely many $$\ell$$ (for example, all $$\ell$$ with $$\ell\equiv 1 \; (\mathrm{mod}\;n)$$), the group $$\mathrm{SL}_n({\mathbb Z}_\ell)$$ has $$n$$-th roots of unity in the centre, it follows that the profinite completion of $$\Gamma$$ is not centreless.
• Great. It seems to work for every finite index subgroup of $\mathrm{SL}_n(\mathbf{Z})$ when $n$ is odd, including $\mathrm{SL}_n(\mathbf{Z})$ itself (and for all centerless finite index subgroups, for arbitrary $n\ge 3$). – YCor Jun 9 at 16:56
• @YCor: thanks for the comment. Yes, torsion free is not assumed by the OP, so it works for every finite index subgroup if $n\geq 3$ is odd. – Venkataramana Jun 10 at 1:17