17

Can I insert a graphic in-line in a sentence?


Use case: I'm writing a manual that involves navigating the Windows Start Menu. I would like to insert a little graphic of the start menu in-line in the text. I am aware of a sparklines package that does something similar, but have not been able to distill that to a simple example.

Is there a macro or command that can help with this?

In addition (and I hope this is a valid part of the question, but am happy to post it as a new question) I would like a shortcut or command to display the Windows Start Menu plus n steps of navigation, so I could write the following:

Some paragraph and then \WinMenu{Start}{Programs}{Foo}{Bar}{Baz.exe} and then more text.

or

Lorem ipsum \WinMenu{Programs,Foo,Bar,Baz.exe} and then more text.

or something similar, and the result in the PDF will be stylized somehow, with the little Start Menu box icon (shown as "GRAPHIC" below), and then, for example, in bold or \tttext fonts, GRAPHIC > Foo > Bar > Baz.exe as part of and embedded in the existing sentence.

3 Answers 3

20

Here is one way to do it. I took the liberty to add some formatting, but feel free to change it as you wish:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}

\newcommand*{\WineMenuColor}{black}%
\newcommand*{\StartMenu}{\includegraphics[scale=0.2]{StartIcon}}%
\newcommand*{\WinMenu}[1]{%
\StartMenu %
\foreach \x in {#1} {%
    $\boldsymbol{\textcolor{\WineMenuColor}{>}}$ \texttt{\textcolor{\WineMenuColor}{\x}}%
}}%

\begin{document}
Lorem ipsum \WinMenu{Programs,Foo,Bar,Baz.exe} and then more text.
\end{document}

enter image description here

3
  • Thanks. This is a good solution. I will post my version (based off an earlier version of yours) for reference.
    – mankoff
    Sep 19, 2011 at 14:49
  • Isn't it possible to define image size based on font size, just like in HTML? May 13, 2015 at 15:24
  • @TomášZato: I am not that familiar with HTML and think you should post separate question. May 13, 2015 at 19:02
8

Based on the selected answer by @Peter I implemented it like so. Please excuse (or edit!) formatting errors below:

\usepackage{tikz}
\newcommand{\StartMenu}{\includegraphics[scale=0.22]{start.pdf}}%
\newcommand{\WinMenu}[1]{%
   \StartMenu
   \texttt{\,Start$>$Programs}%
   \foreach \x in {#1} {%
   \texttt{$>$\x}%    
   }%
}%

It looks better to have the word "Start" be in the same font as the rest of the text. I am also lazy and do not want to type "Start,Programs" each time, so they are hard coded. Use case is: Also, \WinMenu{Foo,Bar,Baz} and some text and result is:

Sample showing WinMenu command

The vertical alignment of the icon is off by a tiny bit, but it is good enough for my purposes.

1
  • The vertical alignment can easily be corrected with \raisebox (\raisebox{-.5ex}{\includegraphics{whatever.jpg}}) Jan 24, 2018 at 6:06
1

Not really a solution: use \includegrapchis and play a bit with the picture size. But you have to do it for each font size.

Concerning menu: http://ctan.org/tex-archive/macros/latex/contrib/menu

Menu.sty define a command \menu{Programm!!Menu1!Command} and expand it to something like Programm=>Menu1->Command. You can use it for documentations of programs.

If you solved your main question (inline Micro-graphics) you may combine it with menu.sty.

You must log in to answer this question.

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