• Tidak ada hasil yang ditemukan

15.5 Internal Macros

15.5.3 Core Name Engine

\@nameauth@IdxPageref Here we set up a local scope because we make changes that would otherwise affect normal nameauthoutput. We redefine\NameauthIndexto print an argument in the text instead of the index, and we force indexing to occur.

376\newcommand*\@nameauth@IdxPageref[3]

377{%

Warn if \SkipIndex was called before\ShowIdxPageref, and reset it.

378 \if@nameauth@SkipIndex

379 \PackageWarning{nameauth}

380 {\string\SkipIndex precedes \string\ShowIdxPageref; check}%

381 \unless\if@nameauth@OldReset

382 \@nameauth@SkipIndexfalse%

383 \fi

384 \fi

Start a local scope to isolate any changes and redefine\NameauthIndex(the index macro hook) to print an entry in the text.

385 \begingroup%

386 \def\NameauthIndex##1{##1}%

387 \@nameauth@DoIndextrue%

We locally delete any tag and xref control sequences as needed. They will be restored when the scope ends. If \ShowIdxPagerefset \@nameauth@LongIdxDebugtruewe produce a full index entry that shows all the tags and the “actual” character as well as the name. Otherwise we produce a short index entry that shows only the name.

388 \@nameauth@Choice{}{}{}%

389 \csundef{\NameauthPattern!PN}%

390 \unless\if@nameauth@LongIdxDebug

391 \csundef{\NameauthPattern!PRE}%

392 \csundef{\NameauthPattern!TAG}%

393 \fi

394 \IndexName[#1]{#2}[#3]%

We close the scope and reset the flags.

395 \endgroup%

396 \global\@nameauth@LongIdxDebugfalse%

397}

If we use\JustIndex then skip everything else. Theoldpassoption restores what we did before version 3.3, where we locally reset\@nameauth@JustIndexfalseand were done. Now, however, the default is a global reset to avoid undocumented behavior.

405 \if@nameauth@JustIndex

406 \IndexName[#1]{#2}[#3]%

407 \if@nameauth@OldPass

408 \@nameauth@JustIndexfalse%

409 \else

410 \if@nameauth@OldReset

411 \@nameauth@FullNamefalse%

412 \@nameauth@FirstNamefalse%

413 \@nameauth@JustIndexfalse%

414 \else

415 \global\@nameauth@FullNamefalse%

416 \global\@nameauth@FirstNamefalse%

417 \global\@nameauth@JustIndexfalse%

418 \fi

419 \fi

420 \else

Create or delete name pattern if directed. Deletion has priority because it occurs after creation. Ensure that names are printed in horizontal mode. Wrap the name with two index entries in case a page break occurs between them.

421 \if@nameauth@Subvert \SubvertName[#1]{#2}[#3]\fi

422 \if@nameauth@Forget \ForgetName[#1]{#2}[#3]\fi

423 \leavevmode\hbox{}%

424 \unless\if@nameauth@SkipIndex \IndexName[#1]{#2}[#3]\fi

425 \if@nameauth@MainFormat

426 \@nameauth@Parse{#1}{#2}{#3}{!MN}%

427 \else

428 \@nameauth@Parse{#1}{#2}{#3}{!NF}%

429 \fi

430 \unless\if@nameauth@SkipIndex \IndexName[#1]{#2}[#3]\fi Reset all the “per name” Boolean values after printing a name. The default is global.

431 \@nameauth@Flags%

432 \fi

433 \@nameauth@Lockfalse%

434 \@nameauth@InNamefalse%

Close the “locked” branch and complete the full stop detection and removal.

435 \fi

436 \if@nameauth@Punct\expandafter\@nameauth@CheckDot\fi

437}

Syntactic Element Layer

\@nameauth@Parse Parse and print a name in the text. The final required argument tells us which naming system we are in (Section6.1). Both\@nameauth@Nameand\AKA call this parser, which only works in a locked state.

438\newcommand\@nameauth@Parse[4]

439{%

440 \if@nameauth@BigLock \@nameauth@Lockfalse\fi

441 \if@nameauth@Lock

Make token register copies of the current name args to be available for the hook macros.

442 \if@nameauth@OldToks

443 \@nameauth@toksa\expandafter{#1}%

444 \@nameauth@toksb\expandafter{#2}%

445 \@nameauth@toksc\expandafter{#3}%

446 \else

447 \global\@nameauth@toksa\expandafter{#1}%

448 \global\@nameauth@toksb\expandafter{#2}%

449 \global\@nameauth@toksc\expandafter{#3}%

450 \fi

If global caps. reversing, and commas are true, set the per-name flags true.

451 \if@nameauth@AllCaps \@nameauth@AllThistrue\fi

452 \if@nameauth@RevAll \@nameauth@RevThistrue\fi

453 \if@nameauth@RevAllComma \@nameauth@RevThisCommatrue\fi

Now we enter a local scope where we can use simple control strings without needing to worry about collisions. We process and load the arguments into the appropriate macros.

454 \begingroup%

455 \def\@nameauth@InParser{}%

456 \@nameauth@LoadArgs{#1}{#2}{#3}%

Copy the protected control sequences to local, unprotected ones.

457 \let\arga\@nameauth@A%

458 \let\rootb\@nameauth@B%

459 \let\suffb\@nameauth@SB%

460 \let\argc\@nameauth@C%

Capitalization on demand in the body text if not in alternate formatting.

461 \if@nameauth@DoCaps

462 \@nameauth@CapArgs{#1}{#2}{#3}%

463 \fi

We capitalize the entire surname when desired; different from above and overrides it.

464 \if@nameauth@AllThis

465 \protected@edef\rootb%

466 {\MakeUppercase{\@nameauth@Root{#2}}}%

467 \fi

Use non-breaking spaces and commas as desired.

468 \@nameauth@AddPunct%

We parse names by attaching “meaning” to patterns of macro arguments primarily via\FNN and\SNN. Then we call the name printing macros, based on optional arguments.

469 \let\SNN\rootb%

470 \@nameauth@Choice

Non-Western names, current syntax. We test\argcand\suffbas needed.

471 {%

472 \ifx\argc\@empty

473 \let\FNN\suffb%

474 \else

475 \let\FNN\argc%

476 \fi

477 \@nameauth@NonWest{\@nameauth@csb#4}%

478 \@nameauth@MakeCS{\@nameauth@csb#4}%

479 }%

Non-Western names, obsolete syntax. Here\argc is significant.

480 {%

481 \let\FNN\argc%

482 \@nameauth@NonWest{\@nameauth@csbc#4}%

483 \@nameauth@MakeCS{\@nameauth@csbc#4}%

484 }%

Western names. We test for\argcand swap it for\argaand account for\suffb.

485 {%

486 \ifx\argc\@empty

487 \let\FNN\arga%

488 \else

489 \let\FNN\argc%

490 \fi

491 \unless\ifx\suffb\@empty

492 \def\SNN{\rootb\Space\suffb}%

493 \if@nameauth@ShortSNN

494 \let\SNN\rootb%

495 \fi

496 \fi

497 \@nameauth@West{\@nameauth@csab#4}%

498 \@nameauth@MakeCS{\@nameauth@csab#4}%

499 }%

We end the local group and reset the flags for name forms here.

500 \endgroup%

501 \if@nameauth@OldReset

502 \@nameauth@FullNamefalse%

503 \@nameauth@FirstNamefalse%

504 \@nameauth@FirstFormatfalse%

505 \else

506 \global\@nameauth@FullNamefalse%

507 \global\@nameauth@FirstNamefalse%

508 \global\@nameauth@FirstFormatfalse%

509 \fi

510 \fi

511}

Name Display Layer

\@nameauth@NonWest Arrange forms of non-Western names. We inherit macros from the parser and only use this macro in the local scope of the parser.

512\newcommand*\@nameauth@NonWest[1]

513{%

514 \ifdefined\@nameauth@InParser

515 \@nameauth@Form{#1}%

516 \ifx\FNN\@empty

517 \@nameauth@Hook{\SNN}%

518 \else

519 \if@nameauth@FullName

520 \if@nameauth@RevThis

521 \@nameauth@Hook{\FNN\Space\SNN}%

522 \else

523 \@nameauth@Hook{\SNN\Space\FNN}%

524 \fi

525 \else

526 \if@nameauth@FirstName

527 \if@nameauth@EastFN

528 \@nameauth@Hook{\FNN}%

529 \else

530 \@nameauth@Hook{\SNN}%

531 \fi

532 \else

533 \@nameauth@Hook{\SNN}%

534 \fi

535 \fi

536 \fi

537 \fi

538}

\@nameauth@West Arrange forms of Western names and “non-native” Eastern names. We inherit macros from the parser and only use this macro in the local scope of the parser.

539\newcommand*\@nameauth@West[1]

540{%

541 \ifdefined\@nameauth@InParser

542 \@nameauth@Form{#1}%

543 \edef\RevSpace{,\SpaceW}%

544 \if@nameauth@FullName

545 \if@nameauth@RevThis

546 \@nameauth@Hook{\SNN\SpaceW\FNN}%

547 \else

548 \if@nameauth@RevThisComma

549 \@nameauth@Hook{\SNN\RevSpace\FNN}%

550 \else

551 \@nameauth@Hook{\FNN\SpaceW\SNN}%

552 \fi

553 \fi

554 \else

555 \if@nameauth@FirstName

556 \@nameauth@Hook{\FNN}%

557 \else

558 \@nameauth@Hook{\rootb}%

559 \fi

560 \fi

561 \fi

562}

\@nameauth@Form Set up the flags per the formatting rules for first, subsequent, long, and short uses. We only use this macro in the local scope of the parser.

563\newcommand*\@nameauth@Form[1]

564{%

565 \ifdefined\@nameauth@InParser

If the name does not exist yet or if thealwaysformatoption is used, force first-use formatting, force a long name, and inhibit a short name.

566 \unless\ifcsname#1\endcsname

567 \@nameauth@FirstFormattrue%

568 \@nameauth@FullNametrue%

569 \@nameauth@FirstNamefalse%

570 \else

571 \if@nameauth@AlwaysFormat\@nameauth@FirstFormattrue\fi

572 \fi

If we are not in\AKA, if a short name form is desired, inhibit a long form.

573 \unless\if@nameauth@InAKA

574 \if@nameauth@FirstName\@nameauth@FullNamefalse\fi

575 \else

If we are in\AKAuse special formatting rules.\AKA* acts like\FName, while\AKAacts like

\Name*. Both prefer using the subsequent-use hooks unless theformatAKA option or the alwaysformatoption are used.

576 \if@nameauth@AltAKA

577 \if@nameauth@OldAKA\@nameauth@EastFNtrue\fi

578 \@nameauth@FullNamefalse%

579 \@nameauth@FirstNametrue%

580 \else

581 \@nameauth@FullNametrue%

582 \@nameauth@FirstNamefalse%

583 \fi

584 \unless\if@nameauth@AlwaysFormat

585 \unless\if@nameauth@AKAFormat

586 \@nameauth@FirstFormatfalse%

587 \fi

588 \fi

589 \fi

590 \fi

591}

Format Hook Dispatcher

\@nameauth@Hook Boolean flags control which hook is called (first/subsequent use, name type). We only use this macro in the local scope of the parser.

592\newcommand*\@nameauth@Hook[1]

593{%

594 \ifdefined\@nameauth@InParser

We tell the formatting hooks that they are in the hook dispatcher to enable alternate formatting. We test the printed name form to see if it has a trailing full stop. The flag

\if@nameauth@InHookwill reset outside of the local scope in\@nameauth@Parse.

595 \@nameauth@InHooktrue%

596 \protected@edef\test{#1}%

597 \expandafter\@nameauth@TestDot\expandafter{\test}%

598 \if@nameauth@MainFormat

We use the formatting hooks for the main-matter system.

599 \if@nameauth@FirstFormat

600 \bgroup\NamesFormat{#1}\egroup%

601 \else

602 \bgroup\MainNameHook{#1}\egroup%

603 \fi

604 \else

We use the formatting hooks for the front-matter system.

605 \if@nameauth@FirstFormat

606 \bgroup\FrontNamesFormat{#1}\egroup%

607 \else

608 \bgroup\FrontNameHook{#1}\egroup%

609 \fi

610 \fi

611 \fi

612}