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'm writing a paper for a conference that requires section headings to have a certain format, with the font size specified in points. There seem to be two packages for changing the fonts of section headings, titlesec and sectsty. However, with sectsty I can't work out how to make subsubsection headings non-bold (which I also need), and with titlesec I can't see how to specify the font size in points, rather than just as "big", "medium", etc.

For completeness, what I need to do is this:

  • typeset \section headings in 11pt bold

  • typeset \subsection headings in 10pt bold

  • typeset \subsubsection headings in 10pt roman

  • remove the whitespace following \subsection and \subsubsection headings.

What is the best way to achieve these effects, using either package?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

With sectsty it's difficult to change the spacings; with titlesec one has to rebuild all headings. Probably copying the definitions from article.cls and modifying them is the easiest way:

\documentclass{article}

\makeatletter
\renewcommand\section{%
  \@startsection{section}{1}
                {\z@}%
                {-3.5ex \@plus -1ex \@minus -.2ex}%
                {2.3ex \@plus.2ex}%
                {\normalfont\fontsize{10.95}{13.6}\bfseries}% 11pt
}
\renewcommand\subsection{%
  \@startsection{subsection}{2}
                {\z@}%
                {-3.25ex\@plus -1ex \@minus -.2ex}%
                {1sp}% No space after subsections
                {\normalfont\normalsize\bfseries}% normal size, boldface
}
\renewcommand\subsubsection{%
  \@startsection{subsubsection}{3}
                {\z@}%
                {-3.25ex\@plus -1ex \@minus -.2ex}%
                {1sp}% No space after subsubsections
                {\normalfont\normalsize}% normal size, medium
}
\makeatother

\usepackage{lipsum} % to provide mock text

\begin{document}
\section{This is large boldface}
\lipsum[2]
\subsection{This is normal size boldface}
\lipsum[2]
\subsubsection{This is normal size medium}
\lipsum[2]
\end{document}

enter image description here

The 1sp for getting zero space is just a trick: if we put 0pt, the heading would be in line (an optimization trick used by LaTeX not to increase the number of arguments). But 1sp is just indistinguishable from zero.

share|improve this answer
    
Thanks, this looks great. I'll leave the question open for a bit in case someone has a better answer (this one feels like a little bit of a hack, but that's nitpicking), and if not I'll accept this. By the way, where do the numbers come from in the \fontsize{10.95}{13.6} command? –  Nathaniel Nov 8 '12 at 13:01
    
@Nathaniel They come from the setting used from LaTeX for 11pt type size (see the file size11.clo). The interline skip (13.6pt) is relevant only if the section title needs to be split across lines. –  egreg Nov 8 '12 at 13:13
add comment

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.