2

I've redefined the section, subsection and subsubsection styles in my preamble as

\renewcommand\section{%
  \@startsection{section}{1}
                {\z@}%
                {-3.5ex \@plus -1ex \@minus -.2ex}%
                {2.3ex \@plus.2ex}%
                {\normalfont\normalsize\bfseries\uppercase}%
}

\renewcommand\subsection{%
  \@startsection{subsection}{2}
                {\z@}%
                {-3.25ex\@plus -1ex \@minus -.2ex}%
                {2.3ex \@plus.2ex}%
                {\normalfont\normalsize\MakeUppercase}
}

\renewcommand\subsubsection{%
  \@startsection{subsubsection}{3}
                {\z@}%
                {-3.25ex\@plus -1ex \@minus -.2ex}%
                {2.3ex \@plus.2ex}%
                {\normalfont\normalsize\bfseries}
}

And I want it to appear the same way in the ToC. I've tried using tocloft but it messes around with other stuff. How could I do it without the use of any package?

6
  • so you want to change the body but not the TOC? Or do you want it to change both the body as well as the TOC entries? Commented Oct 9, 2013 at 15:34
  • @MaxGraves: It is clear through the OP: "And I want it to appear the same way in the ToC." He established a style in the body and wants to apply this to the TOC.
    – Ruben
    Commented Oct 9, 2013 at 17:05
  • @Ruben I would disagree, this seems to be a bit of an ambiguous statement...does 'the same way in the ToC' mean the same as his definition or the same as the default? I wanted clarification before attempting to provide a solution. Commented Oct 9, 2013 at 17:09
  • Sorry if I wasn't clear enough. But Ruben got what I mean: I established a style for the body and want that same style applied to the TOC :)
    – Cyberz
    Commented Oct 9, 2013 at 17:51
  • Most of this is related to extra vertical glue; does it make sense in a TOC?
    – user4686
    Commented Oct 10, 2013 at 13:48

1 Answer 1

2

Well, found a solution :)

Placing in this piece of code at my preamble

\let\stdl@section\l@section
\renewcommand*{\l@section}[2]{%
  \stdl@section{\normalfont\normalsize\bfseries\uppercase{#1}}
{\normalfont\normalsize\bfseries\uppercase{#2}}}

Did the deal. The same could be done to subsection and subsubsecion ;) There is only a small detail left: special characters don't get uppercase, such as:

á é í ó ú à õ ô

And I have no idea why placing an \MakeUppercase instead of \uppercase gets random errors when generating the PDF. Will dig in a little bit more and see what happens.

@Update Guess there is a problem with \MakeUppercase and hyperref package. I removed the hyperref package and changed all the \uppercase for \MakeUppercase and it works as charm. The codes I actually used to modify the ToC appearance is:

\let\stdl@section\l@section
\renewcommand*{\l@section}[2]{%
  \stdl@section{\MakeUppercase{#1}}{#2}}

\let\stdl@subsection\l@subsection
\renewcommand*{\l@subsection}[2]{%
  \stdl@subsection{\normalfont\MakeUppercase{#1}}{#2}}

\let\stdl@subsubsection\l@subsubsection
\renewcommand*{\l@subsubsection}[2]{%
  \stdl@subsubsection{\bfseries{#1}}{#2}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .