3

I am writing a set of notes for which so far, I had been using the article class, but have recently decided to switch to amsart. I had a bunch of declarations (using the sectsty package) to make sections, subsections, etc. colored.

Pretty much everything else works in my LaTeX document when I compile with article replaced by amsart except for the sectsty-based commands, and I get an error message which reads

/usr/local/texlive/2015/texmf-dist/tex/latex/sectsty/sectsty.sty:296: Package sectsty Error: The sectsty package doesn't work with (sectsty) this document class.

Since my sole purpose is to have different section and subsection colors, I am looking to replace the following set of commands

\chapterfont{\color{RubineRed}} % sets colour of chapters (works only with sectsty)
\sectionfont{\color{RubineRed}} % sets colour of sections (works only with sectsty)
\subsectionfont{\color{blue}} % sets colour of subsections (works only with sectsty)

with something that achieves the same effect. Any ideas will be greatly appreciated!

EDIT: As pointed out by cfr, article doesn't have chapters, so the \chapterfont command above is redundant.

2
  • Neither article nor amsart supports chapters.
    – cfr
    Commented Aug 22, 2016 at 0:56
  • @cfr, okay you can ignore the chapters command. It never gave me an error (with sectsty and article) because I never used a chapter in the first place. The question pertains to color in sections and subsections, when amsart is used. Commented Aug 22, 2016 at 0:57

1 Answer 1

4

You can use the etoolbox package to patch the \section and \subsection commands:

\documentclass{amsart}
\usepackage[dvipsnames]{xcolor}
\usepackage{etoolbox}
\patchcmd{\section}{\normalfont}{\normalfont\color{RubineRed}}{}{}
\patchcmd{\subsection}{\normalfont}{\normalfont\color{blue}}{}{}
\usepackage{lipsum}
\begin{document}
\section{A section}
\lipsum[1-2]
\subsection{A subsection}
\lipsum[1-2]
\end{document}

enter image description here

0

You must log in to answer this question.

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