aboutsummaryrefslogtreecommitdiff
path: root/fib.sty
blob: e5465a596d2aebb7d299a56e9a451e80e071f20b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
\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