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

Bold math in section title

1,505 views
Skip to first unread message

jimmij

unread,
May 3, 2005, 10:39:21 AM5/3/05
to
Hi,
I'm trying to redefine \section just like in:
ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
(section 22.1 on page 47)

There is some problem with this redefinition - in table of contents all
sections are not visible. Bellow is minimal example.

%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,twoside,12pt]{report}

\let\sectionold\section
\renewcommand\section[2][\empty]{%
\boldmath\sectionold[#1]{#2}\unboldmath}

\begin{document}
\tableofcontents
\chapter{Abc}
def
\section{ghi $y=x$}
jkl
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%

Any suggestion is welcome,
jimmij
--
I come from the Land Of Imagination

Herbert Voss

unread,
May 3, 2005, 10:57:46 AM5/3/05
to
jimmij wrote:

> There is some problem with this redefinition - in table of contents all
> sections are not visible. Bellow is minimal example.

without a redefinition of section

\section{ghi \boldmath$y=x$\unboldmath}


Herbert

--
http://TeXnik.de/
http://PSTricks.de/
ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
http://www.dante.de/faq/de-tex-faq/
http://www.tex.ac.uk/cgi-bin/texfaq2html?introduction=yes

jimmij

unread,
May 3, 2005, 11:23:34 AM5/3/05
to
Herbert Voss <Herber...@gmx.net> writes:

> without a redefinition of section
>
> \section{ghi \boldmath$y=x$\unboldmath}

Thanks for reply.
I know how to do it without redefination. But I have a lot of sections
with math, so I'm looking for some global way...

regards,

Herbert Voss

unread,
May 3, 2005, 11:32:03 AM5/3/05
to
jimmij wrote:
> Herbert Voss <Herber...@gmx.net> writes:
>
>
>>without a redefinition of section
>>
>>\section{ghi \boldmath$y=x$\unboldmath}
>
>
> Thanks for reply.
> I know how to do it without redefination. But I have a lot of sections
> with math, so I'm looking for some global way...

\documentclass[a4paper,twoside,12pt]{report}

\let\sectionold\section
\renewcommand\section[2][]{%
\sectionold{\boldmath #2\unboldmath}}

\begin{document}
\tableofcontents
\chapter{Abc}
def
\section{ghi $y=x$}
jkl
\end{document}


but it makes no sense, the sections are not in bold in the toc ...

HErbert

jimmij

unread,
May 3, 2005, 11:50:34 AM5/3/05
to
Herbert Voss <Herber...@gmx.net> writes:

> \documentclass[a4paper,twoside,12pt]{report}
>
> \let\sectionold\section
> \renewcommand\section[2][]{%
> \sectionold{\boldmath #2\unboldmath}}
>
> \begin{document}
> \tableofcontents
> \chapter{Abc}
> def
> \section{ghi $y=x$}
> jkl
> \end{document}
> but it makes no sense, the sections are not in bold in the toc ...

Ok, looks like I have to write \boldmath or \bm for all sections
separately...

Thanks for help,

Ralf Stubner

unread,
May 3, 2005, 12:01:30 PM5/3/05
to
jimmij <jim...@jj.jj> writes:

> Herbert Voss <Herber...@gmx.net> writes:
>
> > but it makes no sense, the sections are not in bold in the toc ...
>
> Ok, looks like I have to write \boldmath or \bm for all sections
> separately...

Using one of the KOMA-Script classes you could plug \boldmath directly
into the font selection for sections. I am sure that memoir gives you
similar possibilities. There are also different packages on CCTAN for
altering the fonts used for section titles (see the FAQ).

However, please keep in mind that in $x$ and $\bm{x}$ can mean quite
differnt things. I am not convinced that it is a good idea to switch to
a bold font for math in section titles.

cheerio
ralf

Robin Fairbairns

unread,
May 3, 2005, 12:46:29 PM5/3/05
to
Ralf Stubner <ralf.s...@physik.uni-erlangen.de> writes:

>jimmij <jim...@jj.jj> writes:
>> Ok, looks like I have to write \boldmath or \bm for all sections
>> separately...
>
>Using one of the KOMA-Script classes you could plug \boldmath directly
>into the font selection for sections. I am sure that memoir gives you
>similar possibilities. There are also different packages on CCTAN for
>altering the fonts used for section titles (see the FAQ).

actually there's no problem hacking it up the way jimmij wanted to in
the first place.

\let\oldsection\section
\renewcommand\section[2][\sectiontoc]{%
\def\sectiontoc{#2}%
\oldsection[#1]{\boldmath#2}%
}

note the section title is set in a group, so \boldmath doesn't need to
be unwound.

>However, please keep in mind that in $x$ and $\bm{x}$ can mean quite
>differnt things. I am not convinced that it is a good idea to switch to
>a bold font for math in section titles.

it is sometimes. but sometimes it isn't, i agree.
--
Robin (http://www.tex.ac.uk/faq) Fairbairns, Cambridge

jimmij

unread,
May 3, 2005, 1:01:43 PM5/3/05
to
r...@cl.cam.ac.uk (Robin Fairbairns) writes:

> actually there's no problem hacking it up the way jimmij wanted to in
> the first place.
>
> \let\oldsection\section
> \renewcommand\section[2][\sectiontoc]{%
> \def\sectiontoc{#2}%
> \oldsection[#1]{\boldmath#2}%
> }

It seems to work properly :)
I will do the same for chapter and subsections.

Thank you,

Ralf Stubner

unread,
May 3, 2005, 1:41:36 PM5/3/05
to
r...@cl.cam.ac.uk (Robin Fairbairns) writes:

> actually there's no problem hacking it up the way jimmij wanted to in
> the first place.

Sure, but that is still more complicated than

%%%%%%%%%%%%%%%%%%%%%%%%%%
\documentclass[a4paper,twoside,12pt,chapterprefix]{scrreprt}

\addtokomafont{sectioning}{\rmfamily\boldmath}

\begin{document}
\tableofcontents
\chapter{Abc $y=x$}


def
\section{ghi $y=x$}
jkl

\subsection{ghi $y=x$}
jkl
\end{document}
%%%%%%%%%%%%%%%%%%%%%%%%%%

which works for all sectioning levels. Note that 'chpaterprefix' and
'\rmfamily' are used to get closer to the layout of report.cls.

cheerio
ralf

Donald Arseneau

unread,
May 3, 2005, 4:56:16 PM5/3/05
to
Herbert Voss <Herber...@gmx.net> writes:

> \let\sectionold\section
> \renewcommand\section[2][]{%
> \sectionold{\boldmath #2\unboldmath}}

I think this is really vile.

It breaks the TOC, as Robin pointed out and fixed.

It is creating a "wrapper" macro when the original
\section is just a wrapper macro too! You should
just redefine \section to include \boldmath where
it specifies \bfseries. Also insert \raggedright.

Even though it is very simple already, there are
packages to allow piecemeal specification of headings:
titlesec.sty, and the Koma and Memoir classes.

--
Donald Arseneau as...@triumf.ca

Harri Haanpaa

unread,
May 4, 2005, 12:47:53 AM5/4/05
to
On 2005-05-03, Donald Arseneau <as...@triumf.ca> wrote:
> Herbert Voss <Herber...@gmx.net> writes:
>
>> \let\sectionold\section
>> \renewcommand\section[2][]{%
>> \sectionold{\boldmath #2\unboldmath}}
>
> I think this is really vile.
>
> It breaks the TOC, as Robin pointed out and fixed.

I think there is no good solution and that it would be better to
avoid mathematics in section titles altogether.

In my Licentiate thesis I used the official visual style of the
university, which meant among other things that I was to use the
official fonts. And the default LaTeX math fonts were just totally
unusable with the section title font. (The default LaTeX math font
doesn't math the text font either, and the architecture students
who designed the visual style didn't consider math fonts at all.)

In the end, I ended up faking it with something like

\section{Attempts to Improve \protect\(
\mbox {\em R}_{\mbox {\scriptsize \em k}}\protect \)(3)

which is probably a totally wrong way of doing things but worked
for me both in the section title and in the table of contents.

Older, no wiser but somewhat lazier I nowadays avoid math notation
in document and section titles like the plague.

Regards,
Harri

Ulrich M. Schwarz

unread,
May 4, 2005, 2:52:49 AM5/4/05
to
Harri Haanpaa <har...@yahoo.com> writes:

[...]


> In the end, I ended up faking it with something like
>
> \section{Attempts to Improve \protect\(
> \mbox {\em R}_{\mbox {\scriptsize \em k}}\protect \)(3)
>
> which is probably a totally wrong way of doing things but worked
> for me both in the section title and in the table of contents.

Hmmm... tangentially, classes like beamer do manage to fake
mathematics, so ummm... maybe one could look how they do it in one's
copious amounts of spare time... aaaah: sansmath.sty. Seems like I
should rather tweak my texdoc paths in my spare time ;-)

Ulrich
--
∀x∈ℕ or \forall x\in \mathbb{N}?
http://talcum.sarovar.org/ (Current release: 0.5.0 20050306)

Alberto L

unread,
May 4, 2005, 4:16:25 AM5/4/05
to

>>>>> "jimmij" == jimmij <jim...@jj.jj> wrote:

jimmij> Hi, I'm trying to redefine \section just like in:
jimmij> ftp://ftp.dante.de/tex-archive/info/math/voss/Voss-Mathmode.pdf
jimmij> (section 22.1 on page 47)
[...]

jimmij> Any suggestion is welcome, jimmij -- I come from the Land Of
jimmij> Imagination

I am no real TeX/LaTeX expert, so take what follows with a grain of
salt. I use for my papers the following definition, which I found some
time ago on the web or on Usenet, just before \begin{document}:

\makeatletter
\DeclareRobustCommand\bfseries{%
\not@math@alphabet\bfseries\mathbf
\fontseries\bfdefault\selectfont\boldmath}%
\makeatother

Using teTex 2.0 on Linux, this will convert math to bold in section
titles, at least for the article class. It will convert math to bold
actually whenever math is located where text would be bold.

Greetings,

Alberto

Robin Fairbairns

unread,
May 4, 2005, 11:51:10 AM5/4/05
to
jimmij <jim...@jj.jj> writes:
>r...@cl.cam.ac.uk (Robin Fairbairns) writes:
>> actually there's no problem hacking it up the way jimmij wanted to in
>> the first place.
>>
>> \let\oldsection\section
>> \renewcommand\section[2][\sectiontoc]{%
>> \def\sectiontoc{#2}%
>> \oldsection[#1]{\boldmath#2}%
>> }
>
>It seems to work properly :)
>I will do the same for chapter and subsections.

beware of \chapter* -- you may not do it but a lot of things (like
table of contents) do, and it won't work with the above.

we had discussions about \chapter* and so on, not long back, here.

0 new messages