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

How to underline section titles

1,307 views
Skip to first unread message

Sorin Ciocea

unread,
Jun 24, 1998, 3:00:00 AM6/24/98
to

I have tried to underline section titles in a report by using:

\renewcommand{\thesection}{\underline{\thechapter.\arabic{section}.}} (and it works)

but I still don't know where to put an underline command in the next renewcommand:

\renewcommand{\section}{\@startsection{section}{1}{0mm}{\baselineskip}{0.4\baselineskip}{\normalfont\normalsize}}

Thanks for suggestions.

Sorin

Rebecca and Rowland

unread,
Jun 24, 1998, 3:00:00 AM6/24/98
to

Sorin Ciocea <sci...@ipb0.ulb.ac.be> wrote:

I don't think you can use \underline in \@startsection; I can't work out
how to do it. But why do you want to? If re-defining \thesection does
the job, what's the problem?

(I take it you have a good reason for wanting to implement this
abomination?)

btw, please set your newsreader to wrap lines at 72 characters before
posting.

Rowland.

--
Remove the animal for my email address: reb...@astrid.dog.u-net.com
Sorry - the spam got to me. PGP pub key A680B89D
UK biker? Join MAG and help keep bureaucracy at bay
http://dredd.meng.ucl.ac.uk/www/mag/mag.html

Young Ryu

unread,
Jun 24, 1998, 3:00:00 AM6/24/98
to

Rebecca and Rowland wrote in message
<1db53xy.v4...@p48.nas1.is2.u-net.net>...


>Sorin Ciocea <sci...@ipb0.ulb.ac.be> wrote:
>
>> I have tried to underline section titles in a report by using:
>>
>> \renewcommand{\thesection}{\underline{\thechapter.\arabic{section}.}}
(and
>> it works)
>>
>> but I still don't know where to put an underline command in the next
>> renewcommand:
>>
>>
>>\renewcommand{\section}{\@startsection{section}{1}{0mm}{\baselineskip}{
>>0.4\baselineskip}{\normalfont\normalsize}}
>>
>
>I don't think you can use \underline in \@startsection; I can't work out
>how to do it. But why do you want to? If re-defining \thesection does
>the job, what's the problem?
>


Both

\makeatletter


\renewcommand{\section}{\@startsection{section}{1}{0mm}{\baselineskip}{

0.4\baselineskip}{\normalfont\normalsize\underline}}
\makeatother

and

\makeatletter


\renewcommand{\section}{\@startsection{section}{1}{0mm}{\baselineskip}{

0.4\baselineskip}{\normalfont\normalsize\underbar}}
\makeatother

work fine.

The above will underline both the section number and the section heading.

Young

Donald Arseneau

unread,
Jun 24, 1998, 3:00:00 AM6/24/98
to

In article <SCIOCEA.98...@ipb0.ulb.ac.be>, sci...@ipb0.ulb.ac.be (Sorin Ciocea) writes...

>I have tried to underline section titles in a report by using:
>\renewcommand{\thesection}{\underline{\thechapter.\arabic{section}.}}

That underlines the section *number*, not the title, and it even underlines
it when it appears elsewhere as a cross-\ref-erence!

>but I still don't know where to put an underline command in
>

>\renewcommand{\section}{\@startsection{section}{1}{0mm}{\baselineskip}%
> {0.4\baselineskip}{\normalfont\normalsize}}
^ here
... elineskip}{\normalfont\normalsize\underline}}

This restricts you to one-line section titles.

Donald Arseneau as...@triumf.ca

Rebecca and Rowland

unread,
Jun 27, 1998, 3:00:00 AM6/27/98
to

Young Ryu <ryo...@utdallas.edu> wrote:

[snip]


> Both
>
> \makeatletter
> \renewcommand{\section}{\@startsection{section}{1}{0mm}{\baselineskip}{
> 0.4\baselineskip}{\normalfont\normalsize\underline}}
> \makeatother
>
> and
>
> \makeatletter
> \renewcommand{\section}{\@startsection{section}{1}{0mm}{\baselineskip}{
> 0.4\baselineskip}{\normalfont\normalsize\underbar}}
> \makeatother
>
> work fine.

