\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{fib}[2013/01/13 Custom Package]

% Source:
% https://tex.stackexchange.com/questions/147701/graphical-placeholder-for-variables
% adjusted slightly to fit better with the exam class (printanswers)

\tikzset{box/.style={draw, rectangle, rounded corners, thick, node distance=7em, text width=6em, text centered, minimum height=3.5em}}
\tikzset{container/.style={draw, rectangle, dashed, inner sep=2em}}
\tikzset{line/.style={draw, thick, -latex'}}

\makeatletter
\newlength\fib@width
\def\fib@widthfactor{1.75}

\tikzset{
   every fill in box/.style={
     inner xsep=0pt,
     minimum height=3ex,
     align=center,
     font={\sffamily\slshape},
   },
   colored box/.style={
      every fill in box,
      fill=yellow!50!white,
   },
   framed box/.style={
      every fill in box,
      draw,
   },
   fill in/.style={
      framed box,
   }
}
\NewDocumentCommand { \fib@hide } { m } {%
   \ifprintanswers
        #1%
   \else
        \phantom{#1}%
   \fi
}
\NewDocumentCommand { \fib@makebox }{ m }{%
   \settowidth{\fib@width}{\tikz\node[fill in]{#1};}%
   \begin{tikzpicture}[baseline=(fill in node.base)]
      \node (fill in node) [text width=\fib@widthfactor*\fib@width,fill in] {%
         \fib@hide{#1}%
      };
   \end{tikzpicture}%
}
\NewDocumentCommand { \fib } { s d{<}{>} o m }{{%
   \IfBooleanT{#1}{\noprintanswers}%
   \IfValueT{#2}{\only<#2>{\noprintanswers}}%
   \IfValueT{#3}{\tikzset{fill in/.style={#3}}}%
   \ifmmode
      \mathchoice
         {\fib@makebox{$\displaystyle#4$}}
         {\fib@makebox{$\textstyle#4$}}
         {\fib@makebox{$\scriptstyle#4$}}
         {\fib@makebox{$\scriptscriptstyle#4$}}
   \else
      \fib@makebox{#4}%
   \fi
   \IfValueT{#2}{}%
}}
\makeatother
% end fib definition

 \endinput