aboutsummaryrefslogtreecommitdiff
path: root/fib.sty
diff options
context:
space:
mode:
authorChristopher Baines <mail@cbaines.net>2014-04-01 19:10:41 +0100
committerChristopher Baines <mail@cbaines.net>2014-04-07 15:10:02 +0100
commit723b6ded0066651ac8521ce1320371c8430b1434 (patch)
treec53525348a43d840740971ed01c4b48c0a0fe291 /fib.sty
downloadmathematical-worksheets-723b6ded0066651ac8521ce1320371c8430b1434.tar
mathematical-worksheets-723b6ded0066651ac8521ce1320371c8430b1434.tar.gz
Initial commitHEADmaster
Diffstat (limited to 'fib.sty')
-rw-r--r--fib.sty68
1 files changed, 68 insertions, 0 deletions
diff --git a/fib.sty b/fib.sty
new file mode 100644
index 0000000..e5465a5
--- /dev/null
+++ b/fib.sty
@@ -0,0 +1,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 \ No newline at end of file