Almost; they both indent the sectional heading (including the number),
which isn't quite right.

Rebecca and Rowland

unread,
Jun 27, 1998, 3:00:00 AM6/27/98
to

Donald Arseneau <as...@reg.triumf.ca> wrote:

> In article <SCIOCEA.98...@ipb0.ulb.ac.be>, sci...@ipb0.ulb.ac.be
> (Sorin Ciocea) writes...

[snip]


> >but I still don't know where to put an underline command in
> >
> >\renewcommand{\section}{\@startsection{section}{1}{0mm}{\baselineskip}%
> > {0.4\baselineskip}{\normalfont\normalsize}}
> ^ here
> ... elineskip}{\normalfont\normalsize\underline}}
>
> This restricts you to one-line section titles.

When I tried this, it indented the sectional heading. Any idea how to
stop this happening? (and is there any way of having underlined
multi-line sectional headings?[1])

I tried modifying some of your (Donald's) code posted elsewhere and came
up with this:

\makeatletter
\renewcommand\section{\@startsection {section}{1}{\z@}%
{-3.5ex \@plus -1ex \@minus -.2ex}%
{2.3ex \@plus.2ex}%
{\normalfont\Large\bfseries\ruleunder}}

% \newcommand{\ruleunder}[1]{{#1}\par\nobreak\smallskip\hrule}

\newlength{\SS@SURwidth}

\newcommand{\ruleunder}[1]{{#1}\settowidth{\SS@SURwidth}{#1}%
\par\nobreak\smallskip\hrule width \SS@SURwidth}

\makeatother

Which is *almost* right; the only problem is that the paragraph below
this contruction begins at the specified vertical distance below the
baseline of the sectional heading text, rather than below the rule, so
it looks a bit odd.

I've tried reading the definition of \@startsection and it just gave me
a headache.

Rowland.

[1] Not for me, honest.

Donald Arseneau

unread,
Jun 27, 1998, 3:00:00 AM6/27/98
to

In article <1db9ery.1xk...@p49.nas1.is2.u-net.net>, real-addr...@flur.bltigibbet (Rebecca and Rowland) writes...

>Donald Arseneau <as...@reg.triumf.ca> wrote:
>> ... elineskip}{\normalfont\normalsize\underline}}
>>
>> This restricts you to one-line section titles.
>
>When I tried this, it indented the sectional heading.

Oh yeah. It does that too. I should have inserted \raggedright also
which, as a side-effect, sets parindent=0pt. I probably dropped it
from my answer because it is apparently superfluous for a single line.
If you want, you can put either \parindeny\z@ or \noindent before the
\underline.

>Any idea how to
>stop this happening? (and is there any way of having underlined
>multi-line sectional headings?[1])

Then you use ulem.sty and the following mystic incantation:

\newcommand\ulInSect[1]{\protected@edef\@svsec{\noexpand#1{\@svsec}}%
\def\interlinepenalty##1##2\@@par{\@@interlinepenalty##1#1{##2}\@@par}}
\let\@@interlinepenalty\interlinepenalty

Then use \ulInSect in the definition of \section to set the underline for
the section number and the section text; the type of underline is a parameter
to \ulInSect. For example, a \section with underlined (sanserif) titles:

\newcommand {\section}{\@startsection % or \renew...
{section}{1}{\z@}{-3ex \@plus -1ex \@minus -.2ex}{2ex \@plus.2ex}%
{\normalfont\large\sffamily\bfseries\boldmath\ulInSect{\uline}\raggedright}%
}

Donald Arseneau as...@triumf.ca

Rebecca and Rowland

unread,
Jun 28, 1998, 3:00:00 AM6/28/98
to

Donald Arseneau <as...@reg.triumf.ca> wrote:

> In article <1db9ery.1xk...@p49.nas1.is2.u-net.net>,
> real-addr...@flur.bltigibbet (Rebecca and Rowland) writes...
> >Donald Arseneau <as...@reg.triumf.ca> wrote:
> >> ... elineskip}{\normalfont\normalsize\underline}}
> >>
> >> This restricts you to one-line section titles.
> >
> >When I tried this, it indented the sectional heading.
>
> Oh yeah. It does that too. I should have inserted \raggedright also
> which, as a side-effect, sets parindent=0pt. I probably dropped it
> from my answer because it is apparently superfluous for a single line.
> If you want, you can put either \parindeny\z@ or \noindent before the
> \underline.

Ah yes - thanks. This works :-)

> >Any idea how to
> >stop this happening? (and is there any way of having underlined
> >multi-line sectional headings?[1])
>
> Then you use ulem.sty and the following mystic incantation:
>
> \newcommand\ulInSect[1]{\protected@edef\@svsec{\noexpand#1{\@svsec}}%
> \def\interlinepenalty##1##2\@@par{\@@interlinepenalty##1#1{##2}\@@par}}
> \let\@@interlinepenalty\interlinepenalty

Did you spend 25 years in a Tibetan monastery to learn how to do this
sort of thing?

> Then use \ulInSect in the definition of \section to set the underline for
> the section number and the section text; the type of underline is a parameter
> to \ulInSect. For example, a \section with underlined (sanserif) titles:
>
> \newcommand {\section}{\@startsection % or \renew...
> {section}{1}{\z@}{-3ex \@plus -1ex \@minus -.2ex}{2ex \@plus.2ex}%
> {\normalfont\large\sffamily\bfseries\boldmath\ulInSect{\uline}\raggedright}%
> }

Righto. I shall probably include \ullnSect in the next version of
sectsty (acknowledging the source of the code, of course) if you don't
mind. Is this okay?

Rowland.

Donald Arseneau

unread,
Jun 29, 1998, 3:00:00 AM6/29/98
to

In article <1dbatxj.1ri...@p37.nas1.is2.u-net.net>, real-addr...@flur.bltigibbet (Rebecca and Rowland) writes...

>Righto. I shall probably include \ullnSect in the next version of
>sectsty (acknowledging the source of the code, of course) if you don't
>mind. Is this okay?

Ah ha! I never saw much point in having a sty file merely to circumvent
the boilerplate definitions of the section commands, but sectsty is a
perfect place to expand the capability of \@startsection so, for example,
underlining needs no mysticism. There are lots of useful improvements
like rules above/below, ragged bottom on page before, filler in said
white space...

Donald Arseneau as...@triumf.ca

Javier Bezos

unread,
Jun 29, 1998, 3:00:00 AM6/29/98
to

Sorin Ciocea <sci...@ipb0.ulb.ac.be> wrote:

> I have tried to underline section titles in a report by using:
>
> \renewcommand{\thesection}

> {\underline{\thechapter.\arabic{section}.}} (and it works)


>
> but I still don't know where to put an underline command

> in the next renewcommand:


>
> \renewcommand{\section}{\@startsection{section}{1}{0mm}

> {\baselineskip}{0.4\baselineskip}{\normalfont\normalsize}}
>
> Thanks for suggestions.
>
> Sorin

With the ulem (by Donald Arseneau) and titlesec (by myself)
packages:

\usepackage{ulem,titlesec}

\titleformat{\section}
{\normalfont\normalsize}
{\uline{\thesection} }
{1em}
{\uline}
\titlespacing{\section}
{0pt}
{\baselineskip}
{0.4\baselineskip}

I hope this helps
Javier

Rebecca and Rowland

unread,
Jun 29, 1998, 3:00:00 AM6/29/98
to

Donald Arseneau <as...@reg.triumf.ca> wrote:

There's lots of things one might do, but the basic idea of sectsty was
to write a very simple package to do a very simple job: many LaTeX users
are unhappy with the idea of fiddling with the source and it does make
your document tex file untidy.

Having said all that, there are many things that would be nice. If I
can hack things around well enough to allow these extras, adding them to
sectsty would add no complexity to its (basic) use if it were well
documented.

But... I do like the idea of a very simple package. The only reason
I'm dealing with underlining is that underlining is often required, and
it'd be nice if there was a package that let you do this very easily.

Having said all that, how would you tell LaTeX to make the page before a
sectional heading raggedbottom?

0 new messages