Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

titlesec vs sectsty

1,154 views
Skip to first unread message

coo...@nospam.verizon.net

unread,
Dec 16, 2010, 10:15:30 PM12/16/10
to
It seems to me that the titlesex and sectsty packages both provide
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):


\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...

Alan Munn

unread,
Dec 16, 2010, 10:40:27 PM12/16/10
to
In article <ieekkf$1uu$1...@ruby.cit.cornell.edu>,
coo...@NOSPAM.verizon.net wrote:

\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

Alan Munn

unread,
Dec 16, 2010, 10:43:11 PM12/16/10
to
In article <amunn-F761C3....@news.eternal-september.org>,
Alan Munn <am...@msu.edu> wrote:

This titlespacing command can be replaced with yours. It's really only
the \titleformat command that needs to be changed as I indicated.

Alan

GL

unread,
Dec 17, 2010, 6:02:42 AM12/17/10
to
Le 17/12/2010 04:15, coo...@NOSPAM.verizon.net a écrit :
> It seems to me that the titlesex and sectsty packages both provide

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
% ------------------------------------------------

GL

unread,
Dec 17, 2010, 6:07:43 AM12/17/10
to
Le 17/12/2010 12:02, GL a écrit :
> Le 17/12/2010 04:15, coo...@NOSPAM.verizon.net a écrit :
>> It seems to me that the titlesex and sectsty packages both provide
>
> 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)

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.

Enrico Gregorio

unread,
Dec 17, 2010, 6:24:47 AM12/17/10
to
<coo...@NOSPAM.verizon.net> wrote:

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

coo...@nospamverizon.net

unread,
Dec 17, 2010, 12:45:41 PM12/17/10
to
Thanks to everyone for their suggestions -- a number of things to try.
0 new messages