Specific numbering and colored section

Random questions or observations about and around computers
Post Reply
gdesvignes
Posts: 12
Joined: Mon Dec 28, 2009 12:04 am

Specific numbering and colored section

Post by gdesvignes » Wed Jun 02, 2010 8:56 am

Hi all... again !

I'm writing the report and I want a specific numbering for sections (including chapter).
I have this heading, but it doesn't work for \subsubection :

Code: Select all

\renewcommand{\thechapter}{\Roman{chapter}}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thesubsection}{\thesection.\arabic{subsection}}
\renewcommand{\thesubsubsection}{\thesection.\thesubsection.\arabic{subsubsection}}

\makeatletter
\renewcommand{\@makechapterhead}[1]{%
\vspace*{50 pt}%
{\setlength{\parindent}{0pt} \raggedright \normalfont \color{myTitleColor}{}
\bfseries\Huge \thechapter.\ #1
\par\nobreak\vspace{40 pt}}}
\makeatother

\titleformat{\thechapter}{\color{myTitleColor}}{\thechapter}{\Huge}{}{}
\titleformat{\thesection}{\color{myTitleColor}}{\thesection}{\huge}{}{}
\titleformat{\thesubsection}{\color{myTitleColor}}{\thesection}{\Big}{}{}
What's wrong ? Is there easier ?

User avatar
Vincent
Posts: 3077
Joined: Fri Apr 07, 2006 12:10 pm
Location: Schtroumpf
Contact:

Re: Specific numbering and colored section

Post by Vincent » Wed Jun 02, 2010 7:31 pm

gdesvignes wrote:Hi all... again !
You know, generally there is just me here; I know that "just me" is a hell of a lot, but still, it is not quite "all". ;)
gdesvignes wrote:What's wrong ?
As always with you, I have a lot of guesswork to do just to determine what your problem is, exactly...

If your problem is that subsubsections are not numbered at all, then the solution is to increase numbering depth throughout your document:

Code: Select all

\setcounter{secnumdepth}{6}
If it is something else, please specify. (I see other problems with that code, but none of those is consistent with the way your question is formulated, since they do not only affect subsubsections).

Suggestion: it is considered good practice, when reporting a bug or requesting help, to create a "minimal example file". If you are asking a question about C for instance, give a minimal .c source file ready to compile illustrating your problem; in the case of a \LaTeX question, give a complete .tex file, etc. This can be the document on which you are working, from which all element irrelevant to the problem at hand and unnecessary to compilation have been removed.

For instance here, I had to do some research to determine that you were using the titlesec package, which provides the \titleformat command which you are using. That's an information which should have been provided with the problem. The less time and energy I spend doing soul-searching and crystal-ball ogling to reconstruct your question, the more time and energy I -- or anyone else in similar conditions -- have to actually look for an answer.

So long and thanks for all the fish.
{ Vincent Hugot }

gdesvignes
Posts: 12
Joined: Mon Dec 28, 2009 12:04 am

Re: Specific numbering and colored section

Post by gdesvignes » Thu Jun 03, 2010 11:02 am

Actually, this only one part of my question. Maybe I'll do an other topic for that. It's about coloring titles. That's why I put ohter LaTeX lines...

Your tips works fine ! I saw a such command into LaTeX book. But I didn't remind it unitl now... My brain's trick !
Thank you for your help !

User avatar
Vincent
Posts: 3077
Joined: Fri Apr 07, 2006 12:10 pm
Location: Schtroumpf
Contact:

Re: Specific numbering and colored section

Post by Vincent » Thu Jun 03, 2010 8:55 pm

gdesvignes wrote: It's about coloring titles.
Reference : http://theoval.cmp.uea.ac.uk/~nlct/late ... node9.html

Assuming that you are using the "report" class, modus operandi:
vincent@seth:~$ locate report.cls
...
/usr/share/texmf-texlive/tex/latex/base/report.cls
...
vincent@seth:~$ nano /usr/share/texmf-texlive/tex/latex/base/report.cls
Locate instances of \@startsection, copy and paste in your document all definitions

Code: Select all

\newcommand\section{\@startsection {section}{1}{\z@}%
                                   {-3.5ex \@plus -1ex \@minus -.2ex}%
                                   {2.3ex \@plus.2ex}%
                                   {\normalfont\Large\bfseries}}
\newcommand\subsection{\@startsection{subsection}{2}{\z@}%
                                     {-3.25ex\@plus -1ex \@minus -.2ex}%
                                     {1.5ex \@plus .2ex}%
                                     {\normalfont\large\bfseries}}


etc
Change all \newcommand into \renewcommand add your colors in the last arguments: {\normalfont\Large\bfseries\color{shockingPink}}.

Surround all these definitions between \makeatletter and \makeatother.

It should work.
{ Vincent Hugot }

Post Reply

Who is online

Users browsing this forum: No registered users and 65 guests