6

I would like to place symbol \ding{97} directly at the constant distance from the headword. I made command to place the symbol

% place frequent star
\newcommand{\freqstar}[1]{\hspace*{-1em}{\color{darkgreen}{\ding{97}}}}

in front of the headword. For placing the headwords I use this command

\newcommand\entry[3][]{\hangpara{2em}{1}{\fontfamily{phv}\selectfont{\textbf{{#2}}}}\#3\ifx\relax#1\relax\markboth{#2}{#2}\else\markboth{#1}{#1}\fi\par}\nopagebreak[4]

Problem is that the position is not precise. I would like to achieve that headwords are placed exactly same and the symbol is in front of them.

Follows a picture of incorrect placement: symbol placement

5
  • 2
    You should make a complete example that demonstrates your problem so that people don't have to track down the packages your are using before being able to do some tests. Dec 19, 2012 at 13:44
  • Thank you for remark. I will always put the minimum example.
    – chejnik
    Dec 19, 2012 at 13:59
  • 1
    Why the argument #1 if you don't use any?
    – egreg
    Dec 19, 2012 at 14:02
  • Thats true. I can delete it. I copy the structure from working command and left the field with no reason.
    – chejnik
    Dec 19, 2012 at 14:03
  • similar topic: How to create hanging bullet? has quite a bit of commentary (although i think the answer here is a better fit for the current question). Dec 19, 2012 at 14:05

1 Answer 1

7

Macro \llap can be used to print something to the left without changing the current position:

\newcommand{\freqstar}{% without argument
  \leavevmode % stars paragraph if necessary, \llap does not do this
  \llap{%
    \textcolor{darkgreen}{\ding{97}}%
    \,% space between symbol and entry
  }%
}%

With lowering:

\newcommand{\freqstar}{% without argument
  \leavevmode % stars paragraph if necessary, \llap does not do this
  \llap{%
    \raisebox{-.2ex}{%
      \textcolor{darkgreen}{\ding{97}}%
    }%
    \,% space between symbol and entry
  }%
}%

Centered around the math axis:

\documentclass{article}
\usepackage{pifont}
\usepackage{xcolor}
\definecolor{darkgreen}{rgb}{0,.5,0}

\newcommand{\freqstar}{%
  \leavevmode % stars paragraph if necessary, \llap does not do this
  \llap{%
    $%
      \setlength{\mathsurround}{0pt}%
      \vcenter{%
        \hbox{%
          \textcolor{darkgreen}{\ding{97}}%
        }%
      }%
    $%
    \,% space between symbol and entry
  }%
}%

\begin{document}
\freqstar \textbf{\ae}
\end{document}

Result

4
  • Thank you. It works as wished - except that I need to lower the position of symbol now.
    – chejnik
    Dec 19, 2012 at 14:02
  • Excellent and beautifull :) !!! Merry Christmas dear community.
    – chejnik
    Dec 19, 2012 at 16:36
  • How is \vcenter defined? If I am not mistaken it is a tex primitive, right?
    – azetina
    Dec 19, 2012 at 18:37
  • @azetina Yes. it is a TeX primitive. Dec 19, 2012 at 20:46

You must log in to answer this question.

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