• No results found

consequently, it can be used to adjust the point size of the document

N/A
N/A
Protected

Academic year: 2021

Share "consequently, it can be used to adjust the point size of the document"

Copied!
3
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

The spdef Package

D. P. Story Released June 28, 2012

1∗package

Description and Usage. This is a short package to create the \ifsmartphone switch. The package is designed to be introduced early in the file, even before

\documentclass. I use \RequirePackage, like so.

\RequirePackage[ph]{spdef}

\documentclass[\ifsmartphone12pt\else10pt\fi]{article}

\usepackage[fleqn]{amsmath}

\usepackage[pdf,myconfigi,nopoints,answerkey]{eqexam}

\ifsmartphone

\usepackage[smartphone,nomaketitle,useforms]{aeb_mobile}

\fi

When you use \usepackage, there is an error which says no class file has been used, but apparently it is file to have \RequirePackage before a class file; consequently, it can be used to adjust the point size of the document.

Version 1.2 of aeb mobile works better with spdef. Now if \ifsmartphone is false, aeb mobile does an early exit; consequently, surrounding it with the construct

\ifsmartphone. . . \fi is no longer needed:

\RequirePackage[ph]{spdef}

\documentclass[\ifsmartphone12pt\else10pt\fi]{article}

\usepackage[fleqn]{amsmath}

\usepackage[pdf,myconfigi,nopoints,answerkey]{eqexam}

\usepackage[smartphone,nomaketitle,useforms]{aeb_mobile}

See Section 2 for more details and additional options.

Another feature of this package is the automatic creation of Boolean switches.

If you say

\RequirePackage[use=myswitch]{spdef}

a new switch \ifmyswitch is created and given a value of true. If you say

\RequirePackage[!use=myswitch]{spdef}

a new switch \ifmyswitch is created and given a value of false. See Section 3 for more details.

Of course, if you do not need to introduce spdef before the class in included, you can use the standard \usepackage command.

1

(2)

1 The Code

We begin by requiring kvoptions, this package does not test the the presence of a class file, so we can use it. It allows us to define key-values as options of the package.

2\RequirePackage{kvoptions}[2009/07/21]

The package is primarily intended for use with the aeb mobile package, for format- ting document for the smartphone, but I’ve since developed other applications of a package that is introduced early, see the definition of the use key.

3\newif\ifsmartphone \smartphonefalse

2 smartphone options

We offer two options ph and pa, additional options for other devices may be defined.

• ph sets the \ifsmartphone switch to true. The name ph stands for phone.

• pa sets the \ifsmartphone switch to false. The name of the option, pa, stands for paper.

ph Option for phone: sets the switch \ifsmartphone to true.

pa Option for paper: sets the switch \ifsmartphone to false.

4\DeclareVoidOption{ph}{\smartphonetrue}

5\DeclareVoidOption{pa}{\smartphonefalse}

It’s easy enough, lets do negatives of the two option above. !ph is the same as pa

!ph

and !pa is the same as ph.

!pa

6\DeclareVoidOption{!ph}{\smartphonefalse}

7\DeclareVoidOption{!pa}{\smartphonetrue}

3 Defining Boolean switches on the fly

Based on my own work, I’ve added in two more options use and !use. Suppose we want to create a switch, say \ifforinstr, we can say,

\usepackage[use=forinstr]{spdef}

The spdef package would create a new Boolean \ifforinstr and assign it a value of true. If you want to compile the document with \ifforinstr having a value of false, we would modify the above options like so,

\usepackage[!use=forinstr]{spdef}

2

(3)

use The use=<switch> is a way to define/use a switch early in the compiling of the document, even before the document class is declared. The code below creates the switch \if<switch>, and sets it to true. The document that uses this switch should have this code in it:

\@ifundefined{if<switch>}{\newif\if<switch>\<switch>false}{}

We can set this switch to true through the spdef package, otherwise, its value is false.

!use Given my last remarks on the use key, as a convenience, we declare the option

!use. It does the same as use; it creates the switch but sets it to false. That way, you can say use=useendnotes and \ifuseendnotes is true, or, by prefixing use with an !, like so, !use=useendnotes, spdef defines/sets \ifuseendnotes to false.

8\define@key{spdef}{use}{\@ifundefined{#1}{%

9 \expandafter\newif\csname if#1\endcsname}{}\csname#1true\endcsname}

10\define@key{spdef}{!use}{\@ifundefined{#1}{%

11 \expandafter\newif\csname if#1\endcsname}{}\csname#1false\endcsname}

If the key is not used, back in the document that uses the switch,

\@ifundefined{if<switch>}{\newif\if<switch>\<switch>false}{}

will set this value to false; in this case, you need to explicitly set the value of the switch yourself.

12\ProcessKeyvalOptions{spdef}

\ifspTRUEFALSE is a convenience command for the \ifsmarphone switch.

\ifsp

It takes two arguments, the first one if the \ifsmartphone is true, the second one if not.

13\def\ifsp@default#1#2{\ifsmartphone

14 \expandafter\def\csname sp@next\endcsname{#1}\else

15 \expandafter\def\csname sp@next\endcsname{#2}\fi\sp@next}

16\def\ifsp@expand#1#2{\ifsmartphone#1\else#2\fi}

17\let\ifsp\ifsp@default

18/package

3

Referenties

GERELATEERDE DOCUMENTEN

In the following three examples notice how I have scaled the total length of the scalebar by roughly the same scale as the font change to maintain a nice aspect ratio.. Make a

Many packages for using alternative math fonts, such as mathpazo (for Palatino), provide the \mathbold alphabet already and can be loaded with an option slantedGreek to make

When textcomp is not used (for instance, because your text fonts are not available with TS1 encoding), the gensymb package tries to emulate the above symbols using what is available

After loading of the package, the comma will be typeset as a punctuation character, if the next input character is a space; otherwise the comma is treated as a decimal separator..

The mu symbol to be used there is to be taken from the text font, and most Latin text fonts do actually include a suitable Greek mu, which can be accessed as \textmu. Most likely

For long section headings to wrap around within the TOC, we need to take the hyperref option linktocpage, unless pdflatex or xelatex are used.. 1.1 Now is the time for all good men

Numbers written in italic refer to the page where the corresponding entry is described; numbers underlined refer to the code line of the definition; numbers in roman refer to the

If you’re used to the glossaries package, note the difference in using \gls: hyper-text markup language (html).. And again (no difference): hyper-text markup language