30

I want to get the LaTeX2e logo but with each character having a different color. I know that \LaTeXe produces the logo, but how do I give a color to each character?

2 Answers 2

32

You can use the \textcolor command from the xcolor package to give a color to each character of the logo. Running

texdef -t latex LaTeXe

in a terminal, you can get the implememtation of the LaTeX2e logo:

\mbox {\m@th
  \if b\expandafter \@car \f@series \@nil \boldmath \fi
  \LaTeX \kern .15em2$_{\textstyle \varepsilon }$}

Since the \LaTeXe command is built upon the \LaTeX command which, in its turn, uses the \TeX command (you can use texdef to see their definition), I defined three commands \ClrTeX, \ClrLaTeX, and \ClrLaTeXe to assign a color to each character of the three logos:

\documentclass{article}
\usepackage{xcolor}

\makeatletter
\newcommand*\ClrTeX[3]{%
  \textcolor{#1}{T}\kern-.1667em%
  \lower.5ex\hbox{\textcolor{#2}{E}}\kern-.125em\textcolor{#3}{X}\@}

\newcommand*\ClrLaTeX[5]{%
  \textcolor{#1}{L}\kern-.36em%
  {\sbox\z@ T%
     \vbox to\ht\z@{\hbox{\check@mathfonts
    \fontsize\sf@size\z@
    \math@fontsfalse\selectfont
    \textcolor{#2}{A}}%
    \vss}%
  }%
  \kern-.15em%
  \ClrTeX{#3}{#4}{#5}}

\newcommand*\ClrLaTeXe[7]{%
  \mbox{\m@th
    \if b\expandafter\@car\f@series\@nil\boldmath\fi
    \ClrLaTeX{#1}{#2}{#3}{#4}{#5}\kern.15em%
    \textcolor{#6}{2}$_{\textstyle\textcolor{#7}{\varepsilon}}$}}
\makeatother

\begin{document}

\TeX\quad
\ClrTeX{red}{green}{blue}

\LaTeX\quad
\ClrLaTeX{red}{green}{blue}{gray}{magenta}

\LaTeXe\quad
\ClrLaTeXe{red}{green}{blue}{gray}{magenta}{olive}{purple}

\end{document}

enter image description here

13

An alternative solution is to define \ClrLaTeXe based on local patches of \TeX, \LaTeX and \LaTeXe:

\documentclass{article}

\usepackage{etoolbox}
\usepackage{xcolor}

\newrobustcmd*{\ClrLaTeXe}[7]{%
  \bgroup%
  \def\unskippp{\unskip\unskip\unskip}%
  \expandafter\patchcmd\csname LaTeX \endcsname {L}          {\textcolor{#1}{L}}          {\unskippp}{}%
  \expandafter\patchcmd\csname LaTeX \endcsname {A}          {\textcolor{#2}{A}}          {\unskippp}{}%
  \patchcmd\TeX                                 {T}          {\textcolor{#3}{T}}          {\unskippp}{}%
  \patchcmd\TeX                                 {E}          {\textcolor{#4}{E}}          {\unskippp}{}%
  \patchcmd\TeX                                 {X}          {\textcolor{#5}{X}}          {\unskippp}{}%
  \expandafter\patchcmd\csname LaTeXe \endcsname{2}          {\textcolor{#6}{2}}          {\unskippp}{}%
  \expandafter\patchcmd\csname LaTeXe \endcsname{\varepsilon}{\textcolor{#7}{\varepsilon}}{\unskippp}{}%
  \LaTeXe%
  \egroup%
}

\begin{document}

\noindent
\ClrLaTeXe{magenta}{cyan}{blue}{green}{orange}{red}{brown}

\end{document}

The resulting output is:

1
  • 1
    This is pretty elegant.
    – You
    Commented Sep 6, 2011 at 21:50

You must log in to answer this question.

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