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'm trying to create a symbol of a gray triangle with a black border. I managed to do so using:

\newcommand{\factor}{{\color{gray} \blacktriangledown}\hspace{-1.6ex}\triangledown}

However, the two triangles go out of sync when the \factor is used in a subscript or superscript. That is, the space becomes too large and the black triangle is no longer over the gray one.

Is there a way to ask the space to be relative to the current font, such that it will take into account whether it is in super/sub-script?

share|improve this question

1 Answer 1

The simplest way is to use \mathrlap from mathtools

\usepackage{mathtools}
\newcommand{\factor}{\mathrlap{\color{gray}\blacktriangledown}\triangledown}

With \mathrlap you get "no advancement", so the two symbols are placed one over the other.

A pair of extra braces would allow to say $a_\factor$; on the other hand there are already a number of commands that don't allow it (\notin, for example). In this case, they could be safely added:

\newcommand{\factor}{{\mathrlap{\color{gray}\blacktriangledown}\triangledown}}

However, the extra pair of braces will make the symbol an ordinary one, with regard to surrounding space (that's why \notin hasn't it, since it's a relation symbol). So one has to pay attention on the nature of the requested symbol.

To get spacing in math mode that changes automatically in text or in sub(super)scripts, you have to use mu units and \mspace; but in this case it's not necessary.

share|improve this answer
    
Adding an extra {} in the definition will allow you to use a_\factor instead of having to say a_{\factor}. –  Peter Grill Oct 21 '11 at 18:00
    
@PeterGrill Yes; I'll add in my answer. –  egreg Oct 21 '11 at 18:06

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.