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 need the \paragraph{xxx} command outputs "§ 1 xxx" but the \section{Abc} outputs just "Abc", no numbering. Any help? Thanks.

share|improve this question
    
Should the sectional units associated to \subsection and \subsubsection be numbered or not? –  Gonzalo Medina Dec 17 '11 at 3:43
1  
Both titlesec package and memoir class might be helpful, see their (excellent) documentation. –  mbork Dec 17 '11 at 3:45
    
the \section and \subsection must not be numbered, neither in the body not in the ToC. I'm using the memoir package indeed, but I can't figure how to manage that. If I set \maxsecnumdepth{paragraph}, then, how can I prevent the \section, \subsection and \subsubsection heading from show their numbers (in both the body and the ToC)? –  marlonob Dec 18 '11 at 19:36
add comment

1 Answer 1

up vote 6 down vote accepted

Normally \paragraph is defined using \@startsection which uses the counter secnumdepth to decide whether to number the unit. For example, in article.cls you can find

    \renewcommand\thesubparagraph {\theparagraph.\@arabic\c@subparagraph}

and

    \newcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
                                {3.25ex \@plus1ex \@minus.2ex}%
                                {-1em}%
                                {\normalfont\normalsize\bfseries}}

The first command numbers paragraphs as Section.Para, the second sets the formatting of the paragraphs.

You can patch these commands, for example

\documentclass{article}
\setcounter{secnumdepth}{0}         % Now sections are not numbered
\renewcommand\theparagraph{\arabic{paragraph}} % delete the section num from \theparagraph
\makeatletter
\renewcommand\paragraph{%
   \refstepcounter{paragraph}%   Manually stepping paragraph counter without consulting secnumdepth
   \@startsection{paragraph}{4}{\z@}%
     {3.25ex \@plus1ex \@minus.2ex}%
     {-1em}%
     {\normalfont\normalsize\bfseries\S~\theparagraph\space}} % Formatting the paragraph
\makeatother

\begin{document}
\section{First section}
\paragraph{First paragraph} Second
\end{document}
share|improve this answer
    
Thanks! It seems that this will do the trick. But, will this show the paragraph number in the table of contents? It is not necesary, but would be very practical. Again, the section and subsection numbers must not be shown in the ToC. –  marlonob Dec 18 '11 at 18:22
    
Try, for example, \renewcommand*\l@paragraph{\@dottedtocline{0}{7.0em}{4.1em}}. The first zero here tells TOC to put the paragraph sections into TOC on the 0 level –  Boris Dec 18 '11 at 21:41
    
Thanks @Boris! I finally get what I wanted: The \section and \subsection must appear in the ToC without number but the \paragraph must be numerated, so I use \setcounter{secnumdepth}{0}. I got this with a little addition to the code you suggested, so now it looks like this. –  marlonob Dec 19 '11 at 2:51
    
\makeatletter \renewcommand*\l@paragraph{\@dottedtocline{0}{7.0em}{4.1em}}% Include paragraph as 0 level in ToC \newcommand\Paragraph{% with capital “P” for distinction \refstepcounter{paragraph}% Manually stepping paragraph counter without consulting secnumdepth \@startsection{paragraph}{4}{\z@}% {1.5ex \@plus1ex \@minus.2ex}% {-1em}% {\normalfont\normalsize\sffamily[\bfseries\S~\thechapter.\theparagraph\mdseries‌​]\bfseries\space} } % Formatting the paragraph \renewcommand\paragraph[1]{% \Paragraph[\S~\thechapter.\theparagraph\space~#1][#1]{#1} } \makeatother –  marlonob Dec 19 '11 at 2:52
    
Well, I can't include the proper format in the previous comment (this is my first time :) but I expect to be understandable. I know it doesn't seem a clean solution, so if anyone can figure out something better it would be great. Thanks guys, you're awsome. –  marlonob Dec 19 '11 at 3:03
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.