The formula for compounds containing polyatomic ions depends on the particular compound in question. There is no one standard formula for all compounds, although there is a standardized method for writing such formulas.
The accepted method for writing the formula for a compound containing a polyatomic ion is to write the cation followed by the anion with the number of ions required to bring the ion to a neutral charge displayed as a subscript outside parentheses. When a compound contains two or more of the same polyatomic ions, the standardized method for writing this formula is to show the ion inside parentheses. The number of times it occurs should appear as a subscript outside the parenthesis.