# How can I change the width of the subsection headings to 4 in?

I am using `\@startsection` in `pdflatex` to define the formatting of the subsection headings. I would like their width to be limited to `4in`, and centered. I can change the third item `{\z@}` to indent the left hand side, but it doesn't center. Is there another way of doing this?

``````\renewcommand{\subsection}
{\@startsection
{subsection}
{2}%
{\z@}%
{\li}%
{1pt}%
{\reset@font\centering\normalsize}}
``````
-
have a look at format-title-section-number-flush-left-and-title-centered/49320#49320; it's not exactly the same, but it's pretty close –  cmhughes Jul 4 '12 at 1:30
What about the subsection number? –  egreg Jul 4 '12 at 6:31

Using the titlesec package you can do this as follows, by first calculating the necessary margins:

``````\usepackage{titlesec}

\newlength{\mymargin}
\setlength{\mymargin}{0.5\textwidth}
This uses the default `hang` style with the label hanging to the left of the title. Use `\titleformat{\subsection}[block]{...}` to move the label in, so the first line as a whole is centered, or `[display]` to have the label on the line above.