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.

  • What is the use of this? – user31729 Aug 1 '16 at 15:57
  • Our administrator wants this syntax for the documents we're sending out. We're at his mercy. – kando Aug 1 '16 at 18:28
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

  • 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? – kando Aug 2 '16 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.) – kando Aug 3 '16 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

  • Answer granted to @Elad Den for getting it in first. Still, I appreciate your efforts equally. Leave a comment for a little rep : j – kando Aug 2 '16 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? – kando Aug 2 '16 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. – egreg Aug 2 '16 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.) – kando Aug 2 '16 at 17:28
  • 1
    @kando It's not clear whether you really want to repeat the section title in the subsection title. – egreg Aug 2 '16 at 17:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.