<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div>Hello,</div><div><br></div><div>I’ve written a simple package which permits conditional inclusion of material with more sophisticated logical constraints on what gets included than can easily be generated with \newif conditionals. But it misbehaves in one context, and I was wondering if there was some clever way around it…</div><div><br></div><div>Let me first describe the package (in case anyone is interested), before I mention the misbehaviour.</div><div><br></div><div>The package is available here, in case anyone wants to try it (bug reports appreciated!):</div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre"> </span><a href="https://www.dropbox.com/s/l1vmwlsfui6sbxt/ifkeys.sty">https://www.dropbox.com/s/l1vmwlsfui6sbxt/ifkeys.sty</a></div><div><br></div><div>Here’s how it works… You call a macro called \SetKeys with a comma-separated list of key names (spaces permitted). Those keys are true, all other keys are false.</div><div><br></div><div>Another macro, \ifkeys, is defined, which takes an expression in *disjunctive normal form* as its argument. It then checks whether that expression is satisfied and, if so, evaluates to \iftrue, otherwise \iffalse. The expression uses commas to separate each disjunct, and && to indicate conjunction of key values within each disjunct. And ~ is allowed to specify negation of key values, too. (Since every expression can be written in disjunctive normal form, this allows all logical constraints on keys to be specified, even if at some expense of length.)</div><div><br></div><div>Here’s an example of how it can be used (the number of spaces used in keys doesn’t matter):</div><div><div><br></div><div>\SetKeys{ key one, key two, key three, a really long key name }</div><div><br></div><div>\ifkeys{ key one && key two }</div><div>This is where you put some additional material to be conditionally included exactly when ``key one'' and ``key two'' are both set.</div><div>\fi</div><div><br></div><div>\ifkeys{ key one && ~key three }</div><div>This is where you put some additional material to be conditionally included exactly when ``key one'' is set and ``key three'' is not.</div><div>\else</div><div>You can also use an \verb+\else+ clause to insert material in</div><div>cases where the specified condition is not satisfied.</div><div>\fi</div><div><br></div><div>\ifkeys{a really long key name}</div><div>Keys can have long names with spaces, as well!</div><div>\fi </div><div><br></div><div>\ifkeys{ key one && ~key two, ~key three, ~key four}</div><div>Keys which are not mentioned in \verb+\SetKeys+ are assumed to be false, so this will appear.</div><div>\fi </div></div><div><br></div><div><br></div><div>Ok — now for the problem… The \ifkeys macro cannot be nested with itself or other conditionals, because TeX has a special mechanism for skipping past material at high speeds once it encounters an \iffalse. (It generates the “Extra \fi” error message.) I suspect that there’s no easy / elegant solution for this, but I wanted to ask just in case.</div><div><br></div><div>Many thanks,</div><div><br></div><div>Jason</div><br><div>
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; border-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div>--</div><div>Prof. J. McKenzie Alexander</div><div>Department of Philosophy, Logic and Scientific Method</div><div>London School of Economics</div><div>Houghton Street, London WC2A 2AE</div><div><br></div></div></span><br class="Apple-interchange-newline"></div></span><br class="Apple-interchange-newline"></div><br class="Apple-interchange-newline"><br class="Apple-interchange-newline">
</div>
<br><br clear="both">
Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer<BR>
</body></html>