I am trying to understand a behavior where section headers assume the color of the first word in the section.
Here is my MWE:
\documentclass{minimal}
\usepackage{xcolor}
\makeatletter
\newcommand\section{\@startsection{section}{1}{.25in}%
{1.3ex \@plus .5ex \@minus .2ex}%
{-.5em \@plus -.1em}%
{\reset@font\normalsize\bfseries}}
\makeatother
\begin{document}
\section{First}
{\color{red} Hello there} More text
\end{document}
The desired outcome is for "Hello there" to be red but the rest of the text (including "First") to be black. However, "First" is red. If a word is inserted before "{\color" then the desired behavior occurs. What is going on here? The answer must be some basic fact about latex that I don't know.
Many thanks in advance.
\textcolor{red}{Hello there}– Bernard Mar 04 '19 at 16:40titlesecpackage for this sort of modifications to the defaults, and I don't think you'd have this sort of problem. – Bernard Mar 04 '19 at 16:44#1argument of the section inside the command you could possibly solve the problem -that is the "why?"-) – koleygr Mar 04 '19 at 16:54\everyparwhich executed in horizontal mode i.e when TeX see H of Hello, so when color change was already done. – touhami Mar 04 '19 at 19:18