Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

up vote 32 down vote accepted

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

share|improve this answer

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:

share|improve this answer
1  
This is pretty elegant. –  You Sep 6 '11 at 21:50

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.