One thing you can do relatively easily in sectsty is make the section
numbering to be visible in the margins, with the section titles lined up
with the text -- looks pretty slick (IMO):
\usepackage{sectsty}
\makeatletter\def\@seccntformat#1{\protect\makebox[0pt][r]{\csname
the#1\endcsname\hspace{11pt}}}\makeatother
However, I was wondering if there is a way to do this within titlesec?
(Basically, I'd like to accomplish this, while using some of the other
options/controls provided by titlesec, which don't seem available in
sectsty). I know I can do something like the following in titlesec
\titlespacing*{\section}{-2em}{18pt}{10pt}[10pc]
but that doesn't automatically align the section titles and the text.
Suggestions?
Thanks...
\usepackage{titlesec}
\titleformat{\section}
{\normalfont\Large\bfseries}{\makebox[0pt][r]{\thesection}}{1.3em}{}
\titlespacing*{\section}{-2em}{3.5ex plus 1ex minus .2ex}{2.3ex plus
.2ex}
(not totally automatic, since the spacing is determined by the 1.3em,
but you only have to figure it out once, I guess.)
Alan
This titlespacing command can be replaced with yours. It's really only
the \titleformat command that needs to be changed as I indicated.
Alan
titleSeX and SeXty are both pretty sexy !
> significant control over the formatting of section titling. However,
> each of them has their own pros/cons.
>
> One thing you can do relatively easily in sectsty is make the section
> numbering to be visible in the margins, with the section titles lined up
> with the text -- looks pretty slick (IMO):
You can use \rlap to put the label (ie the section number) into the
margin: Here an example (with interfaces, but you can use \titleformat)
% -----------------------------------------------------
\documentclass{article}
\usepackage{titlesec}
\usepackage{interfaces,lipsum}
%\titlespacing*{\section}{-2em}{18pt}{10pt}[10pc]
\sectionformat\section{
label=\rlap{\arabic{section}}, % put the label in the margin
left=-1cm,
labelsep=1cm,
top=18pt,
bottom=10pt,
right=10pc, % useless
}
\begin{document}
\section{un}
\lipsum[5]
\end{document}\endinput
% ------------------------------------------------
Well:
\usepackage{interfaces}[2010/12/07]
=> version 2.5 Release. Update if necessary.
http://www.tex.ac.uk/tex-archive/help/Catalogue/entries/interfaces.html
Regards.
Using em units is dangerous, since the em depends on the current font:
\titleformat{\section}
{\normalfont\Large\bfseries}
{\makebox[1pc][r]{\thesection\hspace{1pc}}}
{0pt}
{}
\titlespacing*{\section}
{-1pc}{18pt}{10pt}[10pc]
This solves Alan Munn's puzzle: he used the \Large\bfseries em
in \titleformat and the \normalfont em in \titlespacing.
Ciao
Enrico