[Tex/LaTex] Writing Google logo in LaTeX

fontsgraphicssymbols

This is very hard to google itself. I have been told it is possible to use the Google logo in regular text in LaTeX, but I'm struggling to find out how.

For example:

Some words, then {Google Logo here} and then so on...

Best Answer

Image-based approach

The scaling is not perfect, but it's pretty close. The basic idea is to set the height of the image to the sum of the height of G and the depth of g in the current font. Then lower the image by the depth of g to attempt to align the baseline.

Unfortunately, this method is dependent on the descender depth and capital height of the logo font relative to those of the font in use in the TeX document. Slight tweaks might be required. I downloaded the logo as an SVG image and converted it to PDF for use with \includegraphics.

The \protected\def is so that the command can be used in moving arguments. If hyperref is used, you might also want \texorpdfstring or similar for bookmarks/etc.

\documentclass{article}
\usepackage{calc,graphicx}
\newlength\htG\newlength\dpg
\protected\def\google{\settoheight{\htG}{G}\settodepth{\dpg}{g}%
  \raisebox{-\dpg}{\includegraphics[height=\htG+\dpg]{Google_2015_logo}}}

\title{\google\ in the title}
\author{A \google r}

\begin{document}
\maketitle
\section{\google\ in a section}
\google\ all around!
\end{document}

enter image description here


SVG path approach (with Star Wars-inspired testing code)

Alternative to the image-based approach, we can use TikZ's svg.path library and borrow the paths for each letter directly from Google's SVG file. This allows us to set the baseline more precisely at the bottom of the "l"'s rectangle (which is why it's drawn first). The main ideas are quite similar to the original method, though.

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{svg.path}
\definecolor{gG}{RGB}{ 60, 186,  84}
\definecolor{gY}{RGB}{244, 194,  13}
\definecolor{gB}{RGB}{ 72, 133, 237}
\definecolor{gR}{RGB}{219,  50,  54}

\newlength\htG
\protected\def\google{\settoheight{\htG}{G}%
  \begin{tikzpicture}[yscale=-1,scale=(\htG/240pt),baseline=(baseline)]
    \fill[fill=gG] svg {m797.49 249.7h35.975v-240.75h-35.975z};
    \coordinate (baseline) at (current bounding box.south);
    \fill[fill=gB] svg {m246.11 116.18h-116.57v34.591h82.673c-4.0842 48.506-44.44 69.192-82.533 69.192-48.736 0-91.264-38.346-91.264-92.092 0-52.357 40.54-92.679 91.371-92.679 39.217 0 62.326 25 62.326 25l24.22-25.081s-31.087-34.608-87.784-34.608c-72.197-0.001-128.05 60.933-128.05 126.75 0 64.493 52.539 127.38 129.89 127.38 68.031 0 117.83-46.604 117.83-115.52 0-14.539-2.1109-22.942-2.1109-22.942z};
    \fill[fill=gR] svg {m341.6 91.129c-47.832 0-82.111 37.395-82.111 81.008 0 44.258 33.249 82.348 82.673 82.348 44.742 0 81.397-34.197 81.397-81.397 0-54.098-42.638-81.959-81.959-81.959zm0.47563 32.083c23.522 0 45.812 19.017 45.812 49.66 0 29.993-22.195 49.552-45.92 49.552-26.068 0-46.633-20.878-46.633-49.79 0-28.292 20.31-49.422 46.741-49.422z};
    \fill[fill=gY] svg {m520.18 91.129c-47.832 0-82.111 37.395-82.111 81.008 0 44.258 33.249 82.348 82.673 82.348 44.742 0 81.397-34.197 81.397-81.397 0-54.098-42.638-81.959-81.959-81.959zm0.47562 32.083c23.522 0 45.812 19.017 45.812 49.66 0 29.993-22.195 49.552-45.92 49.552-26.068 0-46.633-20.878-46.633-49.79 0-28.292 20.31-49.422 46.741-49.422z};
    \fill[fill=gB] svg {m695.34 91.215c-43.904 0-78.414 38.453-78.414 81.613 0 49.163 40.009 81.765 77.657 81.765 23.279 0 35.657-9.2405 44.796-19.847v16.106c0 28.18-17.11 45.055-42.936 45.055-24.949 0-37.463-18.551-41.812-29.078l-31.391 13.123c11.136 23.547 33.554 48.103 73.463 48.103 43.652 0 76.922-27.495 76.922-85.159v-146.77h-34.245v13.836c-10.53-11.347-24.93-18.745-44.04-18.745zm3.178 32.018c21.525 0 43.628 18.38 43.628 49.768 0 31.904-22.056 49.487-44.104 49.487-23.406 0-45.185-19.005-45.185-49.184 0-31.358 22.619-50.071 45.66-50.071z};
    \fill[fill=gR] svg {m925.89 91.02c-41.414 0-76.187 32.95-76.187 81.57 0 51.447 38.759 81.959 80.165 81.959 34.558 0 55.768-18.906 68.426-35.845l-28.235-18.787c-7.3268 11.371-19.576 22.484-40.018 22.484-22.962 0-33.52-12.574-40.061-24.754l109.52-45.444-5.6859-13.318c-10.58-26.08-35.26-47.86-67.92-47.86zm1.4268 31.413c14.923 0 25.663 7.9342 30.224 17.447l-73.139 30.57c-3.1532-23.667 19.269-48.017 42.915-48.017z};
  \end{tikzpicture}%
}

% just for the testing section
\newcommand{\testing}[1]{\noindent\leavevmode#1\rlap{G}\google\llap{e} \quad \rlap{Google}\google \qquad \google\llap{Google}\par}

\title{\google\ in the title}
\author{A \google r}

\begin{document}
\maketitle
\section{\google\ in a section}
\google\ all around! 

\section{Some testing code}
\testing{\tiny}
\testing{\scriptsize}
\testing{\footnotesize}
\testing{\small}
\testing{\normalsize}
\testing{\large}
\testing{\Large}
\testing{\LARGE}
\testing{\huge}
\testing{\Huge}
\end{document}

enter image description here