[Tex/LaTex] Making a LaTeX text R logo. How maintain the proportions

r

I tried to mimic the R logo in jpg format from R site only with LaTeX in order to make it scalable with the context without external files.

This is the result at tiny, normal and huge size, compared with the jpg at scale 25%, 50 and 100%:

MWE

Evidently, the LaTeX logotype is far from perfect in many areas even at normal size, but the worst is that the proportion between character R and the background circles (\bircirc) is not constant, although everything is defined in em units. Why?

Could be a better way to construct a pretty inline R logo? Of course, it should be not the jpg file nor a scalable vector graphics (SVG) converted to pdf, nor a simple format of the R character, like \newcommand{\R}{\textbf{\textup{R}}}

This is the MWE code:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xspace}
\usepackage{xcolor}
\usepackage{graphicx}
\definecolor{Rcolor}{RGB}{150,160,190}

\newcommand{\R}{%
\raisebox{.3em}{\hspace{1.2em}%
\llap{\resizebox{1.09em}{.5em}{\color{black}$\bigcirc$}}%
\llap{\resizebox{1.199em}{.55em}{\color{darkgray}$\bigcirc$}}%
\llap{\resizebox{1.19em}{.52em}{\color{gray!50}$\bigcirc$}}%
\llap{\resizebox{1.1em}{.5em}{\color{gray}$\bigcirc$}}%
\llap{\resizebox{1.25em}{.55em}{\color{gray}$\bigcirc$}}%
}%
\hspace{-.85em}%
\textbf{%
%\resizebox{.55em}{1.5ex}{\textcolor{black!80}{\textsf{R}}}%
\textcolor{black}{\textsf{R}}%
\hspace{-.025em}\raisebox{.01em}{\llap{\textcolor{Rcolor}{\textsf{R}}}}%
}%
\xspace}

\begin{document}

Bitmap logo: 
\includegraphics[scale=.25]{Rlogo.jpg}
\includegraphics[scale=.5]{Rlogo.jpg}
\includegraphics[scale=1]{Rlogo.jpg}

\LaTeX\ logo:~~ 
\tiny{\R}  \normalsize{ \R}  \Huge{\R}


\end{document}

Best Answer

Text and math fonts are not linearly scaled, LaTeX chooses (or can choose) the nearest design size font in each case, so the relative size of your math circle and text R are not guaranteed. Simplest is to save a normal size logo in a box and then scale the box to the current font size so it all scales together, so once you get it right for one size it will look the same at all sizes.

enter image description here

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{xspace}
\usepackage{xcolor}
\usepackage{graphicx}
\definecolor{Rcolor}{RGB}{150,160,190}

\newcommand{\Rx}{\fontsize{10pt}{12pt}\selectfont
\raisebox{.3em}{\hspace{1.2em}%
\llap{\resizebox{1.09em}{.5em}{\color{black}$\bigcirc$}}%
\llap{\resizebox{1.199em}{.55em}{\color{darkgray}$\bigcirc$}}%
\llap{\resizebox{1.19em}{.52em}{\color{gray!50}$\bigcirc$}}%
\llap{\resizebox{1.1em}{.5em}{\color{gray}$\bigcirc$}}%
\llap{\resizebox{1.25em}{.55em}{\color{gray}$\bigcirc$}}%
}%
\hspace{-.85em}%
\textbf{%
%\resizebox{.55em}{1.5ex}{\textcolor{black!80}{\textsf{R}}}%
\textcolor{black}{\textsf{R}}%
\hspace{-.025em}\raisebox{.01em}{\llap{\textcolor{Rcolor}{\textsf{R}}}}%
}}%

\newbox\rbox
\savebox\rbox{\scalebox{0.1}{\Rx}}

\makeatletter
\def\R{\scalebox{\f@size}{\usebox\rbox}\xspace}
\makeatletter

\begin{document}

Bitmap logo: 
%\includegraphics[scale=.25]{Rlogo.jpg}\includegraphics[scale=.5]{Rlogo.jpg}\includegraphics[scale=1]{Rlogo.jpg}

\LaTeX\ logo:~~ 
\tiny{\R}  \normalsize{ \R}  \Huge{\R}


\end{document}
Related Question