Change the color of title

Insert the colour directly in the \title:

enter image description here

\documentclass{article}

\usepackage{lipsum}% Just for this example
\usepackage{xcolor,sectsty}

\definecolor{astral}{RGB}{46,116,181}
\subsectionfont{\color{astral}}
\sectionfont{\color{astral}}

\title{\color{astral} My title}
\author{An Author}

\begin{document}

\maketitle

\begin{abstract}
  \lipsum[1]
\end{abstract}

\smallskip

\noindent \textbf{Summary:}
\lipsum*[2]

\section{A section}
\lipsum[3]

\end{document}

The above suggestion may seem crude. It is, however, inserted as a part of a one-time usage macro \title, and therefore sufficient for the means. For a more formalized approach, you could patch the inner \@maketitle macro - responsible for setting up the title display:

\usepackage{etoolbox}
\makeatletter
\patchcmd{\@maketitle}% <cmd>
  {\@title}% <search>
  {\color{\@titlecolor}\@title}% <replace>
  {}{}% <success><failure>
\newcommand{\@titlecolor}{black}
\newcommand{\titlecolor}[1]{\renewcommand{\@titlecolor}{#1}}
\makeatother

The above code provides \titlecolor{<color>} which allows you to switch to colour as needed (for example, \titlecolor{astral} would provide the same output). This code is also dependent on the structure of \@maketitle, which may be different for other classes or influenced by certain packages.


Another (less formal) way of address a title colour change could be to only update the way \title handles its argument:

\makeatletter
\renewcommand{\title}[1]{\renewcommand{\@title}{\color{\@titlecolor}#1}}
\newcommand{\@titlecolor}{black}
\newcommand{\titlecolor}[1]{\renewcommand{\@titlecolor}{#1}}
\makeatother

It is cleaner and clearer to avoid hard-coding formatting in the content of commands like \title. Although this is typically a once-off command in a document - if only because \maketitle enforces this by wiping everything - it is still best avoided, I think.

And the alternative is not the scary-looking patching of internal commands. It is, as in the case of section headings, to use a package which does the scary stuff for you. In this case titling specialises in customising the format of document titles.

For example:

\pretitle{\begin{center}\LARGE\color{astral}}
\posttitle{\par\end{center}\vskip 0.5em}

This is slightly more complex than putting the colour in \title but not much. I started with the defaults which I copied from titling's documentation:

\pretitle{\begin{center}\LARGE}
\posttitle{\par\end{center}\vskip 0.5em}

I then simply added the colour specification following the font specification \LARGE.

And that's it:

custom title

\documentclass[11pt,a4paper]{article}
\usepackage{amsmath,url}
\usepackage[utf8x]{inputenc}
\usepackage[czech]{babel}
\usepackage{xcolor}
\usepackage{sectsty,titling}

\definecolor{astral}{RGB}{46,116,181}
\subsectionfont{\color{astral}}
\sectionfont{\color{astral}}

\pretitle{\begin{center}\LARGE\color{astral}}
\posttitle{\par\end{center}\vskip 0.5em}

\title{Title}
\author{Author}

\begin{document}
\maketitle
\begin{abstract}
  An abstract
\end{abstract}
\smallskip
\noindent \textbf{Klíčová slova:}\dots
\section{A section}
\end{document}

Tags:

Color

Titles