My goal is to link to external video files in beamer presentations rather then embedding them directly into the PDF (e.g., with media9 package) to keep the size as small as possible.

I use the hyperref package to create a clickable area (a link) which contains a preview image of the video and TikZ to create a small play button as overlay to attract presenter's attention. The final result looks like this:

vlink command preview

I wrapped the hyperref and TikZ commands in an own command \vlink[options]{name_of_video_file} and I use the pgfkeys package so that my command can accept key-value pairs as options.

The vlink command runs fine when using \textwidth or integer dimensions like 2cm (e.g., \vlink[width=\textwidth]{my_video_file.mp4}). But, when invoking with width=0.5\textwidth or width=2.5cm, I get an Illegal unit of measure (pt inserted) error because my TikZ command uses \fontsize{0.40\vlinkWidth}... to set the overlay dimensions. Obviously, LaTeX expands 0.5\texwidth to something strange which I don't understand (the LaTeX Wikibook states it should be a length).

So, what is the correct way to handle the passed width here?

Any help is appreciated. :)

A minimal working example is attached below (please add a dummy picture named BigBugBunny.mp4.preview.png to avoid compilation errors):



    /vlink/.is family,
    % Here are the options that a user can pass
    default/.style = 
    {width = \textwidth, color=black, opacity=0.25},
    width/.estore in = \vlinkWidth,
    color/.estore in = \vlinkColor,
    opacity/.estore in = \vlinkOpacity,
    \pgfkeys{/vlink, default, #1}%
        \node (previewimage)
        \node [align=center,color=\vlinkColor,opacity=\vlinkOpacity,text width=\vlinkWidth] at

    \begin{frame}{Test `vlink' Command}
        \item Use `vlink' to create a link to a video file.
        \item I.e., the video file is not embedded into the final PDF.
        \item Instead, the default video player is launched when clicking the link.
        \item The link area is a preview image of the embedded video.

  • 2
    Try \fontsize{0.4\dimexpr\vlinkwidth}... Nov 11, 2019 at 10:19

1 Answer 1


\vlinkWidth, is a macro not a length register, you would see the same if you went \def\zzz{100.5pt} then used 0.4\zzz as a length.

The macro would expand and give you 0.4100.5pt with two . and the error that you show.

As Ulrike commented you can use \dimexpr which is essentially an anonymous length register so 0.4\dimexpr\zzz\relax is again a valid length or in your case 0.4\dimexpr\vlinkwidth\relax

  • Thank you very much @UlrikeFischer and @DavidCarlisle for providing a solution and also the background information to use an anonymous length register using \dimexpr. Nov 12, 2019 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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