Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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}}
share|improve this question
    
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

1 Answer 1

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}
\addtolength{\mymargin}{-2in}

\titleformat{\subsection}{\normalfont\fillast}{\thesubsection}{1ex
minus .1ex}{}
\titlespacing{\subsection}{\mymargin}{*3.25}{*1.5}[\mymargin]

Sample output

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.