Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I need to use the \Writinghand symbol from the package marvosym.sty. But, for some reason, loading this package raises an error:

(/usr/local/texlive/2013/texmf-dist/tex/latex/ifsym/ifsym.sty (/usr/local/texlive/2013/texmf-dist/tex/latex/tools/calc.sty)

! LaTeX Error: Command \Sun already defined. Or name \end... illegal, see p.192 of the manual.

So, here is my general question: Is there a general procedure to follow when one wants to include only one symbol from a symbols packages (a package that creates many new symbols)?

share|improve this question
    
Perhaps the package bbding and the command \HandPencilLeft represent a quick workaround? –  Christian Hupfer May 2 at 10:29
    

3 Answers 3

\documentclass{article}
\newcommand\Writinghand{{\fontfamily{mvs}\fontencoding{U}\selectfont\char98}}
\begin{document}
\Writinghand 
\Huge \Writinghand
\end{document}
share|improve this answer

No, there is no general procedure. One has to look into the package code and some knowledge of the terminal can be helpful; but one can always open the package file with an editor.

Let's see for \WritingHand that the Comprehensive List tells you it is from marvosym.sty.

First of all, we need to identify how the font is known to LaTeX. In these cases, rather than opening the file in an editor, I use less:

less $(kpsewhich marvosym.sty)

because kpsewhich is the utility that's used internally by the TeX programs to find a file. The first lines in the file are

\ProvidesPackage{marvosym}
  [2011/07/20 v2.2 Martin Vogel's Symbols font definitions]
\newcommand{\mvs}{\fontfamily{mvs}\fontencoding{U}%
\fontseries{m}\fontshape{n}\selectfont}

Good. We know how to load the font. The code is not the best possible, because

\newcommand{\mvs}{\usefont{U}{mvs}{m}{n}}

would be a cleaner call, although they're equivalent. The encoding U is “unspecified“ or “unknown”, which means that LaTeX won't try any of its tricks to adapt commands to the current encoding. It is a standard encoding, so there's no need to declare it beforehand. Any time we need a glyph from the font, we can say

\usefont{U}{mvs}{m}{n}

in a group. Now we look for \WritingHand and we find it on line 80:

\newcommand\WritingHand{\mvchr{98}}     \let\Writinghand\WritingHand

the second part is just an alias. What's \mvchr? It's on line 5

\newcommand{\mvchr}[1]{{\mvs\char#1}}

but it's again poor LaTeX programming, because \symbol{#1} would be better.

So we have all the necessary bits in order to accomplish our task:

\newcommand{\WritingHand}{{\usefont{U}{mvs}{m}{n}\symbol{98}}}

will work without loading any package. If you plan to use \WritingHand in moving arguments (sectional titles or captions, for instance), it may be better to use \DeclareRobustCommand instead of \newcommand, otherwise in the .aux file you would find

{\fontencoding  {#1}\fontfamily  {#2}\fontseries  {#3}\fontshape  {#4}\selectfont  \ignorespaces \char 98\relax }

instead of a simple \WritingHand. Not much of a problem, but possibly annoying.

Suppose instead you want to use the glyph

enter image description here

that is available in the STIX font package. Looking at the documentation, we find it at position octal 204 (decimal 132) in the font stix-extra1 (font table on page 43).

As before, we look in stix.sty, but we don't find extra inside it. Turn back to the documentation: on page 2 we find indeed

There are also three fonts containing extra miscellaneous symbols, stix-extra1, stix-extra2 and stix-extra3, provided as TFM and PFB files without support from the macro package.

This seems a problem, but indeed it isn't. We can proceed almost as before, just adding the necessary infrastructure

\DeclareFontFamily{U}{stixextrai}{}
\DeclareFontShape{U}{stixextrai}{m}{n}
 { <-> stix-extra1 }{}

\newcommand{\WolframSym}{{\usefont{U}{stixextrai}{m}{n}\symbol{132}}}

The same caveat as before for \DeclareRobustCommand applies. The family name stixextrai is arbitrary. Example document:

\documentclass{article}

\DeclareFontFamily{U}{stixextrai}{}
\DeclareFontShape{U}{stixextrai}{m}{n}
 { <-> stix-extra1 }{}

\newcommand{\WolframSym}{{\usefont{U}{stixextrai}{m}{n}\symbol{132}}}

\begin{document}
\WolframSym
\end{document}

which is how I produced the image above.

share|improve this answer

If it is a text symbol, the \usefont command will do, provided you know the characteristics of the font (encoding, family name, &c.) and slot number of the symbols yoy want tu use. For you case there seems to be a name conflict between the ifsym and marvosym packages (there's also one with mathabx, cf. The Comprehensive LaTeX Symbol list, p.101). So you use a new command name in this way:

\newcommand\mySun{\usefont{U}{mvs}{m}{n}\char192} 

Or if you want to keep the command names, you can overwrite the \Sun command from ifsym writing these lines in the preamble:

\usepackage[weather]{ifsym} 
\renewcommand\Sun{\usefont{U}{mvs}{m}{n}\char192}}%
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.