20

I have a logo in vector format (Adobe Illustrator) that I would like to use in my LaTeX documents. How do I create a latex symbol such that I can include this logo inline with the text, similarly to the symbol \LaTeX for example:

enter image description here

UPDATE

My logo contains a 'y' character and the solution outlined works but the baselines do not match (as the logo baseline is the bottom of 'y'). So I fixed it this way:

\usepackage{scalerel}
\def\mylogo{\kern0em\raise-.1667em\hbox{\scalerel*{\includegraphics{mylogo.pdf}}{X}}}

UPDATE 2

An update on the answer seems to be a better way of accomplishing this.

aaragon
  • 3,041

2 Answers2

31

See UPDATE below, for graphics with descenders.

Here, \scalerel* scales the image to take the same vertical footprint as a capital letter "X". That also means the logo will automatically scale with font size. EDITED to make the process a macro (thanks to Maarten).

\documentclass{article}
\usepackage{scalerel}
\def\mylogo{\scalerel*{\includegraphics{ARL_Logo_March2012_BlackGold}}{X}}
\begin{document}
Can I insert my \mylogo{} inline?

\tiny Can I insert my \mylogo{} inline?
\end{document}

enter image description here

Because the original was a vector image stored in PDF, it zooms without loss of resolution:

enter image description here

UPDATE:

If the original graphic has descenders, one has two options.

One can vertically shift (with a \raisebox) the \includegraphics to match the natural baseline of the graphic with the LaTeX baseline and then "fool" \scalerel* but turning off the depth of shifted graphic:

\documentclass{article}
\fboxsep=-\fboxrule
\usepackage{scalerel}
\def\theirlogo{\scalerel*{%
  \setbox0=\hbox{\raisebox{-52pt}{\includegraphics{GoogleLogo}}}\dp0=0pt\box0}{X}}
\begin{document}
Can I insert my \theirlogo{} inline?

\tiny Can I insert my \theirlogo{} inline?
\end{document}

enter image description here

Alternately (and perhaps more efficiently), one could leave the \includegraphics unaltered and add a appropriately sized negative rule (in scalable units) to the second argument of the \scalerel*.

\documentclass{article}
\fboxsep=-\fboxrule
\usepackage{scalerel}
\def\theirlogo{\scalerel*{\includegraphics{GoogleLogo}}{X\rule[-.6ex]{0pt}{1pt}}}
\begin{document}
Can I insert my \theirlogo{} inline?

\tiny Can I insert my \theirlogo{} inline?
\end{document}
  • 2
    Using this solution you could easily create your Latex symbol (command) by putting \newcommand{\mylogo}{\scalerel*{\includegraphics{ARL_Logo_March2012_BlackGold}}{X}\ } in the preamble. Now you can use the command \mylogo wherever you want inside your document. – Maarten Dhondt Jan 22 '15 at 12:13
  • @MaartenDhondt Yes, that would be recommended. I shall revise my MWE to reflect that. – Steven B. Segletes Jan 22 '15 at 12:14
  • Yes @StevenB.Segletes, do it so that your answer is complete. – aaragon Jan 22 '15 at 15:01
  • @aaragon I believe that such an edit has already been made, so that \mylogo{} is all that need appear in the document itself, now that it is defined in the preamble. – Steven B. Segletes Jan 22 '15 at 15:02
  • @StevenB.Segletes he doesn't use braces. – aaragon Jan 22 '15 at 15:03
  • @aaragon Your original question asked for it to be like \LaTeX, and that uses braces, as in \LaTeX{}. The reason that is a preferred solution is that if I add a space inside the macro, as did Maarten, then I can't use the macro immediately before punctuation, such as , or . because a space will be inserted. This closing {} brace approach is considered preferable because of its flexibility with punctuation. You get used to it. – Steven B. Segletes Jan 22 '15 at 15:06
  • @StevenB.Segletes got it! Thanks again, it's a great solution. – aaragon Jan 22 '15 at 15:08
  • 1
    @aaragon See https://tex.stackexchange.com/questions/31091/space-after-latex-commands, for example, for more discussion of this issue. And lest you think xspace is an alternative, see this: https://tex.stackexchange.com/questions/86565/drawbacks-of-xspace. – Steven B. Segletes Jan 22 '15 at 15:09
  • 1
    My logo has a 'y' letter in it, so the baseline of the characters do not align (it's as if the bottom of the 'character' is the baseline for the logo). Is there a way to get around this? – aaragon Feb 06 '15 at 10:16
  • @aaragon Please see my updated answer. – Steven B. Segletes Feb 06 '15 at 11:20
2

Why do not use

\def\mylogo{{\includegraphics[height=1.4ex]{ARL_Logo_March2012_BlackGold}}}
\begin{document}
Can I insert my \mylogo{} inline?

ex is the height of the "x" character, and changes with the font size.

lehalle
  • 185