3

I would like Sections to display the subsection number,
but I feel that redefining \thesection will recursively affect \thesubsection.

Basically, we're looking to add a zero to the section number in headings and the table of contents.

Example:

What we currently get:

1. Section 1 1.1 Section 1, Subsection 1 1.2 Section 1, Subsection 2 

What we're looking to get:

1.0 Section 1 1.1 Section 1, Subsection 1 1.2 Section 1, Subsection 2 

Additional info:

This post was a helpful start.

2
  • What is the use of this? Commented Aug 1, 2016 at 15:57
  • Our administrator wants this syntax for the documents we're sending out. We're at his mercy. Commented Aug 1, 2016 at 18:28

2 Answers 2

1

Simply changing \thesection so that it would show whatever it is you want it after the number, then redefine \thesubsection so as not to call \thesection.

\documentclass{article} \renewcommand{\thesection}{\arabic{section}.0} \renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}} \begin{document} \tableofcontents \medskip text text \section{test} nah \subsection{test1} blah \subsection{test2} jah \end{document} 

resulting in

just fixing the section

If you wish to fix the TOC you can use the tocloft package thus

\documentclass{article} \usepackage{tocloft} \renewcommand{\thesection}{\arabic{section}.0} \renewcommand{\thesubsection}{\arabic{section}.\arabic{subsection}} \renewcommand\cftsecnumwidth{2.5em} \begin{document} \tableofcontents \medskip text text \section{test} nah \subsection{test1} blah \subsection{test2} jah \end{document} 

This would give you

TOC fix added

2
  • The indentations are off in the Table of Contents. Do you know any simple code to alleviate this? (Else I recommend checking this out.) Either way, can you modify your answer to include a solution? Commented Aug 2, 2016 at 17:20
  • Much thanks. All should note that the method proposed by egreg also works, (although it does not contain Elad Den's ToC fix at this time.) Commented Aug 3, 2016 at 14:33
2

Redefine \thesection to refer to subsection and \thesubsection to be the same as \thesection:

\documentclass{article} \renewcommand{\thesection}{\arabic{section}.\arabic{subsection}} \renewcommand{\thesubsection}{\thesection} \begin{document} \section{Section} \subsection{First subsection} \subsection{Second subsection} \section{Section} \subsection{First subsection} \subsection{Second subsection} \end{document} 

enter image description here

6
  • Answer granted to @Elad Den for getting it in first. Still, I appreciate your efforts equally. Leave a comment for a little rep : j Commented Aug 2, 2016 at 17:00
  • The indentations are off in the Table of Contents. Do you know any simple code to alleviate this? (Else I recommend checking this out.) Either way, can you modify your answer to include a solution? Commented Aug 2, 2016 at 17:21
  • 1
    @kando You could make sections the same as subsections: the zero will tell the reader which is which. Tell me if the idea is what you want. Commented Aug 2, 2016 at 17:25
  • Oop. I didn't see the subtle difference between you two. Does this fix the ToC? (A peer is making the edits. He used \setlength{cftsecnumwidth}{+XXem} from package tocloft to make his fix.) Commented Aug 2, 2016 at 17:28
  • 1
    @kando It's not clear whether you really want to repeat the section title in the subsection title. Commented Aug 2, 2016 at 17:40

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.