Debian Codegraph @

texmf-dist/doc/latex/tikzquests/tikzquests.tex

raw
1 %%%==============================================================================
2 % WinEdt pragmas
3 % !Mode:: "TeX:EN"
4 % Default Compile engines:
5 % !TEX program = pdflatex
6 % !PDFTeXify ext = --enable-etex --restrict-write18
7 % !PDFLaTeX ext = --enable-etex --restrict-write18
8 % !BIB program = none
9 %%%==============================================================================
10 %% Copyright 2023 by Alceu Frigeri
11 %%
12 %% This work may be distributed and/or modified under the conditions of
13 %%
14 %% * The [LaTeX Project Public License](http://www.latex-project.org/lppl.txt),
15 %% version 1.3c (or later), and/or
16 %% * The [GNU Affero General Public License](https://www.gnu.org/licenses/agpl-3.0.html),
17 %% version 3 (or later)
18 %%
19 %% This work has the LPPL maintenance status *maintained*.
20 %%
21 %% The Current Maintainer of this work is Alceu Frigeri
22 %%
23 %% This is version {2.2} {2025/11/01}
24 %%
25 %% The list of files that compose this work can be found in the README.md file at
26 %% https://ctan.org/pkg/tikzquests
27 %%
28 %%%==============================================================================
29 \documentclass[10pt]{article}
30 \RequirePackage[verbose,a4paper,marginparwidth=27.5mm,top=2.5cm,bottom=1.5cm,hmargin={40mm,20mm},marginparsep=2.5mm,columnsep=10mm,asymmetric]{geometry}
31 \usepackage[T1]{fontenc}
32 \usepackage[utf8]{inputenc}
33 \usepackage{lmodern}
34 \usepackage[infograb,silence]{codedescribe}
35 \usepackage{tikzquests}
36 \RequirePackage[inline]{enumitem}
37 \SetEnumitemKey{midsep}{parsep=0ex,itemsep=0.4ex}
38
39 \usepackage[american,siunitx,cuteinductors,smartlabels,arrowmos,EFvoltages,betterproportions]{circuitikz}
40 \usetikzlibrary{math}
41
42
43 \setnewcodekey{tikzquests}{letter={},
44 keywd={
45 Question,tikzQuestion,ftikzQuestion,
46 defQuestion,defQuestionAlias,
47 defRepository,SelectRepository,
48 QuestionsList,QuestVal
49 },
50 emph3={tikz},
51 emph2={xtrakeys,xtraidx,no, defs,old, settings,no, alias,in, review, undef, color, local , keys, prefix}
52 }
53
54
55 \RequirePackage[hidelinks,hypertexnames=false]{hyperref}
56 \begin{document}
57 \tstitle{
58 author={Alceu Frigeri\footnote{\tsverb{https://github.com/alceu-frigeri/tikzquests}}},
59 date={\tsdate},
60 title={The tikzquests package\break A parametric questions' repository\break Version \PkgInfo{tikzquests}{version}}
61 }
62
63 \begin{typesetabstract}
64
65 This is a framework for building parametric questions' repositories, which can be further used to construct parametric questions for exams. Unlike other packages (for instance \tsobj[pkg,sep={or}]{exam,exam-n,exam-lite}) this doesn't try to enforce any pre-defined presentation format, focusing only on how to set a repository and use it.
66 \end{typesetabstract}
67
68 \tableofcontents
69
70 \section{Introduction}
71 One recurring problem when typesetting exams, specially in Engineering fields, is the need to have parameterized questions, specially parameterized schematics used in exam's questions. The intent of this is to allow the creation of such repositories (one or more) with `easily' parameterized text and/or graphic (\tsobj[pkg]{tikz}) questions, without enforcing any style/format whatsoever, leaving it to the end user.
72
73 The package offers
74 \begin{itemize}
75 \item A set of commands to create and use repositories,
76 \item A set of commands to create and use `questions' (code snippets) in a repository,
77 \item Question's customization, parametrization, based on \tsobj[pkg]{keys} and a set of associated macros.
78 \end{itemize}
79
80 \section{Package Options}\label{package options}
81 \begin{describelist}{option}
82 \describe{draft}{(default: false). When using a question (see \ref{question use}), the question's associated remarks and annotations will be printed as well, if any.}
83 \describe{in review}{This is an alias to \tsobj[option]{draft}}
84 \describe{local defs}{(default: false). If set, the pre-defined keys will be defined locally (at each command use, those at \ref{question use}), instead of globally (default). This is less prone to name crashing, but comes with a significant performance hit.}
85 \describe{no defs}{(default: false). This changes the parametrization strategy suppressing the creation of ``keys commands''.}
86 \describe{old settings}{(default: false). This changes the assignment behaviour when \tsobj[option]{no defs} is set. See \ref{parameters}}
87 \describe{keys prefix}{This will add a prefix to all variables. It defaults to `nothing' (no prefix).}
88 \describe{keys}{(default: {R,L,C,Z,Y,G,H,X,K,T,Q,D,EQ}) This (re)sets the list of pre-defined \tsobj[pkg]{keys}. See \ref{parameters}.}
89 \describe{source keys}{(default: {V,I}) This (re)sets the list of pre-defined source \tsobj[pkg]{keys} (those with a $_f$). See \ref{parameters}.}
90 \describe{xtrakeys}{This allows to expand the set of pre-defined (\tsobj[pkg]{keys}). See \ref{parameters}.}
91 \describe{idx}{(default: {\{\},a,b}) This (re)sets the list of pre-defined indexes per key. The \{\} corresponds to the single letter idx's (a to z). See \ref{parameters}.}
92 \describe{xtraidx}{This allows to expand the set of pre-defined (\tsobj[pkg]{keys}) indexes per key. See \ref{parameters}.}
93 \describe{no alias}{(default: false). This suppress the creation of Question's aliases (see \ref{question definition}), handy when one wants to reduce the `noise' while listing all currently known Questions.}
94 \describe{undef color}{(default: red). This sets the color used to indicated the use of a non defined parameter. See \ref{parameters}.}
95 \describe{keys info}{(default: false). If set, when setting the pre-defined keys, the effective sets of \tsobj[key]{keys,indexes} are logged as a package info.}
96 \end{describelist}
97 \begin{tsremark}[\color{red}Warning:]
98 When (re)setting keys/idx list, don't forget to insert the list between braces, otherwise the keys/indexes will be interpreted as package options leading to error messages when loading the package.
99 \end{tsremark}
100
101 \section{Repositories}\label{repositories}
102 Questions are stored in repositories. There is a pre-defined one, named \tsobj[option]{default}. Each repository has two sub-sets (a) a non-starred sub-set and (b) a starred sub-set. The rational behind it is to be able to separate the text part (e.g. the question enunciate) from the graphics part. It is suggested (but not enforced) to store the text part in the starred sub-set and the graphics part (\tsobj[pkg]{tikz}) in the non-starred sub-set. A repository can have an ``unlimited'' set of questions.
103 \begin{tsremark}
104 All commands defined in \ref{question use} can use both subsets, except \tsobj{\QuestionsList} which assumes the non-starred sub-set has only text code, whilst the starred sub-set has \tsobj[pkg]{tikz} commands.
105 \end{tsremark}
106
107 \begin{codedescribe}[code,update=2025/10/01]{\defRepository,\SelectRepository}
108 \begin{codesyntax}%
109 \tsmacro{\defRepository*}{new-repository}
110 \tsmacro{\SelectRepository}{repository}
111 \end{codesyntax}
112 \tsobj{\defRepository} creates a new Repository, \tsobj[marg]{new-repository}. The starred version also switches to it, making it the ``current default''.
113 \tsobj{\SelectRepository} activates \tsobj[marg]{repository} as the ``current default'' one.
114
115 It is possible to construct a tree of related repositories by using a slash, ``/'', like ``repoA'', ``repoA/subA'', ``repoA/subB'', ``repoA/subC'', which can be handy when listing the questions of a repository, see \ref{quest list}.
116 \end{codedescribe}
117
118 \begin{tsremark}
119 About repository's names: It can be almost anything, the name can contain strings normally not allowed in a macro name, like spaces, dots, two-dots and so on. an important exception the backslash is still an active character, meaning that if someone typesets \tsobj{\XYZ} as a repository, the value stored in \tsobj{\XYZ} will be used (if \tsobj{\XYZ} isn't defined this might raise a rather cryptic \LaTeXe\ error).
120 \end{tsremark}
121
122 \begin{tsremark}
123 Do not create a repository with an ending slash, like ``repoName/''. Given the way sub-repositories are defined, it will render impossible to list this repository questions, see \ref{quest list}
124 \end{tsremark}
125
126 \begin{tsremark}
127 A warning is raised if the (deprecated) \tsobj{\defNewRepository} is called. Use \tsobj{\defRepository} instead.
128 \end{tsremark}
129
130 \begin{tsremark}
131 When creating a new repository, a warning is raised in case \tsobj[marg]{new-repository} already exists.
132 When Selecting a repository, an error is raised if \tsobj[marg]{repository} doesn't exists.
133 \end{tsremark}
134
135
136 \section{Questions}
137 As said, for each repository there are two sub-sets of questions (code snippets): starred ones, though for text (which may include \LaTeXe\ commands) and non starred ones though for graphics (for instance, to be used inside a \tsobj[pkg]{tikz} environment).
138
139 Since the code re-factoring (version 2.0), the commands \tsobj{\defQuestion, \defQuestionAlias, \Question, \tikzQuestion, \ftikzQuestion} use/refer to the ``non-starred'' sub-set, while the commands \tsobj{\defQuestion*, \defQuestionAlias*, \Question*, \tikzQuestion*, \ftikzQuestion*} use/refer to the ``starred'' sub-set.
140
141 All questions can be parameterized (see \ref{parameters} below) with a set of predefined keys.
142
143 \subsection{Defining a Question}\label{question definition}
144 \begin{codedescribe}{\defQuestion}
145 \begin{codesyntax}%
146 \tsobj{\defQuestion}\tsargs[oarg]{repository}\tsargs[marg]{quest-name,code}\tsargs[oarg]{remarks}
147 \tsobj{\defQuestion*}\tsargs[oarg]{repository}\tsargs[marg]{quest-name,code}\tsargs[oarg]{remarks}
148 \end{codesyntax}
149 \tsobj{\defQuestion} creates a new Question in \tsobj[oarg]{repository} (per default using the ``current active'' one). \tsobj[marg]{quest-name} will be the associated question key, for later reference. \tsobj[marg]{code} will be the corresponding Question's code. \tsobj[oarg]{remarks} is just a small note associated with the Question. It won't be normally used/typeset, except if the \tsobj[option]{in review} option is being used, or when using the command \tsobj{\QuestionsList}.
150
151 The starred version \tsobj{\defQuestion*} will create the question in the ``starred sub-set'', whilst the non starred one \tsobj{\defQuestion} will create the question in the ``non starred sub-set''.
152 \end{codedescribe}
153 \begin{tsremark}
154 Since the code re-factoring (version 2.0) all commands in \ref{question use} can use both sets of questions, with one exception: \tsobj{\QuestionsList} which assumes that the starred set stores text and the non-starred stores \tsobj[pkg]{tikz} graphics.
155 \end{tsremark}
156 \begin{tsremark}
157 About question's names: It can be almost anything, the name can contain strings normally not allowed in a macro name, like spaces, dots, two-dots and so on, including backslashes, meaning that if someone typesets \tsobj{\XYZ} as a question name, \tsobj{\XYZ} will be it's name: a backslash isn't an active character anymore and one can't use macros when defining a question's name.
158 \end{tsremark}
159
160 \begin{tsremark}
161 An error is raised if \tsobj[marg]{repository} doesn't exist. In case the \tsobj[marg]{quest-name} already exists, it's code is silently replaced by the new one.
162 \end{tsremark}
163
164
165 \begin{codedescribe}[code,update={2025/04/25}]{\defQuestionAlias}
166 \begin{codesyntax}%
167 \tsobj{\defQuestionAlias}\tsargs[oarg]{dst-repository}\tsargs[marg]{quest-alias}\tsargs[oarg]{org-repository}\tsargs[marg]{quest-name}
168 \tsobj{\defQuestionAlias*}\tsargs[oarg]{dst-repository}\tsargs[marg]{quest-alias}\tsargs[oarg]{org-repository}\tsargs[marg]{quest-name}
169 \end{codesyntax}
170 \tsobj{\defQuestionAlias} creates an alias, \tsobj[marg]{quest-alias} (at \tsobj[oarg]{dst-repository}), for a given question, \tsobj[marg]{quest-name} (from \tsobj[oarg]{org-repository}). The current active repository is used if none is specified. If only \tsobj[oarg]{dst-repository} is specified, the same repository is used for \tsobj[oarg]{org-repository}. As with \tsobj{\defQuestion}, the ``star'' refers the sub-set being used.
171 \end{codedescribe}
172
173
174 \begin{tsremark}
175 Be aware that this will copy the question definition at the alias creation point.
176 \end{tsremark}
177
178 \begin{tsremark}
179 An error is raised if \tsobj[marg,sep=or]{dst-repository,org-repository,quest-name} doesn't exist.
180 \end{tsremark}
181
182
183 \subsection{Using a Question}\label{question use}
184 \begin{codedescribe}[code,update=2025/10/01]{\Question,\tikzQuestion,\ftikzQuestion}
185 \begin{codesyntax}%
186 \tsobj{\Question}\tsargs[oarg]{repository}\tsargs[marg]{quest-name}\tsargs[oarg]{key=value list}\tsargs[xarg]{annotation}
187 \tsobj{\tikzQuestion}\tsargs[parg]{scale}\tsargs[oarg]{repository}\tsargs[marg]{quest-name}\tsargs[oarg]{key=value list}\tsargs[xarg]{annotation}
188 \tsobj{\ftikzQuestion}\tsargs[parg]{scale}\tsargs[oarg]{repository}\tsargs[marg]{quest-name}\tsargs[oarg]{key=value list}\tsargs[xarg]{annotation}
189 \tsobj{\Question*}\tsargs[oarg]{repository}\tsargs[marg]{quest-name}\tsargs[oarg]{key=value list}\tsargs[xarg]{annotation}
190 \tsobj{\tikzQuestion*}\tsargs[parg]{scale}\tsargs[oarg]{repository}\tsargs[marg]{quest-name}\tsargs[oarg]{key=value list}\tsargs[xarg]{annotation}
191 \tsobj{\ftikzQuestion*}\tsargs[parg]{scale}\tsargs[oarg]{repository}\tsargs[marg]{quest-name}\tsargs[oarg]{key=value list}\tsargs[xarg]{annotation}
192 \end{codesyntax}
193 Those are the main commands to display a question. The star/non-star defines which sub-set will be used.
194 \tsobj{\Question} is the ``raw'' base variant, the question's code will be used, as is, in a local group. The starred version \tsobj{\Question*} is meant for text questions, whilst the non-starred version \tsobj{\Question} is meant for the case one wants to use a different graphic engine (for instance SVG, instead of the \tsobj[pkg]{tikz} as in \tsobj{\tikzQuestion}). Note that this is just a suggestion, and not enforced.
195
196 The \tsobj{\tikzQuestion} will display the question's code inside a \tsobj[env]{tikzpicture} environment. And then, \tsobj{\ftikzQuestion} will further nest the code inside a \tsobj[env]{center} environment (preparing it to be used inside a floating environment).
197
198 The \tsobj[oarg]{annotation} will only be added if, and only if, the \tsobj[option]{in review} option is being used. The \tsobj[parg]{scale} factor, when present, is related to the current \tsobj{\textwidth}, so a factor of 0.25 will scale the width of the question to 1/4th of the text width. The \tsobj[oarg]{key=value list} is a set of \tsobj[pkg]{keys}, see \ref{parameters} below.
199 \end{codedescribe}
200 \begin{tsremark}
201 Besides the key/parameters from \ref{parameters} there is a special key \tsobj[key]{tikz keys} which can be used to pass \tsobj[pkg]{tikz} specific parameters for the underlying environment, this key is ignored when using \tsobj[code,sep=or]{\Question,\Question*}.
202 \end{tsremark}
203 \begin{tsremark}[\color{red}Warning:]
204 A Warning is raised if one uses the old (deprecated) \tsobj[code,sep=or]{\rawtikzQuestion,\textQuestion}. Use \tsobj{\Question} instead.
205 \end{tsremark}
206
207 \begin{tsremark}
208 An error is raised if \tsobj[marg]{repository} or \tsobj[marg]{quest-name} doesn't exist.
209 \end{tsremark}
210
211
212 \begin{codedescribe}[code,new=2025/10/03]{\QuestionsFmtList,\QuestionsList}\label{quest list}
213 \begin{codesyntax}%
214 \tsmacro{\QuestionsFmtList}[repositories list]{star-cmd,nonstar-cmd}
215 \tsmacro{\QuestionsList}[repositories list]{}
216 \end{codesyntax}
217 \tsobj[oarg]{repositories list} is a comma separated list of repositories. For each repository, all Questions will be typeset in a \tsobj[env]{'describe'} alike environment. If no \tsobj[oarg]{repositories list} is supplied, all repositories will be listed.
218
219 \tsobj[marg]{star-cmd} will be used to typeset a ``star'' question, it can be any command that accepts an optional \tsobj[oarg]{repository} name and a mandatory \tsobj[marg]{quest-name}, like \tsmacro{\starcmd}[repository]{quest-name}.
220
221 Likewise \tsobj[marg]{nonstar-cmd} will be used to typeset a ``non star'' question (assuming the same syntax).
222
223 \tsobj{\QuestionsList[repo-list]} is a shortcut for
224
225 \tsobj{\QuestionsFmtList[repo-list]{\Question*}{\tikzQuestion(0.35)}}
226
227 \end{codedescribe}
228
229 \begin{tsremark}
230 If a \tsobj[oarg]{repositories list}'s term finishes with a slash, ``/'', it will be treated as a family of repositories and all sub-repositories will be listed too.
231 \end{tsremark}
232
233 \begin{tsremark}
234 An error is raised if any repository in \tsobj[marg]{repositories list} doesn't exist. To reduce the clutter (and number of questions listed) one should consider the use of the \tsobj[option]{no alias} option.
235 \end{tsremark}
236
237 \section{Parameters as keys and auxiliary macros.}\label{parameters}
238
239 By default the set of \tsobj[pkg]{keys} and macros is defined as follow: \tsobj[oarg]{prefix}\tsobj[marg]{ID}\tsobj[marg]{idx}. Default \tsobj[marg]{prefix} being nothing. The predefined range of \tsobj[marg]{IDs} being \tsobj[key]{R,L,C,Z,Y,G,H,X,K,T,Q,D,EQ,V,I}. The predefined range of \tsobj[marg]{idx} spans from a, b, c up to z, aa, ab, ac up to az and, finally, ba, bb, bc up to bz.
240 \begin{tsremark}
241 That means, one gets to use \tsobj[pkg]{keys} as, for example, Ra=200, Lca=500, Kbe=230 and so on. For each of the key's \tsobj[marg]{ID} there is (per default) a set of 3x26 keys. If one adds some 3 other \tsobj[marg]{idx} then one gets 6x26 keys per \tsobj[marg]{ID}.
242 \end{tsremark}
243 \begin{tsremark}
244 The \tsobj[marg]{ID}s can be extended with the \tsobj[option]{xtrakeys} option. For example with \tsverb[option]{xtrakeys={NN,B}}, each extra \tsobj[marg]{ID} will add 3x26 keys (per default).
245 \end{tsremark}
246 \begin{tsremark}
247 The \tsobj[marg]{idx}s can be extended with the \tsobj[option]{xtraidx} option. For instance with \tsverb[option]{xtraidx={f,g}} one gets fa, fb, fc up to fz, ga, gb, gc up to gz as well, a x26 set per extra idx.
248 \end{tsremark}
249
250 Unless the \tsobj[option]{no defs} option is used, a corresponding macro (with the same name) will also be defined. For example, there is a macro \tsobj{\Ra} associated with the key \tsobj[key]{Ra}.
251 All those macros/keys are initialized as follow (math mode) \tsobj{\ensuremath{<prefix><ID>_{<idx>}}}, resulting in $prefixID_{idx}$. So, for example, the key \tsobj[key]{Rab}, which can be accessed with the macro \tsobj{\Rab}, will be predefined as $R_{ab}$, \tsobj[key]{Lca} (\tsobj{\Lca}) will be predefined as $L_{ca}$, and so on.
252 \begin{tsremark}[\color{red}Note:]
253 If \tsobj[option]{keys prefix} (see \ref{package options}) is set, all \emph{pre-defined} keys will have that prefix, but only then. For instance, if one set's \tsobj[option]{keys prefix = kp} (when loading this package), the same example above would be, key \tsobj[key]{kpRab}, macro \tsobj{\kpRab}, default value $kpR_{ab}$, and so on.
254 \end{tsremark}
255
256 The idea is that, when using the commands in \ref{question use}, if one doesn't specify a \tsobj[oarg]{key=value list}, the default values will be en force, and all one has to do (to change those values) is to set said list, which doesn't have to be complete, non assigned keys will keep their default value.
257
258 Besides those default keys, one can set and use any key at will (in \tsobj[oarg]{key=value list}) non-existing keys will be created ``on the fly'' with the given name as the default value.
259
260 \subsection{Assigning a value to pre-defined keys}
261 In fact, with each and every predefined key there are 3 ways to assign a value to it \tsobj[oarg]{key}\,=\tsobj[value]{value}, \tsobj[oarg]{key*}\,=\tsobj[value]{value} and \tsobj[oarg]{key raw}\,=\tsobj[value]{value}. The difference being that \tsobj[oarg]{key raw} will assign whatever code/value to the key (and associated macro), \tsobj[oarg]{key*} will assign the code/value inside a math environment.
262 \begin{tsremark}[\color{red}warning:]
263 \tsobj[oarg]{key}\,=\tsobj[value]{value} (without any specifier) will be the same as \tsobj[oarg]{key*} (default). But, if the options \tsobj[option]{no defs,old settings} are used, it will be equivalent to \tsobj[oarg]{key raw}.
264 \end{tsremark}
265
266 \subsection{Assigning a value to new keys}
267 When using \tsobj[oarg]{key}\,=\tsobj[value]{value}, if the \tsobj[oarg]{key} isn't one of the pre-defined ones, then \tsobj[value]{value} will be assigned ``as is'' to \tsobj[oarg]{key}.
268 \begin{tsremark}[\color{red}warning:]
269 Note that, in this case there are no \tsobj[oarg,sep=or]{key*,key raw} equivalents.
270 \end{tsremark}
271
272 \subsection{Using a parameter key}
273 When defining the \tsobj[marg]{code} of a question (see \ref{question definition}) one has two options to recover a key's value:
274 \begin{itemize}
275 \item A macro named after the key itself (in case of the default keys, see above) and, or
276 \item the \tsobj{\QuestVal} command which allows to recover the value of both the default keys, as well as the ones defined on the fly.
277 \end{itemize}
278 \begin{tsremark}[\color{red}Warning:]
279 If the option \tsobj[option]{no defs} is used, the only option to recover a key's value is \tsobj{\QuestVal}. Users are advised to choose a style, and keep it (when starting new docs).
280 \end{tsremark}
281
282
283 \begin{codedescribe}[code,EXP]{\QuestVal}
284 \begin{codesyntax}%
285 \tsmacro{\QuestVal}{prefixIDidx}
286 \tsmacro{\QuestVal}{key}
287 \end{codesyntax}
288 This will always recover the value of a key, regardless if the key is one of the pre-defined ones (in the form \tsobj[marg]{IDidx} or an ``on the fly'' new one, \tsobj[marg]{key}.
289 If the key didn't get (re)defined with the \tsobj[oarg]{key=value list}, it will return the key/parameter default value. In the case of a ``on the fly'' key, it will be the key's name in red (or the color set up with the \tsobj[option]{undef color} option, see \ref{package options}).
290
291 \end{codedescribe}
292 \begin{tsremark}
293 If \tsobj[option]{keys prefix} (see \ref{package options}) is set, all \emph{pre-defined} keys will have that prefix, it's part of their name.
294 \end{tsremark}
295
296 \begin{tsremark}
297 \tsobj{\QuestVal} is fully expandable, if the key's code also is.
298 \end{tsremark}
299
300 \section{Examples of Use}
301
302
303
304 \subsection{Package Options}
305 \begin{codestore}[pack.options A]
306 \usepackage{tikzquests}
307 \end{codestore}
308
309 \tscode*[tikzquests,codeprefix={Package Options}]{pack.options A}
310 This is the default case, in which both \tsobj{\QuestVal} and (for default keys) associated macro name can be used to retrieve a key/parameter value, and no prefix will be added to any key.
311
312 \begin{codestore}[pack.options B]
313 \usepackage[xtrakeys={EX,N},xtraidx={f,h},undef color={blue},no defs]{tikzquests}
314 \end{codestore}
315
316 \tscode*[tikzquests,codeprefix={Package Options}]{pack.options B}
317
318 In this case, one will get the following set of keys
319
320 \begin{itemize}[midsep]
321 \item Ra, Rb ... Rz, Raa, Rab ... Raz .... \emph{Rfa, Rfb ... Rfz, Rha, Rhb ... Rhz}
322 \item .... all other default sets of keys, plus
323 \item EXa, EXb ... EXz, EXaa, EXab ... EXaz .... \emph{EXfa, EXfb ... EXfz, EXha, EXhb ... EXhz}
324 \item Na, Nb ... Nz, Nab, Naa ... Naz .... \emph{Nfa, Nfb ... Nfz, Nha, Nhb ... Nhz}
325 \end{itemize}
326
327 Besides that, the undefined color will be blue and no additional macro will be defined, meaning that \tsobj{\QuestVal} is the only option to retrieve the value of a key/parameter.\\[5mm]
328
329
330 \begin{codestore}[pack.options D]
331 \usepackage[xtrakeys={EX,N},keys prefix = {pr}]{tikzquests}
332 \end{codestore}
333
334 \tscode*[tikzquests,codeprefix={Package Options}]{pack.options D}
335
336 In this case, one will get the following set of keys
337
338 \begin{itemize}[midsep]
339 \item prRa, prRb ... prRz, prRaa, prRab ... prRaz ....
340 \item .... all other default sets of keys, plus
341 \item prEXa, prEXb ... prEXz, prEXaa, prEXab ... prEXaz ....
342 \item prNa, prNb ... prNz, prNaa, prNab ... prNaz ....
343 \end{itemize}
344
345 Note the prefix `pr' in all keys.\\[5mm]
346
347
348
349 \begin{codestore}[pack.options E]
350 \usepackage[keys={R,L,C},idx={{},a},keys prefix = {pr},local defs]{tikzquests}
351 \end{codestore}
352
353 \tscode*[tikzquests,codeprefix={Package Options}]{pack.options E}
354
355 In this case, one will only get the following set of keys
356
357 \begin{itemize}[midsep]
358 \item prRa, prRb ... prRz, prRaa, prRab ... prRaz
359 \item prLa, prLb ... prLz, prLaa, prLab ... prLaz
360 \item prCa, prCb ... prCz, prCaa, prCab ... prCaz
361 \end{itemize}
362
363 Note that, these keys will be defined only locally, when using \tsobj[code,or]{\Question,\tikzQuestion,\ftikzQuestion}.\\[5mm]
364
365
366 \begin{codestore}[pack.options C]
367 \usepackage[no alias, in review]{tikzquests}
368 \end{codestore}
369
370 \tscode*[tikzquests,codeprefix={Package Options}]{pack.options C}
371 In this case, no alias will be defined (the command \tsobj{\defQuestionAlias} will be ignored), and when using \tsobj{\tikzQuestion} (and similar) the question's remarks (defined by \tsobj{\defQuestion}) and annotations (from \tsobj{\tikzQuestion}) will be printed. The \tsobj[option]{no alias} is specially useful when using the commands \tsobj[code,or]{\QuestionsFmtList,\QuestionsList}.
372
373 \subsection{A More Complete Example}
374 In the following code, an extra repository will be set (besides the default one) and two questions (a starred, text, and non starred, graphics) will be defined for each repository.
375
376 \begin{codestore}[DefQuestion]
377 % A repository name can be just about anything.
378 % the star makes sure 'Repo 2' is now the active/default one.
379 \defRepository*{Repo 2}
380
381 % quest names are even more flexible than a repository one
382 % the star implies this is a text one.
383 \defQuestion*{Quest A:1}{
384 In the following circuit, assuming $\beta \approx \QuestVal{Beta}$ and that $V_{be} \approx 0.65V$, find the value of $R_c$ such that the small signal gain is \QuestVal{Gain}.
385 }[That would be a question enunciate.]
386
387 %% Note the use of the macros \Ra, \Rb, \Rc, \Rd, \Vi, \Vbc and \Vo
388 \defQuestion[Repo 2]{Elect. 1a}{
389 \draw
390 (0,0) coordinate(A) to[V,invert,l=\Vi] ++(0,3) coordinate(V)
391 to[R=\Ra] ++(2,0)
392 to[C] ++(2,0) coordinate(B)
393 -- ++(1,0) node[npn,anchor=B] (T1){}
394 (A) -- (A -| B) coordinate(Ba) to[R=\Rb] (B) to[R=\Rg] ++(0,3) coordinate(C)
395 (B) node[circ]{}
396 (T1.E) to[R,l=\Rc] (T1.E |- A) -- (A)
397 (T1.C) to[R,l_=\Rd] (T1.C |- C) -- (C -| A) -- ++(-2,0) coordinate(X) to[V,l=\Vbc] (X |- A) -- (A)
398 (T1.C) -- ++(1.5,0) node[ocirc]{} coordinate(k) to[open,v=\Vo] (k |- A) node[ocirc]{} -- (A)
399 ;
400 }[this is a CircuiTikZ example]
401
402 %switching repositories
403 \SelectRepository{default}
404
405 % Note that, since this is a different repository, there is no name crashing.
406 \defQuestion*{Quest A:1}{
407 In the following circuit, assuming $\beta \approx \QuestVal{Beta}$ and that $V_{be} \approx 0.65V$, find the value of \Rg \ such that the DC level of \Vo \ is equal to \QuestVal{DC level}.
408 }[Just for the sake of it.]
409
410 %% Note the use of the macros \Ra, \Rb, \Rc, \Rd, \Vi, \Vbc and \Vo
411 \defQuestion{Elect. 1b}{
412 \draw
413 (0,0) coordinate(A) to[V,invert,l=\Vi] ++(0,3) coordinate(V)
414 to[R=\Ra] ++(2,0)
415 to[C] ++(2,0) coordinate(B)
416 -- ++(1,0) node[pnp,anchor=B] (T1){}
417 (A) -- (A -| B) coordinate(Ba) to[R=\Rb] (B) to[R=\Rg] ++(0,3) coordinate(C)
418 (B) node[circ]{}
419 (T1.C) to[R,l=\Rc] (T1.C |- A) -- (A)
420 (T1.E) to[R,l_=\Rd] (T1.E |- C) -- (C -| A) -- ++(-2,0) coordinate(X) to[V,l=\Vbc] (X |- A) -- (A)
421 (T1.C) -- ++(1.5,0) node[ocirc]{} coordinate(k) to[open,v=\Vo] (k |- A) node[ocirc]{} -- (A)
422 ;
423 }[this is a CircuiTikZ example]
424 \end{codestore}
425
426 \tscode*[tikzquests,codeprefix={Defining Questions},resultprefix={Result: \emph{no output}},emph={Ra,Rb,Rc,Rd,Rg,Vi,Vbc,Vo,Beta,Gain,raw,DC,level}]{DefQuestion}
427
428 \tsexec{DefQuestion}
429
430
431 Once Questions are defined one can use them, for instance, using just the default parameter's values.
432
433 \begin{codestore}[QuestionDefault]
434 Choose one of the following two questions:
435
436 \begin{enumerate}
437 \item \Question*[Repo 2]{Quest A:1}<just a last minute note about this>\par
438 \ftikzQuestion(0.35)[Repo 2]{Elect. 1a}
439
440 \item \Question*[default]{Quest A:1}<just for the sake of it...>\par
441 \ftikzQuestion(0.35)[default]{Elect. 1b}
442 \end{enumerate}
443 \end{codestore}
444
445 \tscode*[tikzquests, codeprefix={Questions Defaults},resultprefix={}, emph={Ra,Rb,Rc,Rd,Rg,Vi,Vbc,Vo,Beta,Gain,raw,DC,level}]{QuestionDefault}
446
447
448 \hrule\relax\vspace{0.5ex}
449
450
451 %\tikzQuestion(0.35)[Repo 2]{Elect. 1a}
452
453 %\ExplSyntaxOn
454 %\cs_show:N \exp_last_unbraced:Nno
455 %\ExplSyntaxOff
456
457
458 \tsexec{QuestionDefault}
459
460
461
462 Finally, one can use these same questions, setting it's parameters:
463
464 \begin{codestore}[QuestionUse]
465 Choose one of the following two questions:
466
467 \begin{enumerate}
468 \item \Question*[Repo 2]{Quest A:1}[Beta=200,Gain=4,Ra=50\Omega]<just a last minute note about this>\par
469 \ftikzQuestion(0.35)[Repo 2]{Elect. 1a}[Ra=50\Omega,Rb*=100\Omega,Rg raw=$100\Omega$,Rc=100\Omega,Rd=R_c,Vbc=18V,Vi=v_i(t),Vo=v_o(t),tikz keys={thick,red}] %%Note the use of the 'tikz keys' key...
470
471 \item \Question*[default]{Quest A:1}[Beta=200,DC level=8V,Rg=R_{b1},Vo=v_o(t)]<just for the sake of it...>\par
472 \ftikzQuestion(0.35)[default]{Elect. 1b}[Ra=50\Omega,Rb*=100\Omega,Rg=R_{b1},Rc=100\Omega,Rd=200\Omega,Vbc=18V,Vi=v_i(t),Vo=v_o(t)]
473 \end{enumerate}
474 \end{codestore}
475
476 \tscode*[tikzquests, codeprefix={Questions Using Parameters},resultprefix={Result: \emph{no output}},emph={Ra,Rb,Rc,Rd,Rg,Vi,Vbc,Vo,Beta,Gain,raw,DC,level}]{QuestionUse}
477
478 \hrule\relax\vspace{0.5ex}
479
480 \tsexec{QuestionUse}
481
482 \subsection{Listing all Questions}
483 To round it up, using the \tsobj{\QuestionsList} (see \ref{question use}):
484 \begin{codestore}[Qlist]
485 \QuestionsList
486 \end{codestore}
487
488 \tscode*[tikzquests]{Qlist}
489
490 One gets:
491
492 \tsexec{Qlist}
493
494
495 \end{document}