The output of \show
cannot be used as you are trying. It says that \subsection
is a "long" macro that has no arguments and the replacement text is what follows ->
.
The right place where to look is report.cls
, where you find
\newcommand\subsubsection{\@startsection{subsubsection}{3}{\z@}%
{-3.25ex\@plus -1ex \@minus -.2ex}%
{1.5ex \@plus .2ex}%
{\normalfont\normalsize\bfseries}}
\newcommand\paragraph{\@startsection{paragraph}{4}{\z@}%
{3.25ex \@plus1ex \@minus.2ex}%
{-1em}%
{\normalfont\normalsize\bfseries}}
The key point that explain the different behavior are: the negative fourth argument of \@startsection
for \subsubsection
which suppresses indentation of the following paragraph; the positive fifth argument tells TeX that the title will not be "run-in". So
\makeatletter
\renewcommand\subsection{%
\@startsection{subsubsection}{3}{\z@}{3.25ex \@plus1ex \@minus.2ex}%
{-1em}{\normalfont\normalsize\bfseries}}
\makeatother
The second argument to \@startsection
tells LaTeX the level of the sectioning command for the purposes of secnumdepth
and tocdepth
and should stay 3
.
Important note
The \makeatletter
and \makeatother
commands are necessary because we are doing stuff involving the internal command of LaTeX.
Every time a command containing @
in its name has to be used, the code must either be in a .sty
file or surrounded by that pair. See What do \makeatletter and \makeatother do? for more information.
Here's an expl3
version for alternating colours, but not for strings with whitespace (so far)
\documentclass{article}
\usepackage{xparse}
\usepackage[x11names]{xcolor}
\ExplSyntaxOn
\newcommand{\colorstring}[3]{%
\str_set:Nn \l_tmpa_str {#3}% store the string to a string variable
% Now loop through the string variable and get each 'letter'
\int_step_inline:nnnn {1} {1} {\str_count:N \l_tmpa_str } {%
\int_if_odd:nTF{##1}{% Is the number odd → use the first colour
\textcolor{#1}{\str_item:Nn \l_tmpa_str {##1}}
}{% No, use the 2nd colour
\textcolor{#2}{\str_item:Nn \l_tmpa_str {##1}}
}%
}%
}
\ExplSyntaxOff
\begin{document}
\bfseries
\huge \colorstring{blue}{red}{abcdefgh}
\huge \colorstring{brown}{Green4}{ABCEDEFGH}
\end{document}
Another version, with alternating colours
... and providing more than two colours, as well as using in an environment. However, no empty lines are allowed! No real tests on printable characters are done so far.
\documentclass{article}
\usepackage{xparse}
\usepackage{environ}
\usepackage[x11names]{xcolor}
\ExplSyntaxOn
\NewDocumentCommand{\colorstring}{O{blue,red}+m}{%
\clist_set:Nn \l_tmpa_clist {#1}%
\int_zero:N \l_tmpa_int%
\str_set:Nx \l_tmpa_str {#2}%
\int_step_inline:nnnn {1} {1} {\str_count:N \l_tmpa_str } {%
\str_case_x:nnF {\str_item:Nn \l_tmpa_str {##1}} {%
{\space}{\space}
}{%
\int_compare:nNnTF {\l_tmpa_int } < {\clist_count:N \l_tmpa_clist } {
\int_incr:N \l_tmpa_int
}{%
\int_set:Nn \l_tmpa_int {\c_one}
}
\textcolor{\clist_item:Nn \l_tmpa_clist {\l_tmpa_int }}{\str_item:Nn \l_tmpa_str {##1}}
}
}
}
\ExplSyntaxOff
\NewEnviron{ColorLettersInternal}[1]{\colorstring[#1]{\BODY}} % Internal environment for `\Body`
\NewDocumentEnvironment{ColorLetters}{O{blue,red}}{%
\ttfamily%
\ColorLettersInternal{#1}%
}{%
\endColorLettersInternal%
}
\parindent=0pt
\begin{document}
\bfseries
\huge \colorstring{abcdefgh}
\huge \colorstring[brown,Green4,Aquamarine4]{ABCEDEFGH}
\colorstringnew[violet,Green4,Red4,Blue2]{TCGATGGAGGGACCAT}
\begin{ColorLetters}[Blue4,Red4,Green4,LightBlue4]
And now for something completely different
Number Three -- the Larch!
\end{ColorLetters}
\end{document}
Best Answer
The default definition of
textbf
isTo add a new feature you can simple add
\color{red}
\DeclareTextFontCommand
overrides the original definition without errors. You only get an info by\@latex@info
Here the complete MWE: