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 using this amazing tex.sx answer tikz star macro for rendering a x-out-of-y stars graphic for my skills on my resumé.

The resume is done with xelatex and exported to pdf. Because it is a resumé, I'm concerned about it being machine readable.

Is there any way to add some alt tag/caption/label/invisible text to the output of the tikz, so it can be obtained when doing copy paste of the pdf?

Also, related question: Is there something like blind friendly latex?

I tried \pdftooltip from the \pdfcomment package, but didn't work out.

share|improve this question
add comment

2 Answers

up vote 3 down vote accepted

You could simply add an invisible node on top of the stars that contains the score. That way, the text won't be visible, but it will be copy/pastable:

\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}

\newcommand\score[2]{
\pgfmathsetmacro\pgfxa{#1+1}
\tikzset{
    scorestars/.style={
        star,
        star points=5,
        star point ratio=2.25,
        draw,
        inner sep=1.3pt,
        anchor=outer point 3
    }
}
\begin{tikzpicture}[baseline]
  \foreach \i in {1,...,#2} {
    \pgfmathparse{(\i<=#1?"yellow":"gray")}
    \edef\starcolor{\pgfmathresult}
    \draw (\i*1.75ex,0) node[name=star\i,scorestars,fill=\starcolor]  {};
  }
  \node [font=\tiny, opacity=0] at (current bounding box.mid) {#1/#2};
  \end{tikzpicture}
}

\begin{document}
\score{0}{5} A meagre result.

\score{4}{5} Much better

\score{5}{5} Perfect score!

\end{document}
share|improve this answer
    
that was fast! perfect solution for tikzs. If you don't mind, I will ask @Jake to add this to his tikz star macro. Many thanks for the answer! –  viccuad Jul 16 '13 at 19:04
add comment

You can use the accsupp package.

\documentclass{minimal}
\usepackage{tikz}
\usetikzlibrary{shapes.geometric}
\usepackage{accsupp}

\newcommand\score[2]{%
\BeginAccSupp{method=escape,ActualText={#1 of #2}}%
\pgfmathsetmacro\pgfxa{#1+1}%
\tikzstyle{scorestars}=[star, star points=5, star point ratio=2.25, draw,inner sep=1.3pt,anchor=outer point 3]%
  \begin{tikzpicture}[baseline]
    \foreach \i in {1,...,#2} {
    \pgfmathparse{(\i<=#1?"yellow":"gray")}
    \edef\starcolor{\pgfmathresult}
    \draw (\i*1.75ex,0) node[name=star\i,scorestars,fill=\starcolor]  {};
   }
  \end{tikzpicture}%
\EndAccSupp{}%
}

\begin{document}
\score{0}{5} A meagre result.

\score{4}{5} Much better

\score{5}{5} Perfect score!

\end{document}

Selection output:

0 of 5 A meagre result.
4 of 5 Much better
5 of 5 Perfect score!

Note: I'd have to escape line ends in the \score macro to avoid unintentional spaces.

share|improve this answer
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.