Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I want all of my \subsection behave like \subsection* Instead of adding * everywhere, I like to add a few lines in the preamble. What should I do? Can I just \renewcommand?

share|improve this question
2  
I'd think find & replace (or sed for example) would work just fine... –  ℝaphink Sep 12 '11 at 16:38
1  
Why not use 'Replace'? I think it is available in every editor - does it all automatically. –  Count Zero Sep 12 '11 at 16:41
    
Replace is obviously a possibility. But my document consists of many sub .tex files, so it would not be so convenient. And it is possible that I change my mind in the future. :) –  FEQ Sep 13 '11 at 1:43
add comment

2 Answers

up vote 23 down vote accepted

Write

\setcounter{secnumdepth}{1}

in your preamble. This says to LaTeX that only first level sections should be numbered; \subsection is level 2.

As Gonzalo Medina points out, there's also the tocdepth counter that controls what section levels are included in the table of contents. LaTeX is happy to include also unnumbered section levels in the ToC, it's a matter of taste and of the document's nature how deep one should go.

share|improve this answer
3  
And \setcounter{tocdepth}{1} if a ToC is to be generated. –  Gonzalo Medina Sep 12 '11 at 16:40
add comment

Here is a way to redefine it. This uses the solution from Swap definition of starred and non-starred command:

\documentclass{article}

\makeatletter
\let\oldsubsection\subsection
\renewcommand\subsection{\@ifstar{\oldsubsection}{\oldsubsection*}}
\makeatother

\begin{document}
\section{First section}
\subsection{First subsection}
\end{document}
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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