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 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459
|
% ======================================================================
% scrbase.tex
% Copyright (c) Markus Kohm, 2002-2013
%
% This file is part of the LaTeX2e KOMA-Script bundle.
%
% This work may be distributed and/or modified under the conditions of
% the LaTeX Project Public License, version 1.3c of the license.
% The latest version of this license is in
% http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later and of this work.
%
% This work has the LPPL maintenance status "author-maintained".
%
% The Current Maintainer and author of this work is Markus Kohm.
%
% This work consists of all files listed in manifest.txt.
% ----------------------------------------------------------------------
% scrbase.tex
% Copyright (c) Markus Kohm, 2002-2013
%
% Dieses Werk darf nach den Bedingungen der LaTeX Project Public Lizenz,
% Version 1.3c, verteilt und/oder veraendert werden.
% Die neuste Version dieser Lizenz ist
% http://www.latex-project.org/lppl.txt
% und Version 1.3c ist Teil aller Verteilungen von LaTeX
% Version 2005/12/01 oder spaeter und dieses Werks.
%
% Dieses Werk hat den LPPL-Verwaltungs-Status "author-maintained"
% (allein durch den Autor verwaltet).
%
% Der Aktuelle Verwalter und Autor dieses Werkes ist Markus Kohm.
%
% Dieses Werk besteht aus den in manifest.txt aufgefuehrten Dateien.
% ======================================================================
%
% Package scrbase for Package and Class Authors
% Maintained by Markus Kohm
%
% ----------------------------------------------------------------------
%
% Paket scrbase fuer Paket- und Klassenautoren
% Verwaltet von Markus Kohm
%
% ======================================================================
\KOMAProvidesFile{scrbase.tex}
[$Date: 2013-12-13 16:32:18 +0100 (Fr, 13 Dez 2013) $
KOMA-Script package scrbase]
\translator{Markus Kohm\and Melvin Hendrix}
% Date of the translated German file: 2013/11/06
\chapter{Basic Functions of Package \Package{scrbase}}
\labelbase{scrbase}
\BeginIndex{Package}{scrbase}%
The package \Package{scrbase} provides basic features designed and implemented
for use by authors of packages and classes. However, \Package{scrbase} cannot
only by used for wrapper classes related to \KOMAScript{} class. Authors of
classes that have nothing to do with \KOMAScript{} can benefit from
\Package{scrbase} functionality.
\section{Loading the Package}
\label{sec:scrbase.loadit}
Whereas users load packages using \Macro{usepackage}, authors of packages or
classes should use \Macro{RequirePackage}\IndexCmd{RequirePackage}. Authors of
wrapper packages may also use \Macro{RequirePackageWithOptions}. Command
\Macro{RequirePackage} has the same optional argument for package options like
\Macro{usepackage}. In contrast, \Macro{RequirePackageWithOptions} does not
have an optional argument but passes all options given when loading the
wrapper package to the required package. See \cite{latex:clsguide} for more
information about these commands.
The package \Package{scrbase} needs the functionality of package
\Package{keyval}\IndexPackage{keyval} internally. This may be provided by
package \Package{xkeyval} alternatively. Package \Package{scrbase} loads
\Package{keyval} as needed.
The package \Package{keyval} provides definition of keys and assignment of
values to these keys. The options provided by \Package{scrbase} also use
\Package{keyval} syntax: \PName{key}\texttt{=}\PName{value}.
\begin{Declaration}
\KOption{internalonly}\PName{value}
\end{Declaration}
\BeginIndex{Option}{internalonly~=\PName{value}}%
Package \Package{scrbase} provides some commands for conditional
execution. The primary names for these are builds like
\Macro{scr@\PName{name}}, which are internal commands. \KOMAScript{} only uses
these internal commands internally. Authors of packages and classes may use
these internal commands, too, but should not redefine them. Because some of
these commands are useful for users, too, they are provided as
\Macro{\PName{name}} normally. But eventually, other packages may provide
commands with the same name but different syntax or different
functionality. As this would result in an conflict, \Package{scrbase} can
suppress the definition of the user commands \Macro{\PName{name}}. Using
option \Option{internalonly} without \PName{value} will define only the
internal commands and suppress definition of all the user commands for
conditional execution. Alternatively, the user may give all the commands that
should not be defined as \PName{value}, but replaces ``\Macro{}'' by
``\texttt{/}''.
Authors of packages and classes normally should not use this option. Users may
use it with or without \PName{value} either as a global option with
\Macro{documentclass} or using \Macro{PassOptionsToPackage}.
\begin{Example}
The user does not want \Package{scrbase} to define commands \Macro{ifVTeX}
and \Macro{ifundefinedorrelax}. Because of this, to load the class, the user
writes:
\begin{lstcode}
\documentclass%
[internalonly=/ifVTeX/ifundefinedorrelax]%
{foo}
\end{lstcode}
Class name \Class{foo} is, therefore, an placeholder
for any class in this example. The meanings of commands \Macro{ifVTeX} and
\Macro{ifundefinedorrelax} and many more commands for conditional execution
is located in \autoref{sec:scrbase.if}.
\end{Example}
%
\EndIndex{Option}{internalonly~=\PName{value}}%
\section{Keys as Attributes of Families and their Members}
\label{sec:scrbase.keyvalue}
As already mentioned in \autoref{sec:scrbase.loadit}, \Package{scrbase} uses
package \Package{keyval} for keys and values of keys. Nevertheless
\Package{scrbase} extends the functionality of \Package{keyval}. Whereas only
one family owns all keys of \Package{keyval}, \Package{scrbase} recognises
also family members. Therefore, a key may be owned by a family or by one or
more family members. Additionally, a value may be assigned to the key of a
family member, to the key of a family, or to the keys of all family members.
\begin{Declaration}
\Macro{DefineFamily}\Parameter{family}\\
\Macro{DefineFamilyMember}\OParameter{family member}\Parameter{family}%
\end{Declaration}
\BeginIndex{Cmd}{DefineFamily}%
\BeginIndex{Cmd}{DefineFamilyMember}%
\Package{scrbase} needs to know the members of a family for different
reasons. First, you have to define a new family using
\Macro{DefineFamily}, which produces an empty member list. If the family
has already been defined nothing would happen. Nothing also means that an
already existing member list would not be overwritten.
Next, a new member can be added to the family using
\Macro{DefineFamilyMember}. If the family does not exist, this would result in
an error message. If the member already exists, nothing happens. If the
optional \PName{family member} is omitted, the default value
``\texttt{.}\Macro{@currname}\texttt{.}\Macro{@currext}'' is used. During
class or package loading \Macro{@currname} and \Macro{@currext} together
represent the file name of the class or package.
Theoretically, it is possible, to define a member without a name using an
empty optional \PName{family member} argument. But this is the same as the
family itself. It is recommended that only letters and digits be used for
\PName{family} and the first character of \PName{family member} should not be
a letter or digit. Otherwise, it could happen that members of one family are
the same as members of another family.
\Package{scrbase} assigns family ``\PValue{KOMA}'' to itself and adds member
``\PValue{.scrbase.sty}'' to it. Family ``\PValue{KOMA}'' is reserved to
\KOMAScript{}. For your own packages, use the name of the bundle as
\PName{family} and the name of the package as \PName{family member} of that
\PName{family}.
%
\begin{Example}
Assume you are writing a bundle called ``master butcher''. Within that
bundle you have packages \File{salami.sty}, \File{liversausage.sty}, and
\File{kielbasa.sty}. Therefore, you decide to use family name
``\PValue{butcher}'' and,to each of the package file, you add the lines
\begin{lstcode}
\DefineFamily{butcher}
\DefineFamilyMember{butcher}
\end{lstcode}
When loading the three packages, this will
add the members ``\PValue{.salami.sty}'', ``\PValue{.liversausage.sty}'',
and ``\PValue{.kielbasa.sty}'' to the family ``\PValue{butcher}''. After
loading all three packages, all three member will be defined.
\end{Example}
%
\EndIndex{Cmd}{DefineFamilyMember}%
\EndIndex{Cmd}{DefineFamily}%
\begin{Declaration}
\Macro{DefineFamilyKey}\OParameter{family member}\Parameter{family}%
\Parameter{key}\OParameter{default}\\
\hphantom{\Macro{DefineFamilyKey}}\Parameter{action}\\
\Macro{FamilyKeyState}\\
\Macro{FamilyKeyStateUnknown}\\
\Macro{FamilyKeyStateProcessed}\\
\Macro{FamilyKeyStateUnknownValue}\\
\Macro{FamilyKeyStateNeedValue}
\end{Declaration}
\BeginIndex{Cmd}{DefineFamilyKey}%
\BeginIndex{Cmd}{FamilyKeyState}%
\BeginIndex{Cmd}{FamilyKeyStateUnknown}%
\BeginIndex{Cmd}{FamilyKeyStateProcessed}%
\BeginIndex{Cmd}{FamilyKeyStateUnknownValue}%
\BeginIndex{Cmd}{FamilyKeyStateNeedValue}%
The command \Macro{DefineFamilyKey} defines a \PName{key}. If a \PName{family
member} is given, the \PName{key} becomes an attribute of that member in the
given \PName{family}. If a \PName{family member} is not given, the member
``\texttt{.}\Macro{@currname}\texttt{.}\Macro{@currext}'' is assumed. If,
later, a value is assigned to the \PName{key}, the \PName{action} will be
executed and the value made an argument of \PName{action}. So inside
\PName{action} ``\lstinline{#1}'' would be that value. If the value is
omitted, the \PName{default} is used instead. If there is no \PName{default},
the \PName{key} can be used only with a value being defined.
\begin{Explain}
\phantomsection\label{explain:scrbase.macro.DefineFamilyKey}%
At least
\begin{lstcode}[escapeinside=`']
\DefineFamilyKey[`\PName{member}']{`\PName{family}'}{`\PName{key}'}
[`\PName{default}']{`\PName{action}'}
\end{lstcode}
will result in a call of
\begin{lstcode}[moretexcs={define@key},escapeinside=`']
\define@key{`\PName{family\,member}'}{`\PName{key}'}
[`\PName{default}']{`\PName{extended action}'}
\end{lstcode}
with \Macro{define@key} provided by package
\Package{keyval}\IndexPackage{keyval} (see \cite{package:keyval}). However,
the call of \Macro{define@key} and the \PName{action} is, in fact,
extended by additional arrangements.
\end{Explain}
Success\ChangedAt{v3.12}{\Package{scrbase}} or failure of the execution of the
\PName{action} should be reported back to \Package{scrbase} by
\Macro{FamilyKeyState}. The package itself will take care of additional
procedures if needed. You should not report errors by yourself! The default
state before execution of \PName{action} is
\Macro{FamilyKeyStateUnknown}. This signals that it is not known whether or
not the execution is successful. If this state does not change until end of
execution of the \PName{action}, \Package{scrbase} will write a message into
the \File{log} file and assumes state \Macro{FamilyKeyStateProcessed} during
the further procedure.
State \Macro{FamilyKeyStateProcessed} signals that the option and the value
assignment to the option are completely and successfully finished. You may
switch to this state by using \Macro{FamilyKeyStateProcessed} itself.
State \Macro{FamilyKeyStateUnknownValue} indicates that the option was
handled, but the value, that should be assigned to the key, was unknown or not
allowed. You should use \Macro{FamilyKeyStateUnknownValue} to switch to
this state.
State \Macro{FamilyKeyStateNeedValue} signals that the option could not be
set because it needs a value, but no value was assigned to the
key. This state is used automatically, whenever an option has been
defined without \PName{default} value and is used without value
assignment. You should not set the state using \Macro{FamilyKeyStateNeedValue}
yourself.
Last but not least you may switch to additional failure states, simply
re-defining \Macro{FamilyKeyState} with a very short text message.
Generally, the four predefined states should be sufficient.
\begin{Example}
Assume each of the three packages from the previous example should get a
key named \PValue{coldcuts}. When used, a switch is set at each of
the packages. For package \Package{salami} this may be:
\begin{lstcode}
\newif\if@Salami@Aufschnitt
\DefineFamilyKey{butcher}%
{coldcut}[true]{%
\expandafter\let\expandafter\if@salami@coldcut
\csname if#1\endcsname
\FamilyKeyStateProcessed
}
\end{lstcode}
Available values for the key are \PValue{true} or \PValue{false} in this
case. Instead of testing on inappropriate values, success will be signalled
for any case in this example. If the key is used later, it is executed with
one of the allowed values or without assignment. In the second case, the
default \PName{true} will be used.
The definitions in the other packages are similar. Only ``\texttt{salami}''
has to be replaced by the corresponding names.
\end{Example}
%
\EndIndex{Cmd}{FamilyKeyStateNeedValue}%
\EndIndex{Cmd}{FamilyKeyStateUnknownValue}%
\EndIndex{Cmd}{FamilyKeyStateProcessed}%
\EndIndex{Cmd}{FamilyKeyStateUnknown}%
\EndIndex{Cmd}{FamilyKeyState}%
\EndIndex{Cmd}{DefineFamilyKey}%
\begin{Declaration}
\Macro{FamilyProcessOptions}\OParameter{family member}\Parameter{family}
\end{Declaration}
\BeginIndex{Cmd}{FamilyProcessOptions}%
Generally the extension of keys of families to keys of families and family
members, as mentioned earlier, uses keys or key-value settings as class or
package options. The command \Macro{FamilyProcessOptions} is an extension of
\Macro{ProcessOption*} from \LaTeX{} kernel (see \cite{latex:clsguide}, which
processes not only options that has been declared using \Macro{DeclareOption},
it processes all keys of the given family member. If the optional argument
\PName{family member} is omitted, family member
``\texttt{.}\Macro{@currname}\texttt{.}\Macro{@currext}'' is used.
Somehow special are keys that are not attached to a family member, but to a
family. These are keys with an empty family member. Such keys are set before
the keys of the family members.
\begin{Example}
If a package in the previous example would be extended by the line
\begin{lstcode}
\FamilyProcessOptions{butcher}
\end{lstcode}
then the user may select the option \Option{coldcut} when loading the
package. If the option is used globally, this means at the optional
argument of \Macro{documentclass}, then the option would be passed
automatically to all three packages, if all three packages are loaded
later.
\end{Example}
Please note\textnote{Attention!} that packages always process global options
before local options. When processing unknown options initiate an entry in the
\File{log}-file and the option is otherwise ignored. By contrast, unknown
options assigned to the package locally leads to an error message.
\Macro{FamilyProcessOptions} may be interpreted either as an extension of
\Macro{ProcessOption*} or as an extension of the \PName{key=value} mechanism
of \Package{keyval}. Ultimately, with the help of
\Macro{FamilyProcessOptions}, \PName{key=value} pairs become options.%
%
\EndIndex{Cmd}{FamilyProcessOptions}%
\begin{Declaration}
\Macro{FamilyExecuteOptions}\OParameter{family member}\Parameter{family}%
\Parameter{options list}
\end{Declaration}
\BeginIndex{Cmd}{FamilyExecuteOptions}%
This command is an extension of \Macro{ExecuteOptions} from the \LaTeX{}
kernel (see \cite{latex:clsguide}). The command processes not only options
that are defined using \Macro{DeclareOption}, but also processes all keys of
the given \PName{family member}. If the optional argument \Macro{family
member} is omitted, then
``\texttt{.}\Macro{@currname}\texttt{.}\Macro{@currext}'' is used.
Somehow special are keys of empty family members, which are not attached to a
family member, but to a family. Such keys are set before the keys of family
members.
\begin{Example}
Assume option \Option{coldcut} should be set by default in the
previous example. In this case only line
\begin{lstcode}
\FamilyExecuteOptions{butcher}{coldcut}
\end{lstcode}
has to be added.
\end{Example}
%
\EndIndex{Cmd}{FamilyExecuteOptions}%
\begin{Declaration}
\Macro{FamilyOptions}\Parameter{family}\Parameter{options list}%
\end{Declaration}
\BeginIndex{Cmd}{FamilyOptions}%
Hence \PName{options list} is like:
\begin{flushleft}\vskip\dp\strutbox\begin{tabular}{l}
\PName{key}\texttt{=}\PName{value}\texttt{,}%
\PName{key}\texttt{=}\PName{value}\dots
\end{tabular}\vskip\dp\strutbox\end{flushleft}
after which the value assignment may be omitted for \PName{key}s that have a
defined default.
In contrast to average options that are defined using \Macro{DeclareOption},
the \PName{key}s also may be set after loading a class or package. For this,
the user calls \Macro{FamilyOptions}. Thereafter, the \PName{key}s of all
members of the specified family are set. If a \PName{key} also exists as a
family attribute, then the family key is set first. After this, the member
keys follow in the order in which the members have been defined. If a given
\PName{key} does not exist, either for the family or for any member of the
family, then \Macro{FamilyOptions} will result in an error. Package
\Package{scrbase} reports an error also if there are members with key
\PName{key}, but all those members signal failure via \Macro{FamilyKeyState}.
\begin{Example}
You extend your butcher project by a package \Package{sausagesalad}. If this
package has been loaded, all sausage package should generate cold cut:
\begin{lstcode}
\ProvidesPackage{sausagesalad}%
[2008/05/06 nonsense package]
\DefineFamily{butcher}
\DefineFamilyMember{butcher}
\FamilyProcessOptions{butcher}\relax
\FamilyOptions{butcher}{coldcut}
\end{lstcode}
If currently none of the sausage packages are loaded, then an error
message results because of undefined option ``\Option{coldcut}''. This is
avoided by changing the last line of the code to:
\begin{lstcode}[moretexcs={Family@Options}]
\Family@Options{butcher}{coldcut}{}
\end{lstcode}
Despite this, sausage packages loaded after
\Package{sausagesalad} still do not produce cold cut. This may be corrected
by editing the last line of the code again to:
\begin{lstcode}[moretexcs={Family@Options}]
\AtBeginDocument{%
\Family@Options{butcher}{coldcut}{%
\PackageWarning{sausagesalad}{%
sausage salad needs at least
one sausage package}%
}%
}%
\end{lstcode}
This may throw a warning message if none of the sausage packages are loaded.
\end{Example}
%
\EndIndex{Cmd}{FamilyOptions}%
\begin{Declaration}
\Macro{FamilyOption}\Parameter{family}%
\Parameter{option}\Parameter{values list}%
\end{Declaration}
\BeginIndex{Cmd}{FamilyOption}%
Besides options that have concurrently excluding values, there may be options
that produce several values at the same time. Using \Macro{FamilyOptions} for
that type of option would result in using the same option several times with
different value assignments. Instead of this, \Macro{FamilyOption} may be used
to assign a whole \PName{values list} to the same \PName{option}. The
\PName{values list} is a comma separated list of values, also known as
\emph{csv}:
\begin{flushleft}\begin{tabular}{l}
\PName{value}\texttt{,}\PName{value}\dots
\end{tabular}\end{flushleft}
By the way, please note that usage of a comma inside a value may be done only
if the value is put inside braces. The general functionality of this command
is the same as that of the previous command \Macro{FamilyOptions}.
\begin{Example}
Package \Package{sausagesalad} should have one mire option, to add
additional ingredients. Each of the ingredients sets a switch as was done
previously for the cold cut.
\begin{lstcode}
\newif\if@saladwith@onions
\newif\if@saladwith@gherkins
\newif\if@saladwith@chillies
\DefineFamilyKey{butcher}{ingredient}{%
\csname @saladwith@#1true\endcsname
}
\end{lstcode}
Here the three ingredients ``onions'', ``gherkins'', and ``chillies'' have
been defined. An error message for ``not defined'' ingredients does not
exist.
For a salad with onions and gherkins the user may use
\begin{lstcode}
\FamilyOptions{butcher}{%
ingredient=onions,ingredient=gherkins}
\end{lstcode}
or shorter
\begin{lstcode}
\FamilyOption{butcher}
{ingredient}{onions,gherkins}
\end{lstcode}
\end{Example}
%
\EndIndex{Cmd}{FamilyOption}%
\begin{Declaration}
\Macro{AtEndOfFamilyOptions}\Parameter{action}%
\end{Declaration}
\BeginIndex{Cmd}{AtEndOfFamilyOptions}%
Sometimes\ChangedAt{v3.12}{\Package{scrbase}} it is useful to delay the
execution of an \PName{action} that is part of a value assignment to a key
until all assignments inside one \Macro{FamilyProcessOptions},
\Macro{FamilyExecuteOptions}, \Macro{FamilyOptions}, or \Macro{FamilyOption}
is finished. This may be done using \Macro{AtEndOfFamilyOptions} inside
an option definition. Reporting failure states of \PName{action} is not
possible in this case. Furthermore, the command should not be used outside an
option definition.
%
\EndIndex{Cmd}{AtEndOfFamilyOptions}%
\begin{Declaration}
\Macro{FamilyBoolKey}\OParameter{family member}\Parameter{family}%
\Parameter{key}\Parameter{switch name}\\
\Macro{FamilySetBool}\Parameter{family}%
\Parameter{key}\Parameter{switch name}\Parameter{value}
\end{Declaration}
\BeginIndex{Cmd}{FamilyBoolKey}%
\BeginIndex{Cmd}{FamilySetBool}%
In the previous examples, boolean switches often have been used. In the example
with option \Option{coldcut}, it is necessary that the user assigns either
value \PValue{true} or value \PValue{false}. There is no error message for
wrong value assignment. Because of this, boolean switches are a necessary
feature. Package \Package{scrbase} provides \Macro{FamilyBoolKey} for definition of
such options. Therefore, the arguments \PName{family member}, \PName{family}, and
\PName{key} are the same as that used by \Macro{DefineFamilyKey} (see
\autopageref{desc:scrbase.cmd.DefineFamilyKey}). Argument \PName{switch name}
is the name of the switch without the prefix \Macro{if}. If a switch with this
name does not exist already, \Macro{FamilyBoolKey} will define it and
initialize it to \PName{false}. Internally \Macro{FamilyBooKey} uses
\Macro{FamilySetBool} as \PName{action} of \Macro{DefineFamilyKey}. The
\PName{default} for those options is always \PValue{true}.
On the other hand, \Macro{FamilySetBool} understands \PName{value} \PValue{on}
and \PValue{yes} beside \PName{true} for switching on and \PName{off} and
\PName{no} beside \PName{false} for switching off. Unknown values will result
in a call of \Macro{FamilyUnknownKeyValue} with the arguments \PName{family},
\PName{key}, and \PName{value}, which results in setting of
\Macro{FamilyKeyState}. Depending on the command used and other family
members, this may result in an error message about unknown value assignment
(see also \autopageref{desc:scrbase.cmd.FamilyUnkownKeyValue} and
\autopageref{desc:scrbase.cmd.FamilyKeyState}).
\begin{Example}
The key \Option{coldcut} should be declared somehow more
robust. Additionally, all sausage packages should use the same key. So
either all or none of them will produce cold cut.
\begin{lstcode}
\FamilyBoolKey{butcher}{coldcut}%
{@coldcut}
\end{lstcode}
A test, whether or not to produce cold cut, may be:
\begin{lstcode}
\if@coldcut
...
\else
...
\fi
\end{lstcode}
This would be the same in each of the three sausage packages, thereby
defining the attribute ``coldcut'' as a family option:
\begin{lstcode}[moretexcs={define@key}]
\@ifundefined{if@coldcut}{%
\expandafter\newif\csname if@coldcut\endcsname
}{}%
\DefineFamilyKey[]{butcher}{coldcut}[true]{%
\FamilySetBool{butcher}{coldcut}%
{@coldcut}%
{#1}%
}
\end{lstcode}
or shorter:
\begin{lstcode}
\FamilyBoolKey[]{butcher}{coldcut}%
{@coldcut}
\end{lstcode}
using the additional information at
\autopageref{explain:scrbase.macro.DefineFamilyKey}, this is not only valid
for \Macro{DefineFamilyKey} but for \Macro{FamilyBoolKey} too.
\end{Example}
%
\EndIndex{Cmd}{FamilySetBool}%
\EndIndex{Cmd}{FamilyBoolKey}
\begin{Declaration}
\Macro{FamilyNumericalKey}\OParameter{family member}\Parameter{family}%
\Parameter{key}\\
\hphantom{\XMacro{FamilyNumericalKey}}%
\OParameter{default}\Parameter{command}%
\Parameter{values list}\\
\Macro{FamilySetNumerical}\Parameter{family}\Parameter{key}\\
\hphantom{\XMacro{FamilySetNumerical}}%
\Parameter{command}\Parameter{values list}%
\Parameter{value}
\end{Declaration}
\BeginIndex{Cmd}{FamilyNumericalKey}%
\BeginIndex{Cmd}{FamilySetNumerical}%
In contrast to switches that may be either true or false, a key exists
that accept several values. For example an alignment may not only be left or
not left, but left, centered, or right. Internally such
differentiation often is made using \Macro{ifcase}. This \TeX{} command
expects a numerical value. Because of this the command to define a macro by
a \PName{key} has been named \Macro{FamilyNumericalKey} in
\Package{scrbase}. The \PName{values list} thereby has the form:
\begin{flushleft}\vskip\dp\strutbox\begin{tabular}{l}
\Parameter{value}\Parameter{definition}\texttt{,}%
\Parameter{value}\Parameter{definition}\texttt{,}%
\dots
\end{tabular}\vskip\dp\strutbox\end{flushleft}
Therefore, the \PName{values list} does not solely define the supported values to the
\PName{key}. For each of the \PName{value}s, the
\PName{definition} of macro \Macro{\PName{command}} also is given. Usually,
\PName{definition} is just a numerical value. Nevertheless, other content is
possible and allowed. Currently, the only limitation is that
\PName{definition} has to be fully expandable and will be expanded during the
assignment.
\begin{Example}
The sausage may be cut different. For example the cold cut may stay uncut or
will be cut roughly or may be cut thinly. This information should be stored
in command \Macro{cuthow}.
\begin{lstcode}
\FamilyNumericalKey{butcher}%
{saladcut}{cuthow}{%
{none}{none},{no}{none},{not}{none}%
{rough}{rough},%
{thin}{thin}%
}
\end{lstcode}
Not cutting anything may be selected either by
\begin{lstcode}
\FamilyOptions{butcher}{saladcut=none}
\end{lstcode}
or
\begin{lstcode}
\FamilyOptions{butcher}{saladcut=no}
\end{lstcode}
or
\begin{lstcode}
\FamilyOptions{butcher}{saladcut=not}
\end{lstcode}
In all three cases \Macro{cuthow} would be defined with content
\PValue{none}. It may be very useful to provide several values for the same
result as shown in this example.
Now, it's most likely, that the kind of cutting will not be printed, but
should be evaluated later. In this case a textual definition would not be
useful. If the key is defined like this:
\begin{lstcode}
\FamilyNumericalKey{butcher}%
{saladcut}{cuthow}{%
{none}{0},{no}{0},{not}{0}%
{rough}{1},%
{thin}{2}%
}
\end{lstcode}
then a condition like the following may be used:
\begin{lstcode}
\ifcase\cuthow
% no cut
\or
% rough cut
\else
% thin cut
\fi
\end{lstcode}
\end{Example}
Internally, \Macro{FamilyNumericalKey} uses \Macro{FamilySetNumerical} as
\PName{action} of \Macro{DefineFamilyKey}. If a unknown value is assigned to
such a key, \Macro{FamilySetNumerical} will call \Macro{FamilyUnkownKeyValue}
with the arguments \PName{family}, \PName{key} and \PName{value}. This will
normally result in an error message about assigning an unknown value.
%
\EndIndex{Cmd}{FamilySetNumerical}%
\EndIndex{Cmd}{FamilyNumericalKey}%
\begin{Declaration}
\Macro{FamilyStringKey}\OParameter{family member}\Parameter{family}%
\Parameter{key}\\
\hphantom{\XMacro{FamilyStringKey}}%
\OParameter{default}\Parameter{command}
\end{Declaration}
\BeginIndex{Cmd}{FamilyStringKey}%
This defines\ChangedAt{v3.08}{\Package{scrbase}} a \PName{key} that accepts
every value. The value will be stored into the given \Macro{command}. If there
is no optional argument for the \PName{default}, \Macro{FamilyStringKey} is
the same as:
\begin{quote}
\Macro{DefineFamilyKey}\OParameter{family member}\Parameter{family}%
\Parameter{key}\\
\hphantom{\Macro{DefineFamilyKey}}%
\PParameter{\Macro{def}\PName{command}\string{\#1\string}%
\Macro{FamilyKeyStateProcessed}}.
\end{quote}
If an optional argument \PName{default} is used, \Macro{FamilyStringKey}
is the same as:
\begin{quote}
\Macro{DefineFamilyKey}\OParameter{family member}\Parameter{family}%
\Parameter{key}\\
\hphantom{\Macro{DefineFamilyKey}}%
\OParameter{default}%
\PParameter{\Macro{def}\PName{command}\string{\#1\string}}.
\end{quote}
If \PName{command} is not been defined, an empty macro will be defined.
\begin{Example}
By default an amount of 250\Unit{g} sausage salad should be produced. The
amount should be configurable by an option. The wanted amount will be stored
in the macro \Macro{saladweight}. The option should be named
\PValue{saladweight}, too:
\begin{lstcode}
\newcommand*{\saladweight}{250g}
\FamilyStringKey{butcher}%
{saladweight}[250g]{\saladweight}
\end{lstcode}
To switch back to the default weight after changing it, the user may simply
use the option without weight:
\begin{lstcode}
\FamilyOptions{butcher}{saladweight}
\end{lstcode}
This may be done, because the default weight has been set as default at the
definition of the option above.
\end{Example}
In this case there are not unknown values because all values are simply used
for a macro definition. Nevertheless, you should note that paragraph breaks
at the value assignment to the key are not allowed.
%
\EndIndex{Cmd}{FamilyStringKey}%
\begin{Declaration}
\Macro{FamilyUnkownKeyValue}\Parameter{family}\Parameter{key}%
\Parameter{value}\Parameter{values list}%
\end{Declaration}
\BeginIndex{Cmd}{FamilyUnkownKeyValue}%
\BeginIndex{Cmd}{FamilyElseValues}%
The command \Macro{FamilyUnknownKeyValue} throws and error message about
unknown values assigned to a known key. The \PName{values list} is a comma
separated list of allowed values in the form:
\begin{flushleft}\vskip\dp\strutbox\begin{tabular}{l}
`\PName{value}'\texttt{,} `\PName{value}' \dots
\end{tabular}\vskip\dp\strutbox\end{flushleft}
Currently\ChangedAt{v3.12}{\Package{scrbase}}, \PName{values list} is
not used by \Package{scrbase}.
\begin{Example}
Now, for the cold cut, the choices should be cut or no-cut and in case of cut
rough or thin. Rough should be the default for cutting.
\begin{lstcode}
\@ifundefined{if@thincut}{%
\expandafter
\newif\csname if@thincut\endcsname}{}%
\@ifundefined{if@coldcut}{%
\expandafter
\newif\csname if@coldcut\endcsname}{}
\DefineFamilyKey{butcher}%
{coldcut}[true]{%
\FamilySetBool{butcher}{coldcut}%
{@coldcut}%
{#1}%
\ifx\FamilyKeyState\FamilyKeyStateProcessed
\@thincutfalse
\else
\ifstr{#1}{thin}{%
\@coldcuttrue
\@thincuttrue
\FamilyKeyStateProcessed
}{}%
\fi
}%
\end{lstcode}
Let's have a look at the definition of \Option{butcher}:
First of all, we try to set the boolean switch of cold cut using
\Macro{FamilySetBool}. After this command, we test whether or not
\Macro{FamilyKeyState} signals the success of the command with state
\Macro{FamilyKeyStateProcessed}. If so, only the thin cut has to be
deactivated.
In the other case, the value will be tested to be equal to \PValue{thin}. In
that case, cold cut and thin cut are activated and the state will be
switched to \Macro{FamilyKeyStateProcessed}. If the last test failed also,
the failure state of \Macro{FamilySetBool} is still valid at the end of the
execution.
Command \Macro{ifstr} is used for the thin test. It is
described on \autopageref{desc:scrbase.cmd.ifstr} in
\autoref{sec:scrbase.if}.
\end{Example}
%
\EndIndex{Cmd}{FamilyUnkownKeyValue}%
\begin{Declaration}
\Macro{FamilyElseValues}
\end{Declaration}
\BeginIndex{Cmd}{FamilyElseValues}%
With former releases\ChangedAt{v3.12}{\Package{scrbase}} of \Package{scrbase},
additional allowed values reported by \Macro{FamilyUnknownKeyValue} can be
set re-defining \Macro{FamilyElseValues} in the form:
\begin{flushleft}\vskip\dp\strutbox\begin{tabular}{l}
\texttt{,} `\PName{value}'\texttt{,} `\PName{value}' \dots
\end{tabular}\vskip\dp\strutbox\end{flushleft}
Since release~3.12 \Macro{FamilyUnknownValue} does not report errors itself,
but signals them using \Macro{FamilyKeyState}. Therefore,
\Macro{FamilyElseValues} became deprecated. Nevertheless, its former usage is
recognised by \Package{scrbase} and results in a code change demand message.%
\EndIndex{Cmd}{FamilyElseValues}%
\section{Conditional Execution}
\label{sec:scrbase.if}
The package \Package{scrbase} provides several commands for conditional
execution. other than the \TeX{} syntax of conditionals, e.\,g.,
% Umbruchkorrektur
\begin{lstcode}[belowskip=\dp\strutbox]
\iftrue
...
\else
...
\fi
\end{lstcode}
yet the \LaTeX{} syntax also known from \LaTeX{} commands like
\Macro{IfFileExists}, \Macro{@ifundefined}, \Macro{@ifpackageloaded}, and many
others, is used. Nevertheless, some package authors prefer to use the \TeX{}
syntax even for users at the \LaTeX{} interface level that could inevitably
lead to naming conflicts with the \Package{scrbase} conditionals. In fact, the
conditionals of \Package{scrbase} are very basic. Because of this
\Package{scrbase} firstly defines these conditionals as internal commands with
prefix \Macro{scr@}. Additional user commands without this prefix are
subsequently defined. But the definition of the user commands may be
suppressed with option \Option{internalonly} (see
\autoref{sec:scrbase.loadit}, \autopageref{desc:scrbase.option.internalonly}).
Authors of packages and classes should use the internal commands as
\KOMAScript{} itself does. Nevertheless, for completeness the user commands
are described separately.
\begin{Declaration}
\Macro{scr@ifundefinedorrelax}%
\Parameter{name}\Parameter{then instructions}\Parameter{else instructions}\\
\Macro{ifundefinedorrelax}%
\Parameter{name}\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{scr@ifundefinedorrelax}%
\BeginIndex{Cmd}{ifundefinedorrelax}%
This command has almost the same functionality as \Macro{@ifundefined} from
the \LaTeX{} kernel (see \cite{latex:source2e}). So the \PName{then
instructions} will be executed if \PName{name} is the name of a command
that is currently either not defined or \Macro{relax}. Otherwise, the
\PName{else instructions} will be executed. In contrast to
\Macro{@ifundefined}, \Macro{\PName{name}} is not defined to be \Macro{relax}
in the event it was not defined before. Moreover, using \eTeX{} this case will
not consume any hash memory.%
%
\EndIndex{Cmd}{ifundefinedorrelax}%
\EndIndex{Cmd}{scr@ifundefinedorrelax}%
\begin{Declaration}
\Macro{scr@ifpdftex}%
\Parameter{then instructions}\Parameter{else instructions}\\
\Macro{ifpdftex}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{scr@ifpdftex}%
\BeginIndex{Cmd}{ifpdftex}%
If pdf\TeX{} has been used, the \PName{then instructions} will be executed,
otherwise the \PName{else instructions}. Whether or not a PDF-file is
generated does not matter, and the pdf\TeX{} test is rarely useful. In
general, test for the desired command instead (see previous
\Macro{scr@ifundefinedorrelax} and \Macro{ifundefinedorrelax}).
%
\EndIndex{Cmd}{ifpdftex}%
\EndIndex{Cmd}{scr@ifpdftex}%
\begin{Declaration}
\Macro{scr@ifVTeX}%
\Parameter{then instructions}\Parameter{else instructions}\\
\Macro{ifVTeX}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{scr@ifVTeX}%
\BeginIndex{Cmd}{ifVTeX}%
If V\TeX{} has been used, the \PName{then instructions} will be executed,
otherwise the \PName{else instructions}. This test is seldom useful. Test for
the desired command instead (see previous \Macro{scr@ifundefinedorrelax} and
\Macro{ifundefinedorrelax}).
%
\EndIndex{Cmd}{ifVTeX}%
\EndIndex{Cmd}{scr@ifVTeX}%
\begin{Declaration}
\Macro{scr@ifpdfoutput}%
\Parameter{then instructions}\Parameter{else instructions}\\
\Macro{ifpdfoutput}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{scr@ifpdfoutput}%
\BeginIndex{Cmd}{ifpdfoutput}%
When generating a PDF-file the \PName{then instructions} will be executed,
otherwise the \PName{else instructions}. Whether pdf\TeX{} or V\TeX{} or
another \TeX{} engine is used to generate the PDF-file does not matter.
%
\EndIndex{Cmd}{ifpdfoutput}%
\EndIndex{Cmd}{scr@ifpdfoutput}%
\begin{Declaration}
\Macro{scr@ifpsoutput}%
\Parameter{then instructions}\Parameter{else instructions}\\
\Macro{ifpsoutput}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{scr@ifpsoutput}%
\BeginIndex{Cmd}{ifpsoutput}%
When generating a PostScript-file the \PName{then instructions} will be
executed, otherwise the \PName{else instructions}. V\TeX{} provides direct
PostScript generation that will be recognised here. If V\TeX{} is not used,
but a switch \Macro{if@dvips} has been defined, the decision depends on that
switch. \KOMAScript{} provides \Macro{if@dvips} in \Package{typearea}.
%
\EndIndex{Cmd}{ifpsoutput}%
\EndIndex{Cmd}{scr@ifpsoutput}%
\begin{Declaration}
\Macro{scr@ifdvioutput}%
\Parameter{then instructions}\Parameter{else instructions}\\
\Macro{ifdvioutput}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{scr@ifdvioutput}%
\BeginIndex{Cmd}{ifdvioutput}%
When generating a DVI-file the \PName{then instructions} will be executed,
otherwise the \PName{else instructions}. If neither a direct PDF-file
generation nor a direct PostScript-file generation has been detected, DVI-file
generation is assumed.
%
\EndIndex{Cmd}{ifdvioutput}%
\EndIndex{Cmd}{scr@ifdvioutput}%
\begin{Declaration}
\Macro{ifnotundefined}\Parameter{name}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifnotundefined}%
\eTeX{} will be used to test, whether or not a command with the given
\PName{name} has already been defined. The \PName{then instructions} will be
executed if the command is defined, otherwise the \PName{else
instructions}. There is no corresponding internal command.
%
\EndIndex{Cmd}{ifnotundefined}%
\begin{Declaration}
\Macro{ifstr}\Parameter{string}\Parameter{string}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifstr}%
Both \PName{string} arguments are expanded and afterwards compared. If the
expansions are the same, the \PName{then instructions} will be executed,
otherwise the \PName{else instructions}. There is no corresponding internal
command.
%
\EndIndex{Cmd}{ifstr}%
\begin{Declaration}
\Macro{ifstrstart}\Parameter{string}\Parameter{string}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifstrstart}%
Both\ChangedAt{v3.12}{\Package{scrbase}} \PName{string} arguments are
expanded and afterwards compared. If aside from white spaces the first string
starts with the second one, the \PName{then instructions} will be executed,
otherwise the \PName{else instructions}. The command is not completely
expandable and there is no corresponding internal command.%
\EndIndex{Cmd}{ifstrstart}%
\begin{Declaration}
\Macro{ifisdimen}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifisdimen}%
If\ChangedAt{v3.12}{\Package{scrbase}} the expansion of\PName{code} results in
a \Macro{dimen}, which is also known as \TeX{} length register, the
\PName{then instructions} will be executed, otherwise the \PName{else
instructions}. The command is not completely expandable and there is no
corresponding internal command.%
\EndIndex{Cmd}{ifisdimen}%
\begin{Declaration}
\Macro{ifisdimension}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifisdimension}%
If\ChangedAt{v3.12}{\Package{scrbase}} \PName{code} expands to something with
the syntax of the value of a length, the \PName{then instructions} will be
executed, otherwise the \PName{else instructions}. Please
note\textnote{Attention!} that currently an invalid unit will result in an
error message. The command is not completely expandable and there is no
corresponding internal command.%
\EndIndex{Cmd}{ifisdimension}%
\begin{Declaration}
\Macro{ifisdimexpr}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifisdimexpr}%
If\ChangedAt{v3.12}{\Package{scrbase}} the expansion of\PName{code} results in
a \Macro{dimexpr}, which is also known as \TeX{} length expression, the
\PName{then instructions} will be executed, otherwise the \PName{else
instructions}. Note\textnote{Attention!} that illegal expressions will
result in error messages. The command is not completely expandable and there
is no corresponding internal command.%
\EndIndex{Cmd}{ifisdimexpr}%
\begin{Declaration}
\Macro{ifisskip}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifisskip}%
If\ChangedAt{v3.12}{\Package{scrbase}} the expansion of\PName{code} results in
a \Macro{skip}, which is also known as \TeX{} distance register, the
\PName{then instructions} will be executed, otherwise the \PName{else
instructions}. The command is not completely expandable and there is no
corresponding internal command.%
\EndIndex{Cmd}{ifisskip}%
\begin{Declaration}
\Macro{ifisglue}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifisglue}%
If\ChangedAt{v3.12}{\Package{scrbase}} \PName{code} expands to something with
the syntax of the value of a skip, the \PName{then instructions} will be
executed, otherwise the \PName{else instructions}. Please
note\textnote{Attention!} that currently an invalid unit will result in an
error message. The command is not completely expandable and there is no
corresponding internal command.%
\EndIndex{Cmd}{ifisglue}%
\begin{Declaration}
\Macro{ifisglueexpr}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifisglueexpr}%
If\ChangedAt{v3.12}{\Package{scrbase}} the expansion of\PName{code} results in
a \Macro{glueexpr}, which is also known as \TeX{} distance expression, the
\PName{then instructions} will be executed, otherwise the \PName{else
instructions}. Note,\textnote{Attention!} that illegal expressions will
result in error messages. The command is not completely expandable and there
is no corresponding internal command.%
\EndIndex{Cmd}{ifisglueexpr}%
\begin{Declaration}
\Macro{ifiscount}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifiscount}%
If\ChangedAt{v3.12}{\Package{scrbase}} the expansion of\PName{code} results in
a \Macro{count}, which is also known as \TeX{} counter register, the
\PName{then instructions} will be executed, otherwise the \PName{else
instructions}. The command is not completely expandable and there is no
corresponding internal command. For test with \LaTeX{} counters, see
\Macro{ifiscounter}.%
\EndIndex{Cmd}{ifiscount}%
\begin{Declaration}
\Macro{ifisnumber}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifisnumber}%
If\ChangedAt{v3.12}{\Package{scrbase}} \PName{code} expands to something with
the syntax of the value of a counter, which would be a negative or positive
integer, the \PName{then instructions} will be executed, otherwise the
\PName{else instructions}. The command is not completely expandable and there
is no corresponding internal command.%
\EndIndex{Cmd}{ifisnumber}%
\begin{Declaration}
\Macro{ifisnumexpr}\Parameter{code}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifisnumexpr}%
If\ChangedAt{v3.12}{\Package{scrbase}} the expansion of\PName{code} results in
a \Macro{numexpr}, which is also known as \TeX{} number expression, the
\PName{then instructions} will be executed, otherwise the \PName{else
instructions}. Note\textnote{Attention!} that illegal expressions will
result in error messages. The command is not completely expandable and there
is no corresponding internal command.%
\EndIndex{Cmd}{ifisnumexpr}%
\begin{Declaration}
\Macro{ifiscounter}\Parameter{counter}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifiscounter}%
If\ChangedAt{v3.12}{\Package{scrbase}} \PName{counter} is an already defined
\LaTeX{} counter, the \PName{then instructions} will be executed, otherwise
the \PName{else instructions}. The command is not completely expandable and
there is no corresponding internal command.%
\EndIndex{Cmd}{ifiscounter}%
\begin{Declaration}
\Macro{ifnumber}\Parameter{string}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifnumber}%
Note that this does not compare numbers. The \PName{then instructions} will
be executed if the expansion of \PName{string} consists of digits
only. Otherwise the \PName{else instructions} will be used. There is no
corresponding internal command.
%
\EndIndex{Cmd}{ifnumber}%
\begin{Declaration}
\Macro{ifdimen}\Parameter{string}%
\Parameter{then instructions}\Parameter{else instructions}
\end{Declaration}
\BeginIndex{Cmd}{ifdimen}%
Note that this does not compare dimensions. The \PName{then instructions} will
be executed, if the expansion of \PName{string} consists of digits and a valid
unit of length. Otherwise, the \PName{else instructions} will be used. There
is no corresponding internal command.
%
\EndIndex{Cmd}{ifdimen}%
\begin{Declaration}
\Macro{if@atdocument}\ \PName{the instructions}
\Macro{else}\ \PName{else instructions} \Macro{fi}
\end{Declaration}
\BeginIndex{Cmd}{if@atdocument}%
This command exists intentionally as internal command only. In the document
preamble \Macro{if@atdocument} is same as \Macro{iffalse}. After
\Macro{begin}\PParameter{document} it's the same as \Macro{iftrue}. Authors of
classes and packages may use this if a command should work somehow different
depending on whether it has been used in the preamble or inside the documents
body. Please note\textnote{Attention!} that this is a condition in \TeX{}
syntax not in \LaTeX{} syntax!
%
\EndIndex{Cmd}{if@atdocument}%
\section{Definition of Language-Dependent Terms}
\label{sec:scrbase.languageSupport}
\BeginIndex{}{language>definition}
\index{language>dependent terms|see{language definition}}
\index{terms>language-dependent|see{language definition}}
Normally, one has to change or define language-dependent terms like
\Macro{captionsenglish} in such a way that, in addition to the available terms,
the new or redefined terms are defined. This is made more difficult by the
fact that some packages like \Package{german}\IndexPackage{german} or
\Package{ngerman}\IndexPackage{ngerman} redefine those settings when the
packages are loaded. These definitions unfortunately occur in such a manner as
to destroy all previous private settings. That is also the reason why it makes
sense to delay changes with \Macro{AtBeginDocument} until
\Macro{begin}\PParameter{document}; that is, after package loading is
completed. The user can also use \Macro{AtBeginDocument} or redefine the
language-dependent terms after \Macro{begin}\PParameter{document}; that is,
not put them in the preamble at all. The package \Package{scrbase}
provides some additional commands for defining language-dependent terms.
\begin{Declaration}
\Macro{defcaptionname}%
\Parameter{language list}\Parameter{term}\Parameter{definition}\\
\Macro{providecaptionname}%
\Parameter{language list}\Parameter{term}\Parameter{definition}\\
\Macro{newcaptionname}%
\Parameter{language list}\Parameter{term}\Parameter{definition}\\
\Macro{renewcaptionname}%
\Parameter{language list}\Parameter{term}\Parameter{definition}\\
\Macro{defcaptionname*}%
\Parameter{language list}\Parameter{term}\Parameter{definition}\\
\Macro{providecaptionname*}%
\Parameter{language list}\Parameter{term}\Parameter{definition}\\
\Macro{newcaptionname*}%
\Parameter{language list}\Parameter{term}\Parameter{definition}\\
\Macro{renewcaptionname*}%
\Parameter{language list}\Parameter{term}\Parameter{definition}
\end{Declaration}
\BeginIndex{Cmd}{defcaptionname}%
\BeginIndex{Cmd}{providecaptionname}%
\BeginIndex{Cmd}{newcaptionname}%
\BeginIndex{Cmd}{renewcaptionname}%
Using one of these commands, the user can assign a \PName{definition} for a
particular language to a \PName{term}. Several languages can be concatenated
with comma to a \PName{language list}. The \PName{term} is always a
macro. The commands differ depending on whether a given language or a
\PName{term} within a given language are already defined or not at the
time the command is called.
If a language is not defined, then \Macro{providecaptionname} does
nothing other than write a message in the log file. This happens only once
for each language. If a language is defined, but \PName{term} is not yet
defined for it, then it will be defined using \PName{definition}. The
\PName{term} will not be redefined if the language already has such a
definition; instead, an appropriate message is written to the log file.
The command \Macro{newcaptionname} has a slightly different behaviour. If a
language is not yet defined, then a new language command will be
created and a message written to the log file. For language
\PValue{USenglish}, for example, this would be the language command
\Macro{captionsUSenglish}. If \PName{term} is not yet defined in a
language, then it will be defined using \PName{definition}. If
\PName{term} already exists in a language, then this results in an error
message.
The command \Macro{renewcaptionname} again behaves differently. It requires an
existing definition of \PName{term} in the languages. If neither
a language nor \PName{term} exist or \PName{term} is unknown in a
defined language, then an error message is given. Otherwise, the
\PName{term} for the language will be redefined according to
\PName{definition}.
\KOMAScript{} employs \Macro{providecaptionname} in order to define the
commands in \autoref{sec:scrlttr2-experts.languages}.
\begin{Example}
If you prefer ``fig.'' instead of ``figure'' in \PValue{USenglish}, you may
achieve this using:
\begin{lstcode}
\renewcaptionname{USenglish}{\figurename}{fig.}
\end{lstcode}
If you want the same change not only in \PValue{USenglish} but also in
\PValue{UKenglish}, you do not need an additional:
\begin{lstcode}
\renewcaptionname{UKenglish}{\figurename}{fig.}
\end{lstcode}
but can simply extend the \PName{language list}:
\begin{lstcode}
\renewcaptionname{USenglish,UKenglish}{\figurename}{fig.}
\end{lstcode}
You can extend the \PName{language list} in the same manner by
\PValue{american}, \PValue{australian}, \PValue{british}, \PValue{canadian},
and \PValue{newzealand}.
\end{Example}
Since \KOMAScript~3.12\ChangedAt{v3.12}{\Package{scrbase}} you do not need to
delay the definition or redefinition until \Macro{begin}\PParameter{document}
using \Macro{AtBeginDocument} any longer because \Package{scrbase} does the
delay automatically for (re)definitions in the document's
preamble. Additionally, \Package{scrbase} tests if a redefinition should be
made in \Macro{extras\PName{language}} instead of
\Macro{captions\PName{language}} and does so automatically. The new star
variants of the commands always use \Macro{extras\PName{language}}. So
redefinition of language dependent terms for packages like \Package{hyperref}
that use \Macro{extras\PName{language}} should work as expected by the user.
Language dependent terms usually defined by classes and language
packages are listed and described in \autoref{tab:scrbase.commonNames}.
\begin{desclist}
\renewcommand*{\abovecaptionskipcorrection}{-\normalbaselineskip}%
\desccaption[{%
Overview of usual language dependent terms%
}]{%
Overview of language dependent terms of usual language packages%
\label{tab:scrbase.commonNames}%
}{%
Overview of usual language dependent terms
(\emph{continuation})%
}%
\entry{\Macro{abstractname}}{%
heading of the abstract%
\IndexCmd{abstractname}%
}%
\entry{\Macro{alsoname}}{%
``see also'' in additional cross references of the index%
\IndexCmd{alsoname}%
}%
\entry{\Macro{appendixname}}{%
``appendix'' in the heading of an appendix chapter%
\IndexCmd{appendixname}%
}%
\entry{\Macro{bibname}}{%
heading of the bibliography%
\IndexCmd{bibname}%
}%
\entry{\Macro{ccname}}{%
prefix heading for the distribution list of a letter%
\IndexCmd{ccname}%
}%
\entry{\Macro{chaptername}}{%
``chapter'' in the heading of a chapter%
\IndexCmd{chaptername}%
}%
\entry{\Macro{contentsname}}{%
heading of the table of contents%
\IndexCmd{contentsname}%
}%
\entry{\Macro{enclname}}{%
prefix heading for the enclosure of a letter%
\IndexCmd{enclname}%
}%
\entry{\Macro{figurename}}{%
prefix heading of figure captions%
\IndexCmd{figurename}%
}%
\entry{\Macro{glossaryname}}{%
heading of the glossary%
\IndexCmd{glossaryname}%
}%
\entry{\Macro{headtoname}}{%
``to'' in header of letter pages%
\IndexCmd{headtoname}%
}%
\entry{\Macro{indexname}}{%
heading of the index%
\IndexCmd{indexname}%
}%
\entry{\Macro{listfigurename}}{%
heading of the list of figures%
\IndexCmd{listfigurename}%
}%
\entry{\Macro{listtablename}}{%
heading of the list of tables%
\IndexCmd{listtablename}%
}%
\entry{\Macro{pagename}}{%
``page'' in the pagination of letters%
\IndexCmd{pagename}%
}%
\entry{\Macro{partname}}{%
``part'' in the heading of a part%
\IndexCmd{partname}%
}%
\entry{\Macro{prefacename}}{%
heading of the preface%
\IndexCmd{prefacename}%
}%
\entry{\Macro{proofname}}{%
prefix heading of mathematical proofs%
\IndexCmd{proofname}%
}%
\entry{\Macro{refname}}{%
heading of the list of references%
\IndexCmd{refname}%
}%
\entry{\Macro{seename}}{%
``see'' in cross references of the index%
\IndexCmd{seename}%
}%
\entry{\Macro{tablename}}{%
prefix heading at table captions%
\IndexCmd{tablename}%
}%
\end{desclist}
%
\EndIndex{Cmd}{providecaptionname}%
\EndIndex{Cmd}{newcaptionname}%
\EndIndex{Cmd}{renewcaptionname}%
\EndIndex{Cmd}{defcaptionname}%
%
\EndIndex{}{language>definition}
\section{Identification of \KOMAScript}
\label{sec:scrbase.identify}
Package \Package{scrbase} may be used independent of \KOMAScript{} with
other packages and classes. Nevertheless, it is a \KOMAScript{} package. For
this, \Package{scrbase} also provides commands to identify \KOMAScript{} and
to identify itself as a \KOMAScript{} package.
\begin{Declaration}
\Macro{KOMAScript}
\end{Declaration}
\BeginIndex{Cmd}{KOMAScript}%
This command only sets the word ``\KOMAScript'' with sans-serif font and
a little bit tracking for the capitals. By the way: All \KOMAScript{} classes
and packages define this command, if it has not been defined already. The
definition is robust using \Macro{DeclareRobustCommand}.
%
\EndIndex{Cmd}{KOMAScript}
\begin{Declaration}
\Macro{KOMAScriptVersion}
\end{Declaration}
\BeginIndex{Cmd}{KOMAScriptVersion}%
\KOMAScript{} defines the main version of \KOMAScript{} in this command. It
has the form ``\PName{date} \PName{version} \texttt{KOMA-Script}''. This main
version is same for all \KOMAScript{} classes and the \KOMAScript{} packages
that are essential for the classes. Because of this, it may be inquired after
loading \Package{scrbase}, too. For example, this document has been made using
\KOMAScript{} version ``\KOMAScriptVersion''.
%
\EndIndex{Cmd}{KOMAScriptVersion}%
\section{Extension of the \LaTeX{} Kernel}
\label{sec:scrbase:latexkernel}
Sometimes the \LaTeX{} kernel itself provides commands, but lacks other,
similar commands that would often be useful, too. Some of those commands for
authors of packages and classes are provided by \Package{scrbase}.
\begin{Declaration}
\Macro{ClassInfoNoLine}\Parameter{class name}\Parameter{information}\\
\Macro{PackageInfoNoLine}\Parameter{package name}\Parameter{information}%
\end{Declaration}%
\BeginIndex{Cmd}{PackageInfoNoLine}%
\BeginIndex{Cmd}{ClassInfoNoLine}%
For authors of classes and package the \LaTeX{} kernel already provides
commands like \Macro{ClassInfo} and \Macro{PackageInfo} to write information.
together with the current line number, into the log-file. Besides
\Macro{PackageWarning} and \Macro{ClassWarning} to throw warning messages with
line numbers, it also provides \Macro{PackageWarningNoLine} and
\Macro{ClassWarningNoLine} for warning messages without line
numbers. Nevertheless, the commands \Macro{ClassInfoNoLine} and
\Macro{PackageInfoNoLine} for writing information without line numbers into the
log-file are missing. Package \Package{scrbase} provides them.
%
\EndIndex{Cmd}{ClassInfoNoLine}%
\EndIndex{Cmd}{PackageInfoNoLine}
\begin{Declaration}
\Macro{l@addto@macro}\Parameter{command}\Parameter{extension}%
\end{Declaration}%
\BeginIndex{Cmd}{l@addto@macro}%
The \LaTeX{} kernel already provides an internal command \Macro{g@addto@macro}
to extend the definition of macro \Macro{command} by \PName{extension}
globally. This may be used only for macros that have no
arguments. Nevertheless, sometimes a command like this, that works locally to
a group instead of globally, could be useful. Package \Package{scrbase}
provides such a command with \Macro{l@addto@macro}. An alternative may be
usage of package \Package{etoolbox}\IndexPackage{etoolbox}, which provides
several of such commands for different purposes (see \cite{package:etoolbox}).
%
\EndIndex{Cmd}{l@addto@macro}
\section{Extension of the Mathematical Features of \eTeX}
\label{sec:scrbase:etex}
\eTeX{}, that is meanwhile used by \LaTeX{} and needed by \KOMAScript{},
provided with \Macro{numexpr}\IndexCmd{numexpr}, an extended feature for
calculation of simple arithmetic with \TeX{} counters and
integers. The four basic arithmetic operations and brackets are
supported. Correct rounding is done while division. Sometimes additional
operators would be useful.
\begin{Declaration}
\Macro{XdivY}\Parameter{dividend}\Parameter{divisor}\\
\Macro{XmodY}\Parameter{dividend}\Parameter{divisor}%
\end{Declaration}%
\BeginIndex{Cmd}{XdivY}%
\BeginIndex{Cmd}{XmodY}%
Having a division with remainder command\ChangedAt{v3.05a}{\Package{scrbase}}
\Macro{XdivY} gives the value of the integer quotient, with command
\Macro{XmodY} giving the value of the remainder. This kind of division is
defined:
\[
\textit{dividend} = \textit{divisor} \cdot
\textit{integer quotient} + \textit{remainder}
\]
with \textit{dividend} and \textit{remainder} are integer, \textit{remainder}
is greater or equal to \textit{divisor}, and \textit{divisor} is a natural
number greater than 0.
The value may be used for assignment to a counter or directly in the
expression of \Macro{numexpr}. For output the value as an Arabic number has
to be prefixed by \Macro{the}.%
%
\EndIndex{Cmd}{XmodY}%
\EndIndex{Cmd}{XdivY}%
%
\EndIndex{Package}{scrbase}%
\endinput
%%% Local Variables:
%%% mode: latex
%%% mode: flyspell
%%% ispell-local-dictionary: "en_GB"
%%% coding: us-ascii
%%% TeX-master: "../guide.tex"
%%% End:
|