如何在 LaTeX 中创建 LMB(鼠标左键单击)或 RMB(鼠标右键单击)的符号?

如何在 LaTeX 中创建 LMB(鼠标左键单击)或 RMB(鼠标右键单击)的符号?

两周以来,我一直在 LaTeX 中搜索 LMB(鼠标左键单击)或 RMB(鼠标右键单击)符号。我曾在手册中看到过它,但现在再也找不到它了……

现在我想编写一本手册,为了更容易理解如何使用该软件,集成这些简单的符号就太好了!

我已经在 Illustrator 中设计了符号。但现在我不知道如何将其导入 LaTeX 或如何使用“特殊”包来设计符号?!?

缺少图片,因为我是新手,不允许上传图片。

它应该看起来像一个椭圆形。顶部的椭圆形中有一个倒置的 T。如果它应该是“鼠标左键单击”,则左侧是黑色。如果它应该是“鼠标右键单击”,则右侧是黑色。

希望描述足够充分。如果不够,请发帖,我会将图片发给您。

答案1

由于您已经创建了这些图像,因此只需将它们包含在文档中即可。确保图像周围的边界框紧密,否则图像周围会出现太多空白。

要包含图像,请使用

\usepackage{graphicx}% http://ctan.org/pkg/graphicx

在文档序言中,以及类似命令

\newcommand{\LMB}{\includegraphics[height=.8\baselineskip]{LMB}}% Left Mouse Button
\newcommand{\RMB}{\includegraphics[height=.8\baselineskip]{RMB}}% Right Mouse Button

您的按钮从 Adob​​e Illustrator 导出为LMB.pdfRMB.pdf(如果您使用 PDFLaTeX)。

上述命令允许您在文本中使用\LMB\RMB,并以基线高度的 80% 打印图像。根据您的使用情况,您可能还想包括xspace包裹并在每个命令后插入。这样可以简化/\xspace的使用,而不必总是在它后面添加控制空格。\LMB\RMB\

答案2

我通过谷歌来到这里,希望这个页面会被啮齿动物占领,结果我失望了……但下一个谷歌用户不必忍受这样的失望。即使他们寻求更尖锐的种类

老鼠

文档嵌入在代码中,这是从我维护的供个人使用的包中复制/粘贴的。所有部分\begin/end{macrocode}都被剥离了,但它不必要地创建了一个compeng系列/名称空间。虽然这不应该惹恼最终用户。如果对该包感兴趣,请告诉我,我可以在稍微清理文件后将其发布到 CTAN 上,它主要包含用于 GUI 和文档的图标。

\documentclass[tikz]{standalone}

\usetikzlibrary{calc}
\usetikzlibrary{fadings}

\newlength\len
\setlength\len{1em}

