You are not logged in.

#1 2012-01-16 14:45:51

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

[SOLVED] LaTeX: disable numbering of sections, but not of subsections

I have a quesion about LaTeX.

I want to disable the numbering of sections, but not of subsections. By default, it's like this:

1. First section
   1.1. Subsection to the first section
   1.2. Another subsection
2. Another section
   2.1. And so on...

I want it like this:

First section
   1. Subsection to the first section
   2. Another subsection
Another section
   1. And so on...

I know I can specify the depth of the numbering with \secnumdepth, but this way I could only do the opposite of what I want, i.e. disable numbering of subsections and keep the numbering of section. With \section*{First section}, I could selectively disable numbering and manually add the section to the TOC, then I have my unnumbered sections, but the subsections are still numbered "0.1. Subsection..." instead of "1. Subsection".

Any ideas?

-----------------------------------------------------------------------------
[edit] SOLUTION:

\renewcommand{\thesection}{\hspace*{-1.0em}}
\renewcommand{\thesubsection}{\arabic{subsection}}

Last edited by cryptkeeper (2012-01-18 06:18:49)

Offline

#2 2012-01-16 17:00:41

leocp1
Member
From: USA
Registered: 2011-11-18
Posts: 7

Re: [SOLVED] LaTeX: disable numbering of sections, but not of subsections

My commands are kind of kludgy (they make the indenting a little weird), but I think they should work

First, we redefine the command used for numbering sections to "hspace*{-18pt} (ie: just display the title 18pts left of where it should  be). This may need to be adjusted depending on font size/ etc.
Next, we redefine the command used for numbering subsections to display the subsection number as an arabic numeral.

\renewcommand{\thesection}{\hspace*{-18pt}}
\renewcommand{thesubsection}{\indent\arabic{subsection}}

Just for reference, I believe the default behaviour is

\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}

EDIT:

These commands should be placed in the preamble, although I think they work in document.

Also,

\renewcommand{\thesection}{\hspace*{-1.0em}}
\renewcommand{thesubsection}{\indent\arabic{subsection}}

may work better, depending on the font/ fontsize you use. (1.0em is roughly the width of an 'M' in the current font.)

Last edited by leocp1 (2012-01-16 17:55:30)

Offline

#3 2012-01-16 17:06:00

draugdel
Member
Registered: 2008-08-12
Posts: 44

Re: [SOLVED] LaTeX: disable numbering of sections, but not of subsections

\section*{bla}
\addtocounter{section}{1}

That should work.

Offline

#4 2012-01-16 19:21:23

patroclo7
Member
From: Bassano del Grappa, ITALY
Registered: 2006-01-11
Posts: 915

Re: [SOLVED] LaTeX: disable numbering of sections, but not of subsections

draugdel wrote:
\section*{bla}
\addtocounter{section}{1}

That should work.

I don't think so. In this way you only get 1.1 instead of 0.1


Mortuus in anima, curam gero cutis

Offline

#5 2012-01-16 19:50:10

draugdel
Member
Registered: 2008-08-12
Posts: 44

Re: [SOLVED] LaTeX: disable numbering of sections, but not of subsections

patroclo7 wrote:
draugdel wrote:
\section*{bla}
\addtocounter{section}{1}

That should work.

I don't think so. In this way you only get 1.1 instead of 0.1

Doh, didn´t read that right. hmm

Offline

#6 2012-01-17 08:37:08

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

Re: [SOLVED] LaTeX: disable numbering of sections, but not of subsections

leocp1 wrote:
\renewcommand{\thesection}{\hspace*{-18pt}}
\renewcommand{\thesubsection}{\indent\arabic{subsection}}
\renewcommand{\thesection}{\hspace*{-1.0em}}
\renewcommand{\thesubsection}{\indent\arabic{subsection}}

Both commands principally work. There are two issues though. First: You forgot the \ before thesubsection in both commands (I corrected it in the quote).

Second (and that's the real issue): There's too little space between the numbers of the subsections and the subsection title in the TOC. For subsections 1-9, it just works, but from 10 on the second number overlaps with the first character of the title.

Apart from that, it's exactly what I was looking for! big_smile

Last edited by cryptkeeper (2012-01-17 08:48:58)

Offline

#7 2012-01-18 03:10:54

leocp1
Member
From: USA
Registered: 2011-11-18
Posts: 7

Re: [SOLVED] LaTeX: disable numbering of sections, but not of subsections

Doh. I made a pretty bad mistakes

You've probably figured this out by now, but removing the \indent will solve your problems:

\renewcommand{\thesection}{\hspace*{-1.0em}}
\renewcommand{\thesubsection}{\arabic{subsection}}

is what I was supposed to have written.

I honestly have no idea why I made so many typos.

Offline

#8 2012-01-18 06:17:13

cryptkeeper
Member
From: Zurich, Switzerland
Registered: 2011-12-29
Posts: 63

Re: [SOLVED] LaTeX: disable numbering of sections, but not of subsections

leocp1 wrote:

You've probably figured this out by now, but removing the \indent will solve your problems:

Actually I haven't because I've just started using LaTeX last week, I'm just getting used to the basics.

\renewcommand{\thesection}{\hspace*{-1.0em}}
\renewcommand{\thesubsection}{\arabic{subsection}}

is what I was supposed to have written.

Perfect solution! Thanks a lot for your help.

Offline

Board footer

Powered by FluxBB