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.

The following code produces the desired result as shown below:

\documentclass[letterpaper]{article}
\usepackage{xcolor}
\usepackage{amsmath,amssymb,calc,bbding}
\usepackage{enumitem}

\newlist{objective}{enumerate}{2}
\setlist[objective]{label=\protect\raisebox{-1pt}{\textcolor{blue!15}{\CheckmarkBold}}\hspace{-0.75\checklength}\arabic*}

\newlength{\checklength}
\settowidth{\checklength}{\CheckmarkBold}

\begin{document}
    % Desired result. 
    \begin{objective}
      \item First
      \item Second
    \end{objective}
    % Not really a desired result.
{\large
    \begin{objective}
      \item First
      \item Second
    \end{objective}}
    % Even worse.
{\huge
    \begin{objective}
      \item First
      \item Second
    \end{objective}}

\end{document}

enter image description here

If you notice at the first level everything seems fine and ok but as the font size increases, there is the issue of proper kerning. Probably if the enumeration can be fixed or scaled it would help a lot.

share|improve this question
add comment

2 Answers

up vote 9 down vote accepted

you don't actually need to know the width of the checkmark. you can simply superimpose the check with \rlap, shifting a bit to the left (relative to the current type size) since the check is a bit wider than a digit. here's a definition of your list item that will accomplish this:

\setlist[objective]{label=\protect\raisebox{-1pt}{\textcolor{blue!15}%
    {\rlap{\kern-.3em\CheckmarkBold}}}\arabic*}

you can omit all the code for \checklength with this definition; nothing else needs to change.

Edit: to adjust for 2-digit numbers, it's necessary to check the numeric value of the counter. this is a bit tricky, since \setlist expands its arguments immediately, and this has to be suppressed so that the counter can be tested. (i've defined a test counter with a not very original name, but it should be possible to use one of the temporary counters already available in latex; i didn't take the time to investigate, since solving the expansion problem was the important thing.) replacing the above code by the following will work for two digits; adapting this for more than two digits is left as an exercise for the reader -- the principle should be clear.

\makeatletter
\newcount\xxtempcnt
\setlist[objective]{label=\protect\raisebox{-1pt}{\textcolor{blue!15}%
    {\xxtempcnt=\@nameuse{c@\@listctr}%
     \rlap{\noexpand\ifnum\xxtempcnt < 10 \kern-.3em
           \noexpand\fi
           \CheckmarkBold}}}\arabic*}
\makeatother

the result:

output using new definition

share|improve this answer
    
Very clever indeed. I forgot all about \rlap. –  azetina Dec 4 '12 at 17:12
    
Works fine up to 9 but as we enter 2 digit numbers, the display is inappropriate. –  azetina Dec 4 '12 at 19:10
    
@azetina -- 2-digit support added; support for more digits left as an exercise for the user, but it should be clear how to do it. –  barbara beeton Dec 4 '12 at 21:56
    
Understood! :-) But where did you get \@nameuse{c@\@listctr} from? –  azetina Dec 4 '12 at 22:56
1  
@azetina -- i stole \@nameuse{c@\@listctr} out of enumitem.sty. it took some hunting to figure out the name of the counter, so i just copied it when i found it. (one always learns something from digging into the source code.) –  barbara beeton Dec 4 '12 at 23:17
add comment

You are setting \checklength at a fixed font size. Instead it should be done before use with the current font size:

\documentclass[letterpaper]{article}
\usepackage{xcolor}
\usepackage{amsmath,amssymb,calc,bbding}
\usepackage{enumitem}

\newlist{objective}{enumerate}{2}
\setlist[objective]{label=%
  \protect\raisebox{-1pt}{\textcolor{blue!15}{\CheckmarkBold}}%
  \SetCheckLength
  \hspace{-0.75\checklength}\arabic*}

\newlength{\checklength}
\settowidth{\checklength}{\CheckmarkBold}
\DeclareRobustCommand*{\SetCheckLength}{%
  \settowidth{\checklength}{\CheckmarkBold}%
}

\begin{document}
    % Desired result.
    \begin{objective}
      \item First
      \item Second
    \end{objective}
    % Not really a desired result.
{\large
    \begin{objective}
      \item First
      \item Second
    \end{objective}}
    % Even worse.
{\huge
    \begin{objective}
      \item First
      \item Second
    \end{objective}}

\end{document}

Result

Different variant for support of more digits

The following example sets the check mark in the background behind the number without occupying additional space:

\documentclass[letterpaper]{article}
\usepackage{xcolor}
\usepackage{amsmath,amssymb,calc,bbding}
\usepackage{enumitem}

\newlist{objective}{enumerate}{2}
\setlist[objective]{label=%
%  \protect\raisebox{-1pt}{\textcolor{blue!15}{\CheckmarkBold}}%
  \protect\CheckNum{\arabic*}%
}
\newcommand*{\CheckNum}[1]{%
  \begingroup
    \leavevmode
    \sbox0{#1}%
    \hbox to \wd0{%
      \hss
      \raisebox{-1pt}[0pt][0pt]{\textcolor{blue!15}{\CheckmarkBold}}%
      \hss
    }%
    \llap{\box0}%
  \endgroup
}

\begin{document}

    % Desired result.
    \begin{objective}
      \item First
      \item Second
      \addtocounter{objectivei}{7}%
      \item Tenth
      \addtocounter{objectivei}{89}%
      \item Hundredth
    \end{objective}
    % Not really a desired result.
{\large
    \begin{objective}
      \item First
      \item Second
      \addtocounter{objectivei}{7}%
      \item Tenth
      \addtocounter{objectivei}{89}%
      \item Hundredth
    \end{objective}}
    % Even worse.
{\huge
    \begin{objective}
      \item First
      \item Second
      \addtocounter{objectivei}{7}%
      \item Tenth
      \addtocounter{objectivei}{89}%
      \item Hundredth
    \end{objective}}
\end{document}

Result

share|improve this answer
    
This seems to do the trick. Still a little puzzled but am gonna try to digest the suggestion above. –  azetina Dec 4 '12 at 17:05
    
Works fine up to 9 but as we enter 2 digit numbers, the display is inappropriate. –  azetina Dec 4 '12 at 19:12
    
Very interesting use of boxes to achieve the desired. –  azetina Dec 4 '12 at 22:58
add comment

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.