\makeatletter
% To accomodate minor geometry changes within the mouse one needs to optionally enable and disable separate paths.
% The following `if` allows for the middle wheel of the mouse to be activated/deactiveted as necessary.
\newif\if@ce@mouse@wheel
% Open up a tikzset statement and start assigning the necessary keys for the computer mouse pic.
\tikzset{
% We start off with the initial definition of the pic which simply maps to another key which sets the `.code` handler.
 computer mouse/.pic={\tikzset{compeng/mouse={#1}}},
% Although unusual for a pic one also provides a global style option that may modify at some later time.
 every computer mouse/.style={compeng/mouse/setup/.append style={#1}},
% Within my own style sheet I provide a package name space and this has been carried through here. 
% It will only affect you should you start to meddle with the code base. 
% I should've removed it but didn't bother
 compeng/.is family,
 compeng, % Ensure this becomes absolute
% Initially a family is setup for the mouse under compeng, providing a contained name space for various purposes.
 mouse/.is family,
 mouse/.search also={/tikz, /pgf},
 mouse/.style={
  compeng/mouse/.cd,
  setup,
  #1,
  source,
 },
% One provides the `setup` key to allow for the `classic` and `modern` keys discussed later.
% This basically provides one with global options to the pic that one may set using the `every computer mouse` key defined earlier.
 mouse/.cd,
 setup/.style={},
% The following snippet contructs the mouse, this is done by filling various areas nd then tracing the borders after wards.
% I initially tried making every part separately drawable but this failed on due to the fadings and shadings clashing e.g. lines where faded aswell, there were wierd overlaps and so forth.
 source/.code={
   \fill[compeng/mouse/every mouse] let \n{radius}={0.3*\len}, \n{Radius}={0.4*\len} in  
              (0,0.5*\len)                                                                                                    % Top dead Center
              -- (-\n{Radius}+\n{radius}, 0.5*\len) .. controls (-\n{Radius}, 0.5*\len) .. (-\n{Radius}, 0.5*\len-\n{radius}) % Upper Left Corner
              -- (-\n{Radius},-0.1*\len) arc(180:360:\n{Radius})                                                              % Base
              -- ( \n{Radius}, 0.5*\len-\n{radius}) .. controls ( \n{Radius}, 0.5*\len) .. ( \n{Radius}-\n{radius}, 0.5*\len) % Upper right Corner
              -- cycle
              (0,0) -- (0,0.5*\len);
   \fill[compeng/mouse/every lmb] let \n{radius}={0.3*\len}, \n{Radius}={0.4*\len} in 
        (0,0) |- (-0.4*\len+\n{radius}, 0.5*\len) .. controls (-0.4*\len, 0.5*\len) .. (-0.4*\len, 0.5*\len-\n{radius}) -- (-0.4*\len,-0.1*\len) 
   %            arc(180:225:\n{Radius}) 
              -- cycle;
   \fill[compeng/mouse/every rmb] let \n{radius}={0.3*\len}, \n{Radius}={0.4*\len} in 
        (0,0) |- ( 0.4*\len-\n{radius}, 0.5*\len) .. controls ( 0.4*\len, 0.5*\len) .. ( 0.4*\len, 0.5*\len-\n{radius}) -- ( 0.4*\len,-0.1*\len) 
   %            arc(0:-45:\n{Radius}) 
              -- cycle;
   \if@ce@mouse@wheel % Pretty sure I've used if's in paths before ? It wouldn't work here
     \fill[compeng/mouse/every mmb] ( 0,0.25*\len) ellipse ({0.075*\len} and {0.15*\len});
   \fi
   \path[draw, line cap =round] let \n{radius}={0.3*\len}, \n{Radius}={0.4*\len} in  
              (0,0.5*\len)                                                                                                    % Top dead Center
              -- (-\n{Radius}+\n{radius}, 0.5*\len) .. controls (-\n{Radius}, 0.5*\len) .. (-\n{Radius}, 0.5*\len-\n{radius}) % Upper Left Corner
              -- (-\n{Radius},-0.1*\len) arc(180:360:\n{Radius})                                                              % Base
              -- ( \n{Radius}, 0.5*\len-\n{radius}) .. controls ( \n{Radius}, 0.5*\len) .. ( \n{Radius}-\n{radius}, 0.5*\len) % Upper right Corner
              -- cycle;
   \if@ce@mouse@wheel % Pretty sure I've used if's in paths before ? It wouldn't work here
     \path[draw, line cap =round] 
        (0,-0.025*\len) -- ( 0,0.1*\len)  
        ( 0,0.25*\len) ellipse ({0.075*\len} and {0.15*\len}) 
        ( 0,0.4*\len) -- (0,0.5*\len);
   \else
     \path[draw, line cap =round] 
        (0,-0.025*\len) -- (0,0.5*\len);
   \fi;
 },
% It's handy to be able to alternate between a 2 or 3 button mice in some document contexts and the following provides a means of toggling the middle button on or off.
% The user may do this within a given tikzpicture or globally for a document by setting the `every computer mouse` key to either classic (2 button mouse) or modern (3 button mouse), using the usual `\tikzset` command e.g. \tikzset{every computer mouse={classic}}
 wheel/.is if=@ce@mouse@wheel,
 wheel/.default=true,
 wheel=true, % note that using /.initial store the value elsewhere and does not set the if
 modern/.style={wheel=true},
 classic/.style={wheel=false},
% The mouse is setup with a gray base colour that blends nicely into the buttons. 
% Fiddling with the gradient too much here makes it all rather horrid but the user is free to do so.
 every mouse/.style={compeng/mouse/.cd, mouse color},
 mouse color/.style 2 args={
     top color   =#1,
     bottom color=#2!70!#1},
 mouse color/.default={white}{black},
% The middle mouse is simply represented by an ellipse. 
% The default colour here is simply horrid but it's the best I managed to do.
 every mmb/.style={compeng/mouse/.cd, mmb color},
 mmb color/.style n args={2}{
                 inner color  = #1!70!#2,
                 outer color  = #1!50!#2,
 },
 mmb color/.default={white}{black},
% The left mouse button is setup as a shaded and faded a strip covering the left half of the mouse.
% The shading is tilted some what to enhance the gradient somewhat.
 every lmb/.style={compeng/mouse/.cd, lmb color},
 lmb color/.style n args={3}{
   fill          = #2,
   top    color  = #1, % black!70!white,
   bottom color  = #3!70!#2, % Do not adjust
   shading angle = 10,
   fit fading    = true,
   path fading   = south,
   fading angle  = 10,
 },
 lmb color/.default={gray}{white}{black},
% The right mouse button is similarly constructed
 every rmb/.style={compeng/mouse/.cd, rmb color},
% The commented code below is mostly for experimentation purposes, but it could, with extention, allow one to do things like annotate how long the button is held down for or be used to indicate double and single clicks.
%  rmb/.is choice,
%  rmb/click/.style={rmb color={red}{white}{black}},
%  %rmb/.hold={rmb color},
%  %rmb/.release={rmb color},
%  rmb/rest/.style={rmb color},
%  rmb/.default=rest,
 rmb color/.style n args={3}{
                 fill          = #2,
                 top    color  = #1,  % black!70!white,
                 bottom color  = #3!70!#2,
                 shading angle = -10,
                 fit fading    = true,
                 path fading   = south,
                 fading angle  = -10,
 },
 rmb color/.default={gray}{white}{black},
% Presently any clicking action is represented by colouring the appropriate buttons.
 lmb/.style  = {every lmb/.append style={lmb color={blue}{white}{black}}},
 rmb/.style  = {every rmb/.append style={rmb color={red}{white}{black}}},
 mmb/.style  = {every mmb/.append style={mmb color={cyan}{black}}},
 bmb/.style  = {every lmb/.append style={lmb color={purple}{white}{black}},
                every rmb/.append style={rmb color={purple}{white}{black}}},
% The following key/color combinations should probably not be used nor made available but are here for convenience.
 amb/.style  = {every lmb/.append style={lmb color={purple!60!cyan}{white}{black}},
                every rmb/.append style={rmb color={purple!60!cyan}{white}{black}},
                every mmb/.append style={mmb color={purple!60!cyan}{black}}},
 mlmb/.style = {every lmb/.append style={lmb color={blue!60!cyan}{white}{black}},
                every mmb/.append style={mmb color={blue!60!cyan}{black}}},
 mrmb/.style = {every rmb/.append style={rmb color={red!60!cyan}{white}{black}},
                every mmb/.append style={mmb color={red!60!cyan}{black}}},
}
\makeatother

\begin{document}

\begin{tikzpicture}
\draw[every computer mouse={classic}] 
   let \n{len}={1.5em} in
   pic at (180:\n{len}) {computer mouse={lmb}} 
   pic at ( 90:\n{len}) {computer mouse={}} 
   pic at (  0:\n{len}) {computer mouse={rmb}} 
   pic at (270:\n{len}) {computer mouse={bmb}};
\draw[every computer mouse={modern}] 
   let \n{len}={3em} in
   pic at (0,0) {computer mouse} 
   pic at (180:\n{len}) {computer mouse={lmb}} 
   pic at (135:\n{len}) {computer mouse={lmb,mmb}} 
   pic at ( 90:\n{len}) {computer mouse={mmb}} 
   pic at ( 45:\n{len}) {computer mouse={mmb,rmb}} 
   pic at (  0:\n{len}) {computer mouse={rmb}} 
   pic at (225:\n{len}) {computer mouse={mlmb}}
   pic at (270:\n{len}) {computer mouse={amb}}
   pic at (315:\n{len}) {computer mouse={mrmb}};
\end{tikzpicture}
\end{document}

相关内容