From e0c6872cf40896c7be36b11dcc744620f10adf1d Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Mon, 2 Sep 2019 13:46:59 +0900 Subject: Initial commit --- macros/latex/contrib/ncctools/README | 59 + macros/latex/contrib/ncctools/doc/afterpackage.pdf | Bin 0 -> 84330 bytes macros/latex/contrib/ncctools/doc/changes.txt | 438 +++ macros/latex/contrib/ncctools/doc/dcounter.pdf | Bin 0 -> 103989 bytes macros/latex/contrib/ncctools/doc/desclist.pdf | Bin 0 -> 95911 bytes macros/latex/contrib/ncctools/doc/extdash.pdf | Bin 0 -> 205012 bytes macros/latex/contrib/ncctools/doc/manyfoot.pdf | Bin 0 -> 296617 bytes macros/latex/contrib/ncctools/doc/mboxfill.pdf | Bin 0 -> 84823 bytes macros/latex/contrib/ncctools/doc/nccbbb.pdf | Bin 0 -> 78308 bytes macros/latex/contrib/ncctools/doc/nccboxes.pdf | Bin 0 -> 108581 bytes macros/latex/contrib/ncctools/doc/ncccomma.pdf | Bin 0 -> 78184 bytes macros/latex/contrib/ncctools/doc/ncccropbox.pdf | Bin 0 -> 86468 bytes macros/latex/contrib/ncctools/doc/ncccropmark.pdf | Bin 0 -> 85168 bytes macros/latex/contrib/ncctools/doc/nccfancyhdr.pdf | Bin 0 -> 168515 bytes macros/latex/contrib/ncctools/doc/nccfloats.pdf | Bin 0 -> 132566 bytes macros/latex/contrib/ncctools/doc/nccfoots.pdf | Bin 0 -> 83327 bytes macros/latex/contrib/ncctools/doc/nccmath.pdf | Bin 0 -> 181854 bytes macros/latex/contrib/ncctools/doc/nccparskip.pdf | Bin 0 -> 76267 bytes macros/latex/contrib/ncctools/doc/nccpic.pdf | Bin 0 -> 97682 bytes macros/latex/contrib/ncctools/doc/nccrules.pdf | Bin 0 -> 109316 bytes macros/latex/contrib/ncctools/doc/nccsect.pdf | Bin 0 -> 239672 bytes macros/latex/contrib/ncctools/doc/nccstretch.pdf | Bin 0 -> 85209 bytes macros/latex/contrib/ncctools/doc/nccthm.pdf | Bin 0 -> 160456 bytes macros/latex/contrib/ncctools/doc/ncctools.pdf | Bin 0 -> 75505 bytes macros/latex/contrib/ncctools/doc/textarea.pdf | Bin 0 -> 92358 bytes macros/latex/contrib/ncctools/doc/tocenter.pdf | Bin 0 -> 93765 bytes macros/latex/contrib/ncctools/doc/topsection.pdf | Bin 0 -> 86506 bytes macros/latex/contrib/ncctools/doc/watermark.pdf | Bin 0 -> 93299 bytes macros/latex/contrib/ncctools/source/README | 103 + .../latex/contrib/ncctools/source/afterpackage.dtx | 118 + macros/latex/contrib/ncctools/source/dcounter.dtx | 337 +++ macros/latex/contrib/ncctools/source/desclist.dtx | 157 + macros/latex/contrib/ncctools/source/extdash.dtx | 329 +++ macros/latex/contrib/ncctools/source/manifest.txt | 42 + macros/latex/contrib/ncctools/source/manyfoot.dtx | 1521 ++++++++++ macros/latex/contrib/ncctools/source/mboxfill.dtx | 131 + macros/latex/contrib/ncctools/source/nccbbb.dtx | 94 + macros/latex/contrib/ncctools/source/nccboxes.dtx | 428 +++ macros/latex/contrib/ncctools/source/ncccomma.dtx | 101 + .../latex/contrib/ncctools/source/ncccropbox.dtx | 167 ++ .../latex/contrib/ncctools/source/ncccropmark.dtx | 156 + .../latex/contrib/ncctools/source/nccfancyhdr.dtx | 1056 +++++++ macros/latex/contrib/ncctools/source/nccfloats.dtx | 647 +++++ macros/latex/contrib/ncctools/source/nccfoots.dtx | 95 + macros/latex/contrib/ncctools/source/nccmath.dtx | 1186 ++++++++ .../latex/contrib/ncctools/source/nccparskip.dtx | 85 + macros/latex/contrib/ncctools/source/nccpic.dtx | 254 ++ macros/latex/contrib/ncctools/source/nccrules.dtx | 400 +++ macros/latex/contrib/ncctools/source/nccsect.dtx | 3036 ++++++++++++++++++++ .../latex/contrib/ncctools/source/nccstretch.dtx | 75 + macros/latex/contrib/ncctools/source/nccthm.dtx | 1111 +++++++ macros/latex/contrib/ncctools/source/ncctools.ins | 78 + macros/latex/contrib/ncctools/source/ncctools.tex | 299 ++ macros/latex/contrib/ncctools/source/textarea.dtx | 236 ++ macros/latex/contrib/ncctools/source/tocenter.dtx | 315 ++ .../latex/contrib/ncctools/source/topsection.dtx | 133 + macros/latex/contrib/ncctools/source/watermark.dtx | 217 ++ 57 files changed, 13404 insertions(+) create mode 100644 macros/latex/contrib/ncctools/README create mode 100644 macros/latex/contrib/ncctools/doc/afterpackage.pdf create mode 100644 macros/latex/contrib/ncctools/doc/changes.txt create mode 100644 macros/latex/contrib/ncctools/doc/dcounter.pdf create mode 100644 macros/latex/contrib/ncctools/doc/desclist.pdf create mode 100644 macros/latex/contrib/ncctools/doc/extdash.pdf create mode 100644 macros/latex/contrib/ncctools/doc/manyfoot.pdf create mode 100644 macros/latex/contrib/ncctools/doc/mboxfill.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccbbb.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccboxes.pdf create mode 100644 macros/latex/contrib/ncctools/doc/ncccomma.pdf create mode 100644 macros/latex/contrib/ncctools/doc/ncccropbox.pdf create mode 100644 macros/latex/contrib/ncctools/doc/ncccropmark.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccfancyhdr.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccfloats.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccfoots.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccmath.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccparskip.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccpic.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccrules.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccsect.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccstretch.pdf create mode 100644 macros/latex/contrib/ncctools/doc/nccthm.pdf create mode 100644 macros/latex/contrib/ncctools/doc/ncctools.pdf create mode 100644 macros/latex/contrib/ncctools/doc/textarea.pdf create mode 100644 macros/latex/contrib/ncctools/doc/tocenter.pdf create mode 100644 macros/latex/contrib/ncctools/doc/topsection.pdf create mode 100644 macros/latex/contrib/ncctools/doc/watermark.pdf create mode 100644 macros/latex/contrib/ncctools/source/README create mode 100644 macros/latex/contrib/ncctools/source/afterpackage.dtx create mode 100644 macros/latex/contrib/ncctools/source/dcounter.dtx create mode 100644 macros/latex/contrib/ncctools/source/desclist.dtx create mode 100644 macros/latex/contrib/ncctools/source/extdash.dtx create mode 100644 macros/latex/contrib/ncctools/source/manifest.txt create mode 100644 macros/latex/contrib/ncctools/source/manyfoot.dtx create mode 100644 macros/latex/contrib/ncctools/source/mboxfill.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccbbb.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccboxes.dtx create mode 100644 macros/latex/contrib/ncctools/source/ncccomma.dtx create mode 100644 macros/latex/contrib/ncctools/source/ncccropbox.dtx create mode 100644 macros/latex/contrib/ncctools/source/ncccropmark.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccfancyhdr.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccfloats.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccfoots.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccmath.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccparskip.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccpic.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccrules.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccsect.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccstretch.dtx create mode 100644 macros/latex/contrib/ncctools/source/nccthm.dtx create mode 100644 macros/latex/contrib/ncctools/source/ncctools.ins create mode 100644 macros/latex/contrib/ncctools/source/ncctools.tex create mode 100644 macros/latex/contrib/ncctools/source/textarea.dtx create mode 100644 macros/latex/contrib/ncctools/source/tocenter.dtx create mode 100644 macros/latex/contrib/ncctools/source/topsection.dtx create mode 100644 macros/latex/contrib/ncctools/source/watermark.dtx (limited to 'macros/latex/contrib/ncctools') diff --git a/macros/latex/contrib/ncctools/README b/macros/latex/contrib/ncctools/README new file mode 100644 index 0000000000..0d411966bf --- /dev/null +++ b/macros/latex/contrib/ncctools/README @@ -0,0 +1,59 @@ +README for the `ncctools' distribution +====================================== + +This `bundle' consists of LaTeX2e packages written and supported by +Alexander I. Rozhenko. + +Copyright is maintained by Alexander I. Rozhenko. + +The `source' subdirectory contains source codes for all packages of +the bundle prepared in `.dtx' files, and some auxiliary files. +See the `source/manifext.txt' file. + +The `doc' subdirectory contains pdf documentation to all packages. +The `doc/ncctools.pdf' file gives a brief introduction to +all packages of the bundle. Opening it with Adobe Reader, +you can click on a package name at the margin and the +documentation to the package will be shown. + +Additional information on the bundle can be found in the +`source/README' file. + + +License Agreement +================= + +This material is subject to the LaTeX Project Public License. +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +for the details of that license. + + +Reporting Bugs +============== + +To report a problem or bug in any of these packages, describe it in free +form and send it me to e-mail address + + rozhenko@oapmg.sscc.ru + +Type the `NCCTOOLS' word in the subject of letter. This guarantees +that your letter will be not deleted as spam. + +When reporting bugs, please produce a small test file that shows the +problem, and ensure that you are using the current version of the +package, and of the base LaTeX software. + + +Distribution of unchanged versions +================================== + +It is allowed provided that the contents of `source' subdirectory +is included into distribution as is. The files from other +subdirectories and these file also are optional. The decision to +include optional files is up to your choice. + + +Distribution of changed versions +================================ + +It is allowed under restrictions described in the `source/README' file. diff --git a/macros/latex/contrib/ncctools/doc/afterpackage.pdf b/macros/latex/contrib/ncctools/doc/afterpackage.pdf new file mode 100644 index 0000000000..92ea213747 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/afterpackage.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/changes.txt b/macros/latex/contrib/ncctools/doc/changes.txt new file mode 100644 index 0000000000..025e210c27 --- /dev/null +++ b/macros/latex/contrib/ncctools/doc/changes.txt @@ -0,0 +1,438 @@ + +This file lists changes to the LaTeX2e files of `ncctools' bundle in +reverse chronological order. + +======================================================================= + +August 3, 2019 (Release 3.5.3) + + manyfoot: Fix multicol compatibility issues. + + +======================================================================= + +June 24, 2018 (Release 3.5.2) + + extdash: Add more em-dash configuring options. +======================================================================= + +Jan 20, 2006 + + nccsect: Improve \NCC@secflush code to work in rightlast style. + + nccmath: Introduce \dmulticolumn to use within darray. + +======================================================================= + +Jan 19, 2006 (Release 3.5) + + nccsect: Allow caption width be greater than the line width. + Smart overlapping technique is used for such captions. + Compatibility with the `xtab' package added. + The \newplainsectionstyle and \newhangsectionstyle + commands are introduced. The predefined section styles are + reimplemented on the base of new section style definitions. + The `centerlast' section style is introduced. The + \adjustsectionmargins command is introduced. Introduce + customization of suffices after section and caption tags + with \sectiontagsuffix and \captiontagsuffix commands. + +Jan 17, 2006 + + afterpackage: Renamed from `addtopackage' package. Its command + \AddToPackage is also renamed to \AfterPackage. + + nccsect: Changes concerning with renaming the `addtopackage' package. + + nccthm: Fix bug in nccthm.dtx -- remove strings concerning to + `defaults' package inserted in experiments with the package. + + +Jan 07, 2006 + + nccfloats: Expand the syntax of \FloatStyle with optional float-type + parameter. Apply float style to the base floating + environment. Introduce the generic \newminifloat + command. + +Jan 06, 2006 + + nccsect: Introduce \SetTOCStyle and \ChapterPrefixStyle commands. + They were moved from the `nccdefaults' of the `ncclatex' + bundle. + +======================================================================= + +Jan 03, 2006 (Release 3.4) + + nccsect: The \norunningsuffix modifier is introduced. It is applied + just in a parameter of running section to remove the suffix + after it. + +Jan 01, 2006 + + nccsect: Introduce \RunningSectionSuffix command. + Introduce \NCC@preparesectag and \NCC@preparetocnum hooks. + Remove \NCC@defaultsectag command, because it is useless now. + +Dec 31, 2005 + + nccsect: Insert three more hooks. Fix bugs concerned to + \MakeUppercase in section and toc style declarations. + +Dec 30, 2005 + + nccsect: Insert many hooks to simplify customization of commands. + Make all command names except user's level names (\part, + \chapter, etc.) completely independent on standard names + of LaTeX's commands. This fixes the compatibility with + `hyperref' bug. + +Dec 29, 2005 + + nccsect: Introduce the \aftersectionvspace command. + Add the \DeclarePart and \DeclareTOCPart commands. + +Dec 28, 2005 + + nccsect: Extend the syntax of \sectionstyle command. It now contains + an optional `type' parameter to specify particular styles + for section levels. The scope of prefix in \DeclareSection + is now limited with the section number only. New section + styles: hangparindent and hangparindent*. + +Dec 26, 2005 + + textarea: A new package. It allows expand the text area of a document + on other areas: footer, header, and margin. There are two + ways for such expansion -- temporary expansion of a current + page on the header using a special negative vertical skip, + or global change of page layout parameters with possibility + of later restoration them to the original values. + + nccsect: Apply conditional definition of \StartFromTextArea and + \StartFromHeaderArea for compatibility with the `textarea' + package. + +Dec 25, 2005 + + addtopackage: A new package. It supports customization of default + settings in packages without their loading. + +Dec 24, 2005 + + topsection: A new package. It implements an unnumbered top-level + section (\chapter in books and reports or \section in + articles) in class-independent way. Such a section is + used as a title for standard document sections such as + table of contents, index, bibliography. Using this + command allows simplify the definition or redefinition + of standard document environments. + +======================================================================= + +Sep 11, 2005 (Release 3.3) + + manyfoot: Improve calculations of the fudge factor in para-footnotes + to remove overflow when baseline skip in footnotes is + greater or equal to 16pt. The improved algorithm now works + till 64pt. + +======================================================================= + +Jun 15, 2005 (Release 3.2) + + nccsect: Fixed bug in \DeclareTOCEntry concerning with \applystyle + command. + +======================================================================= + +Jun 08, 2005 (Release 3.1) + + nccsect: Fix \beforechapter hook to allow \part command in it. + +Jun 07, 2005 + + ncccropmark: Minor changes in documentation. + +May 22, 2005 + + nccsect: Introduce \captionstyle, \captiontagstyle, and + \captionwidth commands. Add \TOCMarginDrift command. + Allow use the \applystyle command in TOC-entry style. + +May 21, 2005 + + nccsect: Introduce \epigraph and \epigraphparameters commands. + +May 20, 2005 + + nccsect: Introduce \beforechapter hook. Add commands + \StartFromTextArea and \StartFromHeaderArea + (they were moved from the ncc class) + +May 13, 2005 + + `mboxfill' and `nccrules' packages are introduced. + +May 11, 2005 + + manyfoot: The \SetFootnoteHook command is introduced. + +Apr 25, 2005 + + dcounter: Emulate the dynamic style for existing counters declared + as dynamic ones. + +Apr 15, 2005 + + nccsect: Emulate the \@makecaption command for compatibility with + packages using it. Provide compatibility with the + `supertabular' and `longtable' packages. + +Mar 06, 2005 + + nccpic: Correct extension lists. + +Feb 21, 2005 + + nccmath: Improve `darray' to avoid conflict with the `array' package. + +Feb 16, 2005 + + nccmath: New medium-size math commands: \medmath, \medop, \medint, + \medintcorr, \mfrac, \mbinom. New medium-size environments: + medsize and mmatrix. Introduce the `mediummath' option. + Remove redefinition of equation tag. + +Feb 10, 2005 + + manyfoot: Replace \NCC@makemark with \NCC@makefnmark. + ncccomma: A new package implements the smart math comma. + +Feb 07, 2005 + + nccboxes: Add \tc command; allow lengths in the \Strut's parameter. + +Feb 03, 2005 + + nccfoots: Rename \NCC@makemark with \NCC@makefnmark to avoid + conflicts with the `nccsect' package using another command with + the same name (this was a bug). + +Jan 29, 2005 + + extdash: Change spaces surround em-dash: decrease space before and + increase space after to remove visual effect of larger space before + the em-dash. + +======================================================================= + +Dec 17, 2004 (Release 3.0) + + Prepare the short guide ncctools.tex. + +Dec 16, 2004 + + nccthm: revise the package and finish documenting it. + +Dec 12, 2004 + + nccsect: revise the package and finish documenting it. + + +Dec 09, 2004 + + Prepare self-documented code for the nccpic, tocenter, and watermark + packages. + +Dec 08, 2004 + + Prepare self-documented code for the nccparskip package. + + nccmath: revise the package, do \fleqn and \ceqn working with + all display equations, finish documenting the package. + +Dec 07, 2004 + + nccfancyhdr: revise the package, introduce \newpagestyle and floats + testing commands, finish documenting the package. + +Dec 05, 2004 + + nccfloats: Improve calculation of width parameters (units are + allowed now). Prepare self-documented code for the package. + +Nov 30, 2004 + + Introduce a new package nccstretch. It allows stretch a text + with something inserted between tokens. + +Nov 29, 2004 + + Prepare self-documented code for the ncccropmark package. + +Nov 28, 2004 + + Prepare self-documented code for the nccboxes package. + +Nov 24, 2004 + + Prepare self-documented code for the nccbbb and ncccropbox packages. + +Nov 23, 2004 + + Prepare self-documented code for the desclist package. + + Minor corrections in documentation to dcounter, extdash, manyfoot, + and nccfoot packages. + +======================================================================= + +Sep 20, 2004 (Release 2.08) + + manyfoot: Version 1.7. The \ExtraParaSkip command introduced. + +Sep 04, 2004 + + nccpic: Patch for bounding box calculation added. If a graphics + rule requires calculations of bounding box via external file, + non-existance of the required file does not lead to LaTeX error + if the size of graphics is specified in another way (for example, + \includegraphics[width=..., height=...]{filename} is enough in + this case). + +======================================================================= + +Apr 08, 2004 (Release 2.07) + + nccthm: Improvements in interpreting spaces after labels + +======================================================================= + +May 12, 2003 (Release 2.06) + + manyfoot: Version 1.6. Compatibility with footmisc improved: + Restore \footnotemargin support that was occasionally removed. + Add support for multiple option from footmisc + +======================================================================= + +Apr 04, 2003 (Release 2.05) + + watermark: hbox underfull removed in empty and plain page styles + +Apr 02, 2003 + + manyfoot: Version 1.5 prepared. \DeclareNewFootnote command introduced. + Compatibility with footmisc improved. Selection of custom footnote rules + added. Perpage footnote numbering option added. + +Jan 13, 2003 + + nccthm: space after label in theorems is ignored now. + +May 24, 2002 + + nccboxes: bug in \jparbox fixed + +May 22, 2002 + + nccsect: centering in captions works again. + +======================================================================= + +May 19, 2002 (Release 2.04) + + nccthm: an extra group added in theorem headers to scope font changes + + nccsect: internal changes in making captions (vertical skips are + moved after style settings to allow use the relative units in them, + e.g. 1ex or 1em) + +May 17, 2002 + + Handling of side floats is improved in `nccfloats' package. + In the new version, a strut before the side float is not necessary, + \noindent is allowed at the beginning of side float's text, and + final strut is inserted at the end of side float's text in horizontal + mode only. + +======================================================================= + +Mar 23, 2002 (Release 2.03) + + The `nccfloats' package is introduced. It covers LaTeX's floats with + some service commands (minifloats and side floats). + +Mar 20, 2002 + + The `nccboxes' package modified: internal changes in the \jvbox command + and the \jparbox is introduced. + + The \draftgraphics and \finalgrapgics commands are introduced in the + `nccpic' package to toggle draft/final mode for graphics independently + on draft/final mode of entire document. In draft mode, graphics are shown + as framed boxes with file name marks. + +Mar 16, 2002 + + The \useshortskip command is introduced in `nccmath' package. + +Feb 19, 2002 + + Commands \Eq, \Eqs, and \Eqalign are removed from `nccmath' package. + They are moved to obsolete commands in the `ncclatex' bungle. + \mop command is also removed from `nccmath' package (it is introduced + in the `ncclatex' package of the `ncclatex' bungle now). + +Feb 17, 2002 + + Options of the `nccpic' package are passed now to the graphicx package. + Internal modifications in the `nccthm' package. + +Feb 13, 2002 + + The bug concerning with \noheadingtag is fixed in `nccsect' package. + The hbox underful in \thispageheading{} with empty parameter is + suppressed in `watermark' package. + +Feb 08, 2002 + + Internal change in `nccsect' package: the \NCC@thetocchapter hook + introduced. + +======================================================================= + +Feb 08 2002 (Release 2.02) + + The packages `cropbox' and `cropmark' are renamed to + `ncccropbox' and `ncccropmark' to avoid possible name conflicts. + +Feb 07, 2002 + + The \fancycenter command is introduced in `nccfancyhdr' package. + Header and footer struts are moved out of parboxes they were before. + +======================================================================= + +Feb 07, 2002 (Release 2.01) + + The `parskip' package is renamed to `nccparskip' to avoid conflicts + with already existing `parskip' package + +======================================================================= + +Feb 01, 2002 (Release 2.0) + + The release 2.0 of `ncctools' bundle is completed. The following + packages are added: cropbox, cropmark, desclist, nccbbb, nccboxes, + nccfancyhdr, nccmath, nccpic, nccsect, nccthm, parskip, tocenter, + watermark. + +======================================================================= + +Dec 20, 1998 (Release 1.0) + + The initial version of `ncctools' bundle is completed. It contains + 4 packages: dcounter, extdash, manyfoot, nccfoots. diff --git a/macros/latex/contrib/ncctools/doc/dcounter.pdf b/macros/latex/contrib/ncctools/doc/dcounter.pdf new file mode 100644 index 0000000000..0e283d5fa2 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/dcounter.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/desclist.pdf b/macros/latex/contrib/ncctools/doc/desclist.pdf new file mode 100644 index 0000000000..c8c3bf3caa Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/desclist.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/extdash.pdf b/macros/latex/contrib/ncctools/doc/extdash.pdf new file mode 100644 index 0000000000..1c68cbeec1 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/extdash.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/manyfoot.pdf b/macros/latex/contrib/ncctools/doc/manyfoot.pdf new file mode 100644 index 0000000000..477fec1800 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/manyfoot.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/mboxfill.pdf b/macros/latex/contrib/ncctools/doc/mboxfill.pdf new file mode 100644 index 0000000000..860494c483 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/mboxfill.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccbbb.pdf b/macros/latex/contrib/ncctools/doc/nccbbb.pdf new file mode 100644 index 0000000000..8a5d8482b2 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccbbb.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccboxes.pdf b/macros/latex/contrib/ncctools/doc/nccboxes.pdf new file mode 100644 index 0000000000..8cfec11222 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccboxes.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/ncccomma.pdf b/macros/latex/contrib/ncctools/doc/ncccomma.pdf new file mode 100644 index 0000000000..26b60fbd06 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/ncccomma.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/ncccropbox.pdf b/macros/latex/contrib/ncctools/doc/ncccropbox.pdf new file mode 100644 index 0000000000..cee716df7b Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/ncccropbox.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/ncccropmark.pdf b/macros/latex/contrib/ncctools/doc/ncccropmark.pdf new file mode 100644 index 0000000000..4a8094033e Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/ncccropmark.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccfancyhdr.pdf b/macros/latex/contrib/ncctools/doc/nccfancyhdr.pdf new file mode 100644 index 0000000000..83fd9ef325 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccfancyhdr.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccfloats.pdf b/macros/latex/contrib/ncctools/doc/nccfloats.pdf new file mode 100644 index 0000000000..6adf235b4f Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccfloats.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccfoots.pdf b/macros/latex/contrib/ncctools/doc/nccfoots.pdf new file mode 100644 index 0000000000..5c18afa726 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccfoots.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccmath.pdf b/macros/latex/contrib/ncctools/doc/nccmath.pdf new file mode 100644 index 0000000000..786bc2c198 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccmath.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccparskip.pdf b/macros/latex/contrib/ncctools/doc/nccparskip.pdf new file mode 100644 index 0000000000..8b48dd0243 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccparskip.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccpic.pdf b/macros/latex/contrib/ncctools/doc/nccpic.pdf new file mode 100644 index 0000000000..726f2b3417 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccpic.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccrules.pdf b/macros/latex/contrib/ncctools/doc/nccrules.pdf new file mode 100644 index 0000000000..a1fa4963a9 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccrules.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccsect.pdf b/macros/latex/contrib/ncctools/doc/nccsect.pdf new file mode 100644 index 0000000000..1bb4c2344f Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccsect.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccstretch.pdf b/macros/latex/contrib/ncctools/doc/nccstretch.pdf new file mode 100644 index 0000000000..80a0232c10 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccstretch.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/nccthm.pdf b/macros/latex/contrib/ncctools/doc/nccthm.pdf new file mode 100644 index 0000000000..042889ba19 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/nccthm.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/ncctools.pdf b/macros/latex/contrib/ncctools/doc/ncctools.pdf new file mode 100644 index 0000000000..aa810b2bac Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/ncctools.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/textarea.pdf b/macros/latex/contrib/ncctools/doc/textarea.pdf new file mode 100644 index 0000000000..f43f029122 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/textarea.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/tocenter.pdf b/macros/latex/contrib/ncctools/doc/tocenter.pdf new file mode 100644 index 0000000000..bac4cb28a0 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/tocenter.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/topsection.pdf b/macros/latex/contrib/ncctools/doc/topsection.pdf new file mode 100644 index 0000000000..eff6c22222 Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/topsection.pdf differ diff --git a/macros/latex/contrib/ncctools/doc/watermark.pdf b/macros/latex/contrib/ncctools/doc/watermark.pdf new file mode 100644 index 0000000000..1f7c3408cb Binary files /dev/null and b/macros/latex/contrib/ncctools/doc/watermark.pdf differ diff --git a/macros/latex/contrib/ncctools/source/README b/macros/latex/contrib/ncctools/source/README new file mode 100644 index 0000000000..bf152a0bea --- /dev/null +++ b/macros/latex/contrib/ncctools/source/README @@ -0,0 +1,103 @@ +README for the `ncctools' bundle +================================ + +This `bundle' consists of LaTeX2e packages written and supported by +Alexander I. Rozhenko. + +The documented source code of all packages is in files with extension +`.dtx'. To install the bungle, run + + latex ncctools.ins + +It will produce the package files from all `.dtx' files. +The files with extensions `.sty' should then be moved to a directory +on LaTeX's standard input path. + +License Agreement +================= + +This material is subject to the LaTeX Project Public License. +See http://www.ctan.org/tex-archive/help/Catalogue/licenses.lppl.html +for the details of that license. + +NOTE (docstrip version) +*********************** +**** +**** If latex ncctools.ins +**** produces the `docstrip interactive mode' prompt: +**** +**** * First type the extension of your input file(s): * +**** \infileext= +**** +**** Then your version of docstrip is too old. +**** Quit (eg by hitting `enter' to all questions) and get a newer +**** docstrip.tex. It must be at least version 2.4. +**** +**** A suitable docstrip.tex may be found from `CTAN' archives such as +**** ftp.dante.de tex-archive/macros/latex/unpacked/docstrip.tex +**** +**** Docstrip is part of the base LaTeX distribution, so if you have +**** an old docstrip then your LaTeX is out of date and you may consider +**** getting the whole of that directory and re-installing LaTeX. +**** However you need to fetch only the file docstrip.tex to unpack +**** this tools distribution with your existing format. + + +Documentation for the individual documented packages may then be +obtained by running LaTeX on the `.dtx' files. + +For example: + + latex manyfoot.dtx + +will produce the file manyfoot.dvi, documenting the manyfoot package. + +***NOTE**** +Copyright is maintained by Alexander I. Rozhenko. + +All the packages in this bundle are released under the restrictions +detailed below. + +The file manifest.txt contains a list of files in the distribution. + + +Reporting Bugs +============== + +To report a problem or bug in any of these packages, describe it in free +form and send it me to e-mail address + + rozhenko@oapmg.sscc.ru + +Type the `NCCTOOLS' word in the subject of letter. This guarantees +that your letter will be not deleted as spam. + +When reporting bugs, please produce a small test file that shows the +problem, and ensure that you are using the current version of the +package, and of the base LaTeX software. + + +Distribution of unchanged versions +================================== + + Redistribution of unchanged files is allowed provided that this + readme file is included and all the files for a package are + distributed together. + +Generation and distribution of changed versions +=============================================== + + The generation of changed versions of the files included in these + packages is allowed under the restrictions listed in the file + legal.txt in the base LaTeX distribution. In particular you should: + + - rename the file before you make any changes to it. + + - change the error report address so that I do not get sent error + reports for files *not* maintained by me. + + The distribution of changed versions of the files included in these + packages is allowed under the restrictions listed in the file + legal.txt in the base LaTeX distribution. In particular you should: + + - also distribute the unmodified version of the file. diff --git a/macros/latex/contrib/ncctools/source/afterpackage.dtx b/macros/latex/contrib/ncctools/source/afterpackage.dtx new file mode 100644 index 0000000000..4fbd30ce14 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/afterpackage.dtx @@ -0,0 +1,118 @@ +% \iffalse +%% +%% File: afterpackage.dtx Copyright (C) 2005, 2006 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{afterpackage} +% [2006/01/17 v1.1 Apply Commands After Package (NCC)] +% +% \changes{v1.0}{2005/12/25}{Initial version} +% \changes{v1.1}{2006/01/17}{The package renamed to `afterpackage'} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{afterpackage} +\GetFileInfo{afterpackage.sty} +\begin{document} +\title{The \textsf{afterpackage} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{afterpackage.dtx} +\end{document} +% +% \fi +% The package allows specify what additional commands should be applied +% to a package after its loading. To describe the usability of +% the package, consider the task of customization of a number of +% packages. Let we need to apply some package-specific code after loading +% packages such as customization of their defaults or hooks. +% To do this, we need to load all required packages and then apply the +% related staff to them. But, sometimes loading of all required packages is +% impossible or unnecessary because packages can have options or some of +% customized packages are rarely useful. +% +% The main idea of using this package is to specify how other packages +% can be customized in such a way that their customization is applied when +% and if customized packages are loaded. All the customization is applied +% in the preamble only. +% +% \DescribeMacro\AfterPackage +% To customize a package, load the \textbf{afterpackage} package and +% insert any number of the following commands anywhere in the preamble: +% \begin{quote} +% |\AfterPackage|\marg{package name}\marg{commands} +% \end{quote} +% The command works as follows: it tests the required package to be +% already loaded; if the package is loaded, it directly applies \meta{commands}; +% otherwise, it collects \meta{commands} in a special macro. The specified +% macro will be applied later when the respective package will be loaded. +% This operation is executed when the package loading finishes and all +% end-of-package hooks are applied. So, the \meta{commands} are applied +% \emph{after the end} of respective package. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\AfterPackage} +% The command tests the |\ver@|\meta{filename} command to be +% defined and considers either collect commands in a special macro +% or apply them directly. +% \begin{macrocode} +%<*package> +\newcommand*\AfterPackage[1]{% + \expandafter\ifx\csname ver@#1.\@pkgextension\endcsname\relax + \@ifundefined{#1.\@pkgextension-@dd}{% + \expandafter\let\csname#1.\@pkgextension-@dd\endcsname\@empty + \expandafter\@onlypreamble\csname#1.\@pkgextension-@dd\endcsname + }{}% + \wlog{After Package Info: Collect commands for #1\on@line}% + \def\@tempa{% + \expandafter\g@addto@macro\csname#1.\@pkgextension-@dd\endcsname}% + \else + \ATP@apply@info{#1}% + \let\@tempa\@firstofone + \fi + \@tempa +} +\@onlypreamble\AfterPackage +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\@popfilename} +% To apply collected commands to a package, we use the |\@popfilename| hook. +% This hook is applied after loading a package. It pops a name of previous +% package or class which was active before loading a package. We save +% the original value of |\@popfilename| hook in a special macro and +% redefine it to execute the |\|\meta{filename}|-@dd| hook before pop of +% the previous filename. +% \begin{macrocode} +\let\ATP@popfilename\@popfilename +\@onlypreamble\ATP@popfilename +\def\@popfilename{% + \@ifundefined{\@currname.\@currext-@dd}{}{% + \ATP@apply@info{\@currname}% + \csname\@currname.\@currext-@dd\endcsname + \expandafter\let\csname\@currname.\@currext-@dd\endcsname\relax + }% + \ATP@popfilename +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ATP@apply@info} +% This information message is logged when commands are applied. Its parameter +% contains a name of package which commands are customized. +% \begin{macrocode} +\def\ATP@apply@info#1{% + \wlog{After Package Info: Apply commands to #1\on@line}% +} +\@onlypreamble\ATP@apply@info +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/dcounter.dtx b/macros/latex/contrib/ncctools/source/dcounter.dtx new file mode 100644 index 0000000000..785ce5d911 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/dcounter.dtx @@ -0,0 +1,337 @@ +% \iffalse +%% +%% File: dcounter.dtx Copyright (C) 1998-2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{dcounter} +% [2005/04/25 v1.2 Dynamic Counters (NCC)] +% +% \changes{v1.0}{1998/12/19}{Initial version} +% \changes{v1.1}{2004/11/23}{Minor corrections of the documentation} +% \changes{v1.2}{2005/04/25}{Emulate dynamic style for non-dynamic counters} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{dcounter} +\GetFileInfo{dcounter.sty} +\begin{document} +\title{The \textsf{dcounter} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{dcounter.dtx} +\end{document} +% +% \fi +% This package implements a concept of \emph{dynamic counters}. The +% counter declared as dynamic is really created at the first use +% and receives at that moment the \emph{count style} which was +% established by the |\countstyle| command. For example, +% if |\countstyle{section}| is established, all dynamically created +% counters will be subordinated to |section| counter (i.e., reset +% to zero when |section| counter is stepped) and their typesetting +% command |\the|\emph{foo} will be equal to +% |\thesection.\arabic{|\emph{foo}|}|. This package is compatible with +% |calc| package. +% +% \section{User Interface} +% +% \DescribeMacro\DeclareDynamicCounter +% To declare a dynamic counter \meta{foo} you have to write +% \begin{quote} +% |\DeclareDynamicCounter|\marg{foo} +% \end{quote} +% If the \meta{foo} counter does not exist, its name is added to the list of +% dynamic counters. This allows create a counter at the first use +% with one of the following commands +% \begin{tabbing} +% | \setcounter|\marg{foo}\marg{number}\qquad\qquad\= +% |\stepcounter|\marg{foo}\\ +% | \addtocounter|\marg{foo}\marg{number}\> +% |\refstepcounter|\marg{foo} +% \end{tabbing} +% If the \meta{foo} counter exists, it will emulate the dynamic style. +% I use the following trick for such counters: let |\the|\meta{foo} command +% empty and test it at the beginning of document; if it is empty, the +% count style of this counter is redefined on the base of dynamic +% style.\footnote{This trick was added in version 1.2 of the package.} +% This allows work with existing counters by the same manner as with +% ``true dynamic'' counters. +% +% \DescribeMacro\countstyle +% To specify a count style you have to use the command +% \begin{quote} +% |\countstyle|\marg{counter} +% \end{quote} +% The parameter \meta{counter} have to be existing counter, or dynamic +% counter, or empty. Empty \meta{counter} means the \emph{plain} count +% style without subordination. If \meta{counter} not exists and is +% dynamic it is created here within the previously specified count style. +% The default count style is the plain style. +% +% The |\counstyle| command has an optional parameter useful for +% special purposes. If you want to create some counters in another style +% that is specified by |\countstyle| command, you can write +% \begin{quote} +% |\countstyle|\oarg{list of counters}\marg{another counter} +% \end{quote} +% Here \meta{list of counters} is the list of comma separated counters +% whose count style you want to subordinate to +% \meta{another counter}. This command creates all undefined counters of +% the list. The list may contain not only undefined counters but also +% existing counters. If counter in the list +% exists, its count style will be modified to be subordinated to +% \meta{another counter}. Note, that if this counter was subordinated +% before to any other counter, \emph{the previous subordination will be +% rejected}. For example, let you want to use the |book| document class +% and set |\Roman| enumeration of chapters, independent arabic +% enumeration of sections and to subordinate enumeration of figures, +% tables and equations to the \emph{section} counter. You can write +% \begin{quote} +% |\documentclass{book}|\\ +% |\usepackage{dcounter}|\\ +% |\renewcommand\thechapter{\Roman{chapter}}|\\ +% |\countstyle[section]{}|\\ +% |\countstyle[figure,table,equation]{section}| +% \end{quote} +% After that the \emph{chapter} counter will not affect on +% \emph{section} counter, and all figure, table, and equation numbers +% will typeset as |\thesection.\arabic{|\emph{foo}|}|. +% +% \DescribeMacro\DynamicCount +% The command +% \begin{quote} +% |\DynamicCount|\marg{counter} +% \end{quote} +% sets the count style for \meta{counter} exactly the same as for +% dynamically created counters and creates this counter if it is +% undefined. This command is internally used in emulation of dynamic +% counters and in the |\countstyle| command with optional parameter. +% Since version 1.2, this command is obsolete, but it is saved for +% backward compatibility. +% +% \textbf{Note}. All described commands are used in the preamble. +% +% \StopEventually{} +% +% \section{The Basic Implementation Part} +% +% \begin{macro}{\DCNT@list} +% \begin{macro}{\DCNT@elist} +% We begin from the initialization of the list of dynamic counters. +% |\DCNT@list| contains a list of undeclared counters and +% |\DCNT@elist| contains a list of existing counters that are declared +% as dynamic counters. +% \begin{macrocode} +%<*package> +\def\DCNT@list{} +\def\DCNT@elist{} +\@onlypreamble\DCNT@elist +% \end{macrocode} +% Their items will have the form |\@elt|\marg{counter} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\DCNT@in} +% The macro |\DCNT@in|\marg{list}\marg{yes}\marg{no} +% tests the list of counters \meta{list} to contain the counter +% |\DCNT@foo| and after testing executes \meta{yes}-sequence if +% |\DCNT@foo| found or \meta{no}-sequence if not. To restrict +% the scope of internal modifications made by this macro we always +% enclose it into a group. While processing the list of counters the +% command executes |\DCNT@noteq|\marg{counter} hook for every +% counter which name is distinct from the tested name. +% \begin{macrocode} +\def\DCNT@in#1#2#3{\@tempswafalse + \let\@elt\DCNT@elt #1% + \if@tempswa #2\else #3\fi +} +\def\DCNT@elt#1{\def\DCNT@name{#1}% + \ifx\DCNT@name\DCNT@foo \@tempswatrue \else \DCNT@noteq{#1}\fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DCNT@define} +% The command |\DCNT@define|\marg{command}\marg{foo} +% tests the counter \meta{foo} to be undefined and, if it is true, +% tries to create it dynamically. After that it executes \meta{command} +% with the \meta{foo} parameter. +% \begin{macrocode} +\def\DCNT@define#1#2{% + \@ifundefined{c@#2}% + {{\edef\DCNT@foo{#2}\let\DCNT@noteq\@gobble + \DCNT@in\DCNT@list{\newcounter{#2}\DCNT@the{#2}}{}% + }}{}% + #1{#2}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DCNT@the} +% The command |\DCNT@the|\marg{foo} redefines |\the|\meta{foo} +% command to typeset it in the count style subordinated to |\DCNT@main| +% counter. It also adds the name \meta{foo} to the resetting list of\/ +% |\DCNT@main| counter. +% \begin{macrocode} +\def\DCNT@the#1{% + \ifx\DCNT@main\@empty + \expandafter\xdef\csname the#1\endcsname + {\noexpand\@arabic \expandafter\noexpand \csname c@#1\endcsname}% + \else + \expandafter\xdef\csname the#1\endcsname + {\expandafter\noexpand \csname the\DCNT@main\endcsname + .\noexpand\@arabic \expandafter\noexpand \csname c@#1\endcsname}% + \@addtoreset{#1}\DCNT@main + \fi +} +\let\DCNT@main\@empty +% \end{macrocode} +% \end{macro} +% +% \section{The Preamble Only Commands} +% +% \begin{macro}{\DeclareDynamicCounter} +% The following command tests the counter and adds it to the list of +% dynamic counters if it does not exist or to the list +% of emulated counters if it already exists. In the last case, +% |\the|\meta{counter} command is defined as empty command. It will be +% redefined later at the beginning of document. +% \begin{macrocode} +\newcommand*{\DeclareDynamicCounter}[1]{% + \begingroup + \edef\DCNT@foo{#1}% + \ifx\DCNT@foo\@empty + \PackageError{dcounter}% + {Cannot declare a dynamic counter with empty name}{}% + \fi + \let\DCNT@noteq\@gobble + \@ifundefined{c@#1}% + {\DCNT@in\DCNT@list{}{\@cons\DCNT@list{{#1}}}}% + {\DCNT@in\DCNT@elist{}{\@cons\DCNT@elist{{#1}}}% + \expandafter\global\expandafter\let + \csname the#1\endcsname\@empty}% + \endgroup +} +\@onlypreamble\DeclareDynamicCounter +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\countstyle} +% Now we implement |\countstyle| command which redefines |\DCNT@main| +% macro to new main counter. It tests the counter to be defined and +% tries to define it if\/ not. +% \begin{macrocode} +\newcommand{\countstyle}{\@ifnextchar[{\DCNT@lcstyle}{\DCNT@cstyle}} +\@onlypreamble\countstyle +\def\DCNT@cstyle#1{\edef\DCNT@foo{#1}% + \ifx\DCNT@foo\@empty \else + \DCNT@define\@gobble{#1}% + \@ifundefined{c@#1}{\@nocounterr{#1}}{}% + \fi + \let\DCNT@main\DCNT@foo +} +\@onlypreamble\DCNT@cstyle +% \end{macrocode} +% The special variant of this command with optional parameter locally +% sets the special count style and redefines all counters in list via +% the |\DynamicCount| command. +% \begin{macrocode} +\def\DCNT@lcstyle[#1]#2{% + {\DCNT@cstyle{#2}\@for\@tempa:=#1\do{\DynamicCount\@tempa}}% +} +\@onlypreamble\DCNT@lcstyle +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DynamicCount} +% The macro |\DynamicCount|\marg{foo} modifies the count style of +% the counter \meta{foo} and defines this counter if it is undefined. +% \begin{macrocode} +\newcommand*{\DynamicCount}[1]{% + \@ifundefined{c@#1}% + {\newcounter{#1}}% +% \end{macrocode} +% If the counter is already defined, we check all resetting lists and +% remove all references to this counter. +% \begin{macrocode} + {{\edef\DCNT@foo{#1}\let\DCNT@noteq\DCNT@add + \let\@elt\DCNT@remove \cl@@ckpt + }}% + \DCNT@the{#1}% +} +\@onlypreamble\DynamicCount +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DCNT@remove} +% The |\DCNT@remove|\marg{foo} command removes all references +% to |\DCNT@foo| counter from the |\cl@|\meta{foo} list of counters. +% \begin{macrocode} +\def\DCNT@remove#1{\expandafter\DCNT@remlist\csname cl@#1\endcsname} +\def\DCNT@remlist#1{% + {\let\@tempa\@empty \DCNT@in#1{\global\let#1\@tempa}{}}% +} +\@onlypreamble\DCNT@remove +\@onlypreamble\DCNT@remlist +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DCNT@add} +% The |\DCNT@add|\marg{counter} command locally adds +% |\@elt|\marg{counter} to |\@tempa|. +% \begin{macrocode} +\def\DCNT@add#1{% + \let\@elt\relax\edef\@tempa{\@tempa\@elt{#1}}\let\@elt\DCNT@elt +} +\@onlypreamble\DCNT@add +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DCNT@eltemu} +% The |\DCNT@emu|\marg{counter} command test |\the|\meta{counter} +% command to be empty and redefines the counter in the dynamic style. +% This command is applied to all existing counters that are emulated as +% dynamic counters. +% \begin{macrocode} +\def\DCNT@emu#1{% + \expandafter\ifx\csname the#1\endcsname\@empty + \DynamicCount{#1}\fi +} +\@onlypreamble\DCNT@emu +% \end{macrocode} +% \end{macro} +% +% \section{Final Modifications} +% +% Finally, we modify |\setcounter| and |\addtocounter| commands. +% We do it at the beginning of the document to avoid conflict with +% the |calc| package. If\/ the list of dynamic counters is empty, +% we delete all commands of the package. We also define all +% dynamically emulated counters if their |\the| command is empty. +% \begin{macrocode} +\AtBeginDocument{% + \ifx\DCNT@list\@empty + \@onlypreamble\DCNT@list + \@onlypreamble\DCNT@in + \@onlypreamble\DCNT@elt + \@onlypreamble\DCNT@define + \@onlypreamble\DCNT@the + \@onlypreamble\DCNT@main + \@onlypreamble\DCNT@name + \@onlypreamble\DCNT@foo + \@onlypreamble\DCNT@noteq + \else + \let\DCNT@setcounter\setcounter + \def\setcounter{\DCNT@define\DCNT@setcounter} + \let\DCNT@addtocounter\addtocounter + \def\addtocounter{\DCNT@define\DCNT@addtocounter} + \fi + {\let\@elt\DCNT@emu \DCNT@elist}% +} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/desclist.dtx b/macros/latex/contrib/ncctools/source/desclist.dtx new file mode 100644 index 0000000000..de6a911f2d --- /dev/null +++ b/macros/latex/contrib/ncctools/source/desclist.dtx @@ -0,0 +1,157 @@ +% \iffalse +%% +%% File: desclist.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{desclist} +% [2004/11/23 v1.1 Desclist Package (NCC)] +% +% \changes{v1.0}{2002/01/09}{This version was uploaded to CTAN} +% \changes{v1.1}{2004/11/21}{Desclist suffix was enclosed in braces} +% \changes{v1.1}{2004/11/23}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{desclist} +\GetFileInfo{desclist.sty} +\begin{document} +\title{The \textsf{desclist} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{desclist.dtx} +\end{document} +% +% \fi +% The package implements the |desclist| environment and redefines +% the |description| environment to provide an optional parameter +% as a prototype for calculation the hang indent of the list. +% +% \tableofcontents +% +% \section{User Interface} +% +% \DescribeMacro{desclist} +% The |desclist| environment is similar to the |description| +% environment but adds more control for typesetting list labels. +% The usage: +% \begin{quote} +% |\begin{desclist}|\marg{prefix}\marg{suffix}\oarg{prototype}\\ +% |\item|\oarg{label} \meta{text}\\ +% \ldots\\ +% |\end{desclist}| +% \end{quote} +% The \meta{prefix} is inserted before the label and the suffix +% is inserted after the label. The optional \meta{prototype} parameter +% specifies a prototype for calculation the minimum width of a list label +% and for calculation the hang indent of a list text. +% If this parameter is omitted, the standard hang indent value is used +% and the minimum width of list labels is equal to zero. +% +% A list label is generated in the |\item|\oarg{label} command +% as follows: +% \begin{quote} +% \meta{prefix}\meta{label}\marg{suffix}|\hfil| +% \end{quote} +% Therefore, you can finish the \meta{label} with a command having a parameter +% to replace a suffix with something else. The |\hfil| command at the end of +% label adds necessary horizontal space if the label width is less than the +% minimum width of list label. Using a \meta{prototype} together with the +% |\hfill| command in \meta{prefix} and/or \meta{suffix} +% parameters, you can align left, align right, or center narrow list labels. +% +% The following example shows the benefits of the |desclist| environment: +% \begin{desclist}{\sf}{ \rm\hfill---}[Mark] +% \newcommand*\Skip[1]{} +% \item[M] an item with a narrow label; +% \item[MM] an item with a narrow label; +% \item[Mark] an item with a normal label; +% \item[Long mark] an item with too wide label; and +% \item[A mark without dash.\Skip] Here we skip the desclist suffix. +% \end{desclist} +% It was prepared as follows: +% \begin{quote} +% |\begin{desclist}{\sf}{ \rm\hfill---}[Mark]|\\ +% |\newcommand*\Skip[1]{}|\\ +% |\item[M] an item with a narrow label;|\\ +% |\item[MM] an item with a narrow label;|\\ +% |\item[Mark] an item with a normal label;|\\ +% |\item[Long mark] an item with too wide label; and|\\ +% |\item[A mark without dash.\Skip] Here we skip|\\ +% |the desclist suffix.|\\ +% |\end{desclist}| +% \end{quote} +% +% \DescribeMacro{description} +% The package also redefines the |description| environment to allow +% an optional parameter. In fact, the new implementation of |description| +% is equivalent to +% \begin{quote} +% |\begin{desclist}{\normalfont\bfseries}{}|\oarg{prototype}\\ +% \ldots\\ +% |\end{desclist}| +% \end{quote} +% \StopEventually{} +% +% \section{The Implementation} +% \begin{macro}{desclist} +% The definition of the |desclist| environment is quite simple. +% If an optional parameter is omitted, pass an empty one +% to the internal command. +% \begin{macrocode} +%<*package> +\newenvironment*{desclist}[2]{% + \@ifnextchar[{\NCC@dlist{#1}{#2}}{\NCC@dlist{#1}{#2}[]}% +}{% + \endlist +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@dlist} +% The internal definition of the |desclist| is based on the |\list|: +% \begin{macrocode} +\def\NCC@dlist#1#2[#3]{% + \list{}{% +% \end{macrocode} +% Specify just the same list parameters as in the |description| +% if the optional parameter is empty: +% \begin{macrocode} + \def\@tempa{#3}\ifx\@tempa\@empty + \labelwidth\z@ \itemindent-\leftmargin +% \end{macrocode} +% In other case, use the prototype to calculate the label width +% and margins: +% \begin{macrocode} + \else + \settowidth\leftmargin{#1#3{#2}}% + \advance\leftmargin\labelsep + \labelwidth=\leftmargin + \itemindent\z@ + \fi +% \end{macrocode} +% Finally, define the |\makelabel| command adding the desclist +% prefix and suffix and finishing it with |\hfil| to allow left +% alignment for narrow labels. The suffix is enclosed in braces, +% to allow a trick with ignoring it in the label mark if necessary +% (see the example above): +% \begin{macrocode} + \def\makelabel##1{\hspace\labelsep #1##1{#2}\hfil}% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{description} +% Now we redefine the |description| environment. We do not test +% is it defined or not. +% \begin{macrocode} +\def\description{\desclist{\normalfont\bfseries}{}} +\let\enddescription=\enddesclist +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/extdash.dtx b/macros/latex/contrib/ncctools/source/extdash.dtx new file mode 100644 index 0000000000..597ef17cd7 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/extdash.dtx @@ -0,0 +1,329 @@ +% \iffalse +%% +%% File: extdash.dtx Copyright (C) 1998-2018 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{extdash} +% [2018/06/24 v1.3 Extended Dash Package (NCC)] +% +% \changes{v1.0}{1998/12/20}{Initial version} +% \changes{v1.1}{2004/11/23}{Minor corrections of the documentation} +% \changes{v1.2}{2005/01/29}{Change spaces surround em-dash} +% \changes{v1.3){2018/06/24}{Add more em-dash configuring options by request from Frank Mittelbach} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{extdash} +\GetFileInfo{extdash.sty} +\begin{document} +\title{The \textsf{extdash} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{extdash.dtx} +\end{document} +% +% \fi +% The package implements the commands, |\Hyphdash|, |\Endash|, and +% |\Emdash|, to control hyphenation of compound words and ordinary +% words dashed by \emph{em-dash}. Some additional commands and +% shortcuts are also introduced. +% +% \tableofcontents +% +% \section{User Interface} +% +% \DescribeMacro{\Hyphdash} +% \DescribeMacro{\Hyphdash*} +% The main purpose of the |extdash| package is to allow hyphenation +% of compound words. When the word |something-something| occurs, the only +% hyphenation point after the dash is available. To allow hyphenation +% of both words joint by dash you can write +% \begin{center} +% |something\Hyphdash something|\quad or easier\quad +% |something\-/something| +% \end{center} +% (the last case is available if\/ you use the package |extdash| +% with |shortcuts| option). Sometimes the line break immediately after +% the dash is inadmissible. To avoid this, you can write +% \begin{center} +% |something\Hyphdash* something|\quad or easier\quad +% |something\=/something| +% \end{center} +% (the last case is also a shortcut). An example is the word +% \emph{$L$-approximation} which can't be broken at the dash.\pagebreak +% +% \DescribeMacro{\Endash} +% \DescribeMacro{\Endash*} +% Analogously, you can use |\Endash| command (and its star version) to join +% words with \emph{en-dash}. Shortcuts for it are |\--| and |\==|. +% +% \DescribeMacro{\Emdash} +% \DescribeMacro{\Emdash*} +% The last case is the use of \emph{em-dash} when some glue +% before and after em-dash have to be added. The command |\Emdash| adds +% this glue, named |\Halfspace|, which natural width is equal to the +% \DescribeMacro{\Halfspace} +% \DescribeMacro{\Halfspace*} +% half of the ordinary interword space. The |\Halfspace| command +% produces the \emph{elastic} horizontal space and its |*|-form +% produces the nonbreakable elastic space. All these commands have +% shortcuts +% \begin{center} +% |\---|\qquad |\===|\qquad |\-,|\qquad |\=,| +% \end{center} +% Note, that |\Emdash| command removes extra space before and after it. +% When |\Emdash| appears at the beginning of a paragraph (the direct +% speech) the space after it will be rigid and unbreakable. +% +% The standard em-dash is longer that it is required by Russian and German +% typesetting rules. To decrease its length to the required one, you can +% use this package with |shortemdash| option +% (the |cyremdash| option is also supported for compatibility with the previous +% version). +% +% Note: Some more options are available from the version 1.3. They control +% the spacing around |\Emdash| and the breaking strategy to be applied +% before it. +% +% \section{Package Options} +% +% \subsection{Shortcuts} +% +% \begin{center} +% |\usepackage[shortcuts]{extdash}| +% \end{center} +% +% The |shortcuts| option redefines \LaTeX{} commands |\-| and |\=| in +% such a way to recognize shortcut sequences. If\/ no shortcut +% recognized, the corresponding original command will be called. +% In other words, when no shortcut recognized, the command |\-| +% sets extra hyphenation point and |\=| means the accent command. +% +% \begin{center} +% \begin{tabular}{l@{\qquad}l@{\qquad\qquad}l@{\qquad}l} +% Command & Shortcut & Command & Shortcut \\ +% \cs{Hyphdash} & \cs{-/} & \cs{Hyphdash*} & \cs{=/} \\ +% \cs{Endash} & \cs{--} & \cs{Endash*} & \cs{==} \\ +% \cs{Emdash} & \cs{---} & \cs{Emdash*} & \cs{===} \\ +% \cs{Halfspace}& \cs{-,} & \cs{Halfspace*}& \cs{=,} +% \end{tabular} +% \end{center} +% +% \emph{All described commands and shortcuts are robust.} +% +% \subsection{Breaks before em-dash} +% +% All dash commands defined in this package disallow line breaks before a dash. +% For em-dash this rule can be changed. To allow breaks before a em-dash, please +% use the option +% +% \begin{center} +% |\usepackage[allowbreakbefore]{extdash}| +% \end{center} +% +% \subsection{Shorter em-dash} +% +% \begin{center} +% |\usepackage[shortemdash]{extdash}| +% \end{center} +% +% This option redefines |\Emdash| to be shorter than the standard +% em-dash (0.8~em). +% +% \subsection{Spaces around em-dash} +% +% By default, the half-space is inserted before and after em-dash. +% This behavior can be changed with option +% +% \begin{center} +% |\usepackage[wordspacearound]{extdash}| +% \end{center} +% +% \noindent or +% +% \begin{center} +% |\usepackage[nospacearound]{extdash}| +% \end{center} +% +% The first option provides interword spaces around em-dash and the +% last one removes spaces around em-dash. Of course, these two +% options are mutually exclusive. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\EXD@test} +% \begin{macro}{\EXD@break} +% First we implement the command, |\EXD@test|. It recognizes the +% star after the command, sets |\EXD@break| command to be equal +% to |\nobreak| if\/ star is found or |\@empty| if\/ not, and calls +% its parameter. +% \begin{macrocode} +%<*package> +\def\EXD@test#1{% + \@ifstar{\let\EXD@break\nobreak #1}{\let\EXD@break\@empty #1}% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\Hyphdash} +% \begin{macro}{\Endash} +% \begin{macro}{\Emdash} +% \begin{macro}{\Halfspace} +% Now we declare user's level commands +% \begin{macrocode} +\DeclareRobustCommand{\Hyphdash}{\EXD@test{\EXD@dash-}} +\DeclareRobustCommand{\Endash}{\EXD@test{\EXD@dash{--}}} +\DeclareRobustCommand{\Emdash}{\EXD@test{\EXD@emd@sh}} +\DeclareRobustCommand{\Halfspace}{\@tempcnta\z@ + \@ifstar{\EXD@nobreak\EXD@space\ignorespaces}{\EXD@space\ignorespaces}% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \begin{macro}{\EXD@dash} +% \begin{macro}{\EXD@emd@sh} +% \begin{macro}{\EXD@nobreak} +% \begin{macro}{\EXD@embreakbefore} +% \begin{macro}{\EXD@spacecalc} +% \begin{macro}{\EXD@space} +% and then the basic commands +% \begin{macrocode} +\def\EXD@nobreak{\ifvmode\leavevmode\else\nobreak\fi} +\def\EXD@dash#1{% + \EXD@nobreak\hbox{#1}\EXD@break\hskip\z@skip \ignorespaces +} +\def\EXD@emnobreak{\nobreak} +\def\EXD@emd@sh{% + \ifvmode + \leavevmode\EXD@emdash\nobreak\hskip.35em + \else + \unskip\EXD@emnobreak \@tempcnta\m@ne + \EXD@space \EXD@emdash \EXD@break \EXD@space + \fi \ignorespaces +} +\DeclareOption{allowbreakbefore}{% + \let\EXD@emnobreak\@empty +} +% \end{macrocode} +% The |\@tempcnta| specifies the width of half-space. It can have +% the following values: |-1|, |0|, or |+1|. The negative value +% means using the space before em-dash (the space is narrow at this point), +% zero value means an ordinary half space, and the positive value +% means a half-space after em-dash (the space is wider at this point). +% This trick compensates a visual effect of wider space before an em-dash +% especially if the punctuation mark goes before. +% +% The meaning of negative and positive values of |\@tempcnta| +% is redefined with |wordspacearound| and |nospacearound| options. +% \begin{macrocode} +\def\EXD@spacecalc{% + \edef\@tempa{% + \ifnum\@tempcnta<\z@ .4\else \ifnum \@tempcnta=\z@ .5\else .6\fi\fi + }% + \def\@tempb{.5}% +} +\def\EXD@space{% + \EXD@spacecalc + \hskip \@tempa\fontdimen2\font \@plus \@tempb\fontdimen3\font + \@minus \@tempa\fontdimen4\font + \@tempcnta -\@tempcnta +} +\DeclareOption{wordspacearound}{% + \def\EXD@spacecalc{% + \edef\@tempa{\ifnum \@tempcnta=\z@ .5\fi}% + \let\@tempb\@tempa + } +} +\DeclareOption{nospacearound}{% + \def\EXD@spacecalc{% + \edef\@tempa{\ifnum \@tempcnta=\z@ .5\else0\fi}% + \let\@tempb\@tempa + } +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\EXD@emdash} +% The last basic command is the default \emph{em-dash}. It could be +% redefined later in |shortemdash| option. +% \begin{macrocode} +\def\EXD@emdash{\hbox{---}} +% \end{macrocode} +% \end{macro} +% +% \begin{macrocode} +\DeclareOption{shortcuts}{% +% \end{macrocode} +% +% \begin{macro}{\HyphOrDash} +% \begin{macro}{\BarOrDash} +% The commands |\HyphOrDash| and |\BarOrDash| are called by |\-| and |\=| commands +% and can appear in aux file. They choose the corresponding shortcut or the original +% command saved in |\EXD@hyph| and |\EXD@bar|. +% \begin{macrocode} + \DeclareRobustCommand{\HyphOrDash}{% + \let\EXD@break\@empty + \@ifnextchar/{\EXD@d@sh}{% + \@ifnextchar-{\EXD@hdash}{% + \@ifnextchar,{\EXD@sp@ce}{\EXD@hyph}% + }% + }% + } + \DeclareRobustCommand{\BarOrDash}{% + \let\EXD@break\nobreak + \@ifnextchar/{\EXD@d@sh}{% + \@ifnextchar={\EXD@bdash}{% + \@ifnextchar,{\nobreak\EXD@sp@ce}{\EXD@bar}% + }% + }% + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% Shortcuts: +% \begin{macrocode} + \def\EXD@d@sh/{\EXD@dash-} + \def\EXD@sp@ce,{\EXD@space} + \def\EXD@hdash-{\@ifnextchar-{\EXD@hhdash}{\EXD@dash{--}}} + \def\EXD@bdash={\@ifnextchar={\EXD@bbdash}{\EXD@dash{--}}} + \def\EXD@hhdash-{\EXD@emd@sh} + \def\EXD@bbdash={\EXD@emd@sh} +% \end{macrocode} +% +% We turn on the shortcuts mechanism at the beginning of the document to +% avoid conflict with |fontenc| package which redefines accents. +% \begin{macrocode} + \AtBeginDocument{% + \let\EXD@hyph\- \let\@dischyph\HyphOrDash \let\-\@dischyph + \let\EXD@bar\= \let\@acciii\BarOrDash \let\=\@acciii + } +} +% \end{macrocode} +% +% \begin{macrocode} +\DeclareOption{shortemdash}{% + \def\EXD@emdash{\hb@xt@.8\fontdimen6\font{--\hss--}} +} +\DeclareOption{cyremdash}{% + \def\EXD@emdash{\hb@xt@.8\fontdimen6\font{--\hss--}} +} +\ProcessOptions\relax +% +% \end{macrocode} +% +\endinput diff --git a/macros/latex/contrib/ncctools/source/manifest.txt b/macros/latex/contrib/ncctools/source/manifest.txt new file mode 100644 index 0000000000..682169c5c2 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/manifest.txt @@ -0,0 +1,42 @@ +% +% Copyright 1998-2018 by Alexander I. Rozhenko +% +% CONTENTS OF THE NCCTOOLS BUNDLE, Release 3.5 +%============================================= + +afterpackage.dtx +dcounter.dtx +desclist.dtx +extdash.dtx +manyfoot.dtx +mboxfill.dtx +nccbbb.dtx +nccboxes.dtx +ncccomma.dtx +ncccropbox.dtx +ncccropmark.dtx +nccfancyhdr.dtx +nccfloats.dtx +nccfoots.dtx +nccmath.dtx +nccparskip.dtx +nccpic.dtx +nccrules.dtx +nccsect.dtx +nccstretch.dtx +nccthm.dtx +textarea.dtx +tocenter.dtx +topsection.dtx +watermark.dtx + +% +% OTHER FILES +%============= + +manifest.txt This file +ncctools.ins Instructions for unpacking packages prepared in `.dtx' files. + See README +ncctools.tex Short guide to the bundle +README Describes installation and bug reporting procedures. + Contains copyright notes and distribution rules. diff --git a/macros/latex/contrib/ncctools/source/manyfoot.dtx b/macros/latex/contrib/ncctools/source/manyfoot.dtx new file mode 100644 index 0000000000..d66cc54e1d --- /dev/null +++ b/macros/latex/contrib/ncctools/source/manyfoot.dtx @@ -0,0 +1,1521 @@ +% \iffalse +%% +%% File: manyfoot.dtx Copyright (C) 1998--2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e}[1993/12/01] +%\ProvidesPackage{manyfoot} +% [2019/08/03 v1.11 Many Footnote Levels Package (NCC)] +% +% \changes{v1.0}{1998/11/09}{Initial version} +% \changes{v1.1}{1998/11/13}{Compatibility problems solved} +% \changes{v1.2}{1998/11/15}{Such footnotes may now appear in minipages!} +% \changes{v1.3}{1998/11/23}{Floating support bug fixed} +% \changes{v1.4}{1998/12/19}{Hand footnotes are moved to nccfoots package} +% \changes{v1.4}{1998/12/19}{Options |ruled| and |para*| added} +% \changes{v1.5}{2003/02/26}{|\DeclareNewFootnote| command introduced} +% \changes{v1.5}{2003/02/26}{Compatibility with footmisc added} +% \changes{v1.5}{2003/02/27}{More compatibility with footmisc} +% \changes{v1.5}{2003/03/03}{|\Footnote|\marg{suffix} and +% |\Footnotemark|\marg{suffix} added} +% \changes{v1.5}{2003/03/16}{Option |perpage| added} +% \changes{v1.5}{2003/03/26}{The |\MFL@footnoterule| introduced +% for more compatibility with footmisc} +% \changes{v1.5}{2003/04/02}{Custom footnote rules support added} +% \changes{v1.6}{2003/05/11}{Restore |\footnotemargin| support occasionally removed} +% \changes{v1.6}{2003/05/12}{Add support for |multiple| option from footmisc} +% \changes{v1.7}{2004/09/20}{The |\ExtraParaSkip| command introduced} +% \changes{v1.8}{2004/11/23}{Minor corrections of the documentation} +% \changes{v1.9}{2005/02/10}{|\NCC@makemark| replaced with |\NCC@makefnmark|} +% \changes{v1.9}{2005/05/11}{Introduce the |\SetFootnoteHook| command} +% \changes{v1.10}{2005/09/11}{Remove overflow in calculation the fudge factor} +% \changes{v1.11}{2019/08/03}{Fix compatibility issues with multicol} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage[para]{manyfoot} +\DeclareNewFootnote{A} +\DeclareNewFootnote[para]{B}[roman] +\GetFileInfo{manyfoot.sty} +\begin{document} +\title{The \textsf{manyfoot} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{manyfoot.dtx} +\end{document} +% +% \fi +% +% This package implements a command, |\newfootnote|, that adds +% footnote levels to the standard \LaTeX's footnote mechanism. Footnotes +% of every additional level are automatically grouped together +% on a \LaTeXe{} output page and are separated from another levels +% by the special vertical space and rule. +% The |\newfootnote| command allows customization of the +% way footnotes of additional level are represented in \LaTeXe{} +% documents. Two +% customization styles are available now: the |plain| style is the +% ordinary \LaTeX's style of footnote representation; the |para| style +% causes footnotes to be typeset as a run-in paragraph (derived from +% Donald Knuth's \TeX book and from another sources such as the package +% |fnpara| by Dominik Wujastyk and Chris Rowley and the package +% |footmisc| by Robin Fairbairns). +% +% An additional |\DeclareNewFootnote| command is introduced since the +% version~1.5 of the package. It simplifies creation of new +% footnote levels with automatic enumeration. Thanks to Frank Mittelbach +% for this suggestion and for many other proposals for the package +% improvement. +% +% Since version 1.5, a new footnote rule selection method is +% introduced (thanks to Christian Tapp || +% for the idea of this improvement). It allows a customization of +% footnote rules to be inserted before footnote levels. +% +% \tableofcontents +% +% \section{User Interface} +% +% \DescribeMacro\extrafootnoterule +% Footnotes of different levels are separated at the output page +% by the special footnote rule, |\extrafootnoterule|. +% By the default this command is empty. If you want to separate +% footnotes by a footnote rule you may redefine it +% or call the package with the |ruled| option: +% \begin{quote} +% |\usepackage[ruled]{manyfoot}| +% \end{quote} +% In this case, the |\extrafootnoterule| receives a value of the +% default footnote rule command. +% +% \DescribeMacro\defaultfootnoterule +% The default footnote rule is saved in the |\defaultfootnoterule| command +% at the beginning of document (we provide this for compatibility with +% the |splitrule| option of the \textbf{footmisc} package). +% +% The style |para| of footnotes typesetting needs many code. To save +% space, the support for this style is loaded with |para| or |para*| options. +% If you are going to use run-in paragraph footnotes indented as +% ordinary footnotes, use the package with the +% |para| option: +% \begin{quote} +% |\usepackage[para]{manyfoot}| +% \end{quote} +% To suppress indentation, use it with the |para*| option: +% \begin{quote} +% |\usepackage[para*]{manyfoot}| +% \end{quote} +% Note, that these options only \emph{allow} you to generate +% additional footnote levels in |para| style. +% But what style you prefer for every footnote level is up to you. For +% example, let as generate two footnote levels: the first---in ordinary +% style and the second---in |para| style. To do this we have to write +% the following code in the preamble of the document: +% \begin{quote} +% |\usepackage[para]{manyfoot}|\\ +% |\newfootnote{A}|\\ +% |\newfootnote[para]{B}| +% \end{quote} +% \DescribeMacro\newfootnote +% The mandatory parameter of |\newfootnote| is a \emph{suffix} to be added +% to the end of command names generated by |\newfootnote| command. +% The optional parameter is a customization +% style for generated footnote level (two styles now implemented, named +% |plain| and |para|; the default is |plain|). +% +% This example generates +% two commands, |\FootnotetextA| and |\FootnotetextB|, for insertion of +% a text into corresponding footnote levels. Their syntax +% is the following: +% \begin{quote} +% |\Footnotetext|\meta{suffix}\marg{marker}\marg{inserted +% text} +% \end{quote} +% They put the \meta{inserted text} marked with \meta{marker} into +% \TeX's insert register |\footins|\meta{suffix} (this insert is also +% generated by |\newfootnote| command). We use \emph{the hand} style of +% footnote marking, because the choice of how such footnotes have to be +% marked is user's one. Such a way simplifies the syntax of new commands +% and minimize a number of additional commands needed. +% +% \DescribeMacro\Footnotemark +% \DescribeMacro\Footnotetext +% \DescribeMacro\Footnote +% It is clear that accompany to |\Footnotetext|\meta{suffix} must +% present something like \emph{the hand footnote mark} command. Such +% commands are provided by |nccfoots| package which is automatically +% loaded in this package. Their syntax is the following: +% \begin{quote} +% |\Footnotemark|\marg{marker}\\ +% |\Footnotetext|\marg{marker}\marg{inserted text}\\ +% |\Footnote|\marg{marker}\marg{inserted text} +% \end{quote} +% The first command is useful for all footnote levels. Two last commands +% are the hand companions for \LaTeX's |\footnote...| commands. +% +% The question is what these commands have to do when \meta{marker} is +% empty? In such a case we leave the current marker unchanged. +% Therefore, |\Footnote| command is equal to +% \begin{quote} +% |\Footnotemark|\marg{marker}|\Footnotetext{}|\marg{inserted text} +% \end{quote} +% This is useful for |\Footnotetext|\meta{suffix} commands in +% |plain| style. For |para| style the empty \meta{marker} means +% the footnote without marker (this is the special case used for +% splitting long footnotes in |para| style; see below). +% +% Finally, we explain\footnoteA{This is the first A-level footnote.} +% on the previous example\footnoteB{This is the first B-level +% footnote.} how to automate\footnoteA{The second +% A-footnote.} enumeration of the +% additional\footnoteB{The second B-footnote.} +% footnote\footnoteA{The third A-footnote.} +% levels\footnoteB{The third very very very very very very very very very +% long B-footnote.} (we have used in this +% sentence a number of level's |A| and |B| footnotes to show how this +% package works). Let us enumerate the footnotes of |A|~level by arabic +% numbers and the footnotes of |B|~level by roman numbers. We allocate +% two new counters named |footnoteA| and |footnoteB| and define the +% corresponding |\footnote...| commands with automatic enumeration. The +% corresponding code is the following +% \begin{quote} +% |\newcounter{footnoteA}|\\ +% |\newcommand{\footnoteA}{%|\\ +% | \stepcounter{footnoteA}%|\\ +% | \Footnotemark\thefootnoteA \FootnotetextA{}}|\\ +% |\newcounter{footnoteB}|\\ +% |\newcommand{\footnoteB}{%|\\ +% | \stepcounter{footnoteB}%|\\ +% | \Footnotemark\thefootnoteB \FootnotetextB\thefootnoteB}|\\ +% |\renewcommand{\thefootnoteB}{\roman{footnoteB}}| +% \end{quote} +% To produce footnotes presented here, we have done the following +% \begin{verbatim} +% Finally, we explain\footnoteA{This is the first A-level +% footnote.} on the previous example\footnoteB{This is the first +% B-level footnote.} how to automate\footnoteA{The second +% A-footnote.} enumeration of the additional\footnoteB{The second +% B-footnote.} footnote\footnoteA{The third A-footnote.} +% levels\footnoteB{The third very very very very very very very +% very very long B-footnote.}\end{verbatim} +% +% \section{Declaring New Footnotes} +% +% \DescribeMacro\DeclareNewFootnote +% To create a new footnote level with automate enumeration, you need to +% type a bulk of code: create a new footnote level (e.g.~|\newfootnote{A}|), +% create a counter for automate enumeration (e.g.~|\newcounter{footnoteA}|), +% and create a footnote insertion command (e.g.~|\newcommand{\footnoteA}|). +% All these things can be automated with the |\DeclareNewFootnote| command +% used in the preamble only: +% \begin{quote} +% |\DeclareNewFootnote|\oarg{footnote style}\marg{suffix}\oarg{enumeration style} +% \end{quote} +% Here \meta{footnote style} is the customization style (|plain| is default) and +% \meta{enumeration style} is a style of numbering. This macro +% also prepares |\footnotemark|\meta{suffix}, |\footnotetext|\meta{suffix}, +% |\Footnotemark|\meta{suffix}, and |\Footnote|\meta{suffix} commands for +% completeness. +% For example, the command |\DeclareNewFootnote{A}| creates the following: +% \begin{itemize} +% \item The new plain footnote level with \TeX's insert register |\footinsA|; +% \item The counter |footnoteA| with arabic numbering; +% \item The command |\FootnoteA|\marg{marker}\marg{inserted text}; +% \item The command |\FootnotemarkA|\marg{marker}; +% \item The command |\FootnotetextA|\marg{marker}\marg{inserted text}; +% \item The command |\footnoteA|\oarg{number}\marg{inserted text}; +% \item The command |\footnotemarkA|\oarg{number}; and +% \item The command |\footnotetextA|\oarg{number}\marg{inserted text}. +% \end{itemize} +% The first three |\Footnote...| commands work as their analogues without +% suffix, and the behavior of three last commands is just the same as for +% ordinary |\footnote|, |\footnotemark|, and |\footnotetext|. +% Examples of footnote controls shown in the previous section can be easy +% specified in the following two lines: +% \begin{quote} +% |\DeclareNewFootnote{A}|\\ +% |\DeclareNewFootnote[para]{B}[roman]| +% \end{quote} +% +% \section{Custom Footnote Rules} +% +% \DescribeMacro\SelectFootnoteRule +% A custom footnote rule can be specified for every new footnote level. +% Just store the |\SelectFootnoteRule| command before a new footnote +% declaration. Its syntax is the following: +% \begin{quote} +% |\SelectFootnoteRule|\oarg{priority}\marg{rule name}\oarg{action} +% \end{quote} +% The \meta{priority} is a nonnegative integer number specifying an importance +% of the rule. It controls the process of a footnote rule selection while +% typeset (see more detail description below). The default priority is 0. +% The \meta{rule name} is a prefix of the footnote rule command to be used +% before the next footnote level. The command |\|\meta{rule name}|footnoterule| +% is used as a footnote rule. The \meta{action} parameter specifies an +% additional action to be applied just before the next footnote group if it +% is nonempty (for example, an action can produce a marginal mark near the +% footnote group). The default action is empty. A footnote rule and +% an action must insert a material of zero height in vertical mode. +% +% Two footnote rule commands are predefined: +% |\extrafootnoterule| and |\defaultfootnoterule|. The |\extrafootnoterule| +% is selected with zero priority before a new footnote level if no other +% footnote rule was selected with the |\SelectFootnoteRule| command. The +% |\defaultfootnoterule| is usually equal to the |\footnoterule|, but if +% the |\footnoterule| was redefined in the \textbf{footmisc} package with +% the |splitrule| option, the |\defaultfootnoterule| will save the +% original value of the footnote rule. So, if you want to select an ordinary +% footnote rule for the next footnote level, use the following command +% \begin{quote} +% |\SelectFootnoteRule{default}| +% \end{quote} +% The following example create four footnote levels with rule inserted between +% footnotes A,B and C,D: +% \begin{quote} +% |\DeclareNewFootnote{A}|\\ +% |\DeclareNewFootnote[para]{B}[alph]|\\ +% |\SelectFootnoteRule[1]{default}|\\ +% |\DeclareNewFootnote{C}[roman]|\\ +% |\DeclareNewFootnote{D}[Roman]| +% \end{quote} +% To use more custom footnote rules, you must create corresponding commands +% in some way. +% +% The algorithm of footnote rule insertion while a page output is the following: +% \begin{itemize} +% \item At first, we set the |\defaultfootnoterule| to be the current rule. +% Then we test the insert register of the standard footnote group. +% If it is empty, we set the priority of current rule to |1|, +% otherwise to |-1| (|-1| means that this rule is already played). +% \item After that, we do the following for every next footnote group. +% We compare the priority of current rule and the priority of rule +% linked with the next footnote group. If the current priority is less +% or equal to the next priority, the current rule is changed to the +% next rule and the current priority is set to the next priority. +% Then we test an insert register of the next footnote group. +% If this footnote group is nonempty, we insert the current rule +% before it and decrease the current priority to |-1| (played rule). +% \end{itemize} +% +% \DescribeMacro\footnoterulepriority +% The priority for the rule of standard footnote group is specified +% in the |\footnoterulepriority| command. Its default value is |1| (this means that +% the standard footnote rule is more important then every next rule of 0th priority). +% You can redefine this priority with the |\renewcommand|. +% +% \section{Add Hooks at the Beginning of Footnotes} +% +% \DescribeMacro\SetFootnoteHook +% Since version 1.9, a new command |\SetFootnoteHook|\marg{text} is introduced. +% This command is used before a new footnote declaration and specifies +% an action applied for such footnotes. +% +% If the new footnote level is plain, the hook is applied at the beginning of +% every its footnote. For example, the following declaration specifies +% A-footnotes with hang numbering: +% \begin{quote} +% |\SetFootnoteHook{\hangindent=1.8em\noindent}|\\ +% |\DeclareNewFootnote{A}| +% \end{quote} +% +% For para-footnotes, the hook is applied in the output routine after +% merging all para-footnotes together. The following declaration specified +% B-footnotes starting with the word ``Cases:'' typeset in boldface: +% \begin{quote} +% |\SetFootnoteHook{\noindent\textbf{Cases:}\quad}|\\ +% |\DeclareNewFootnote[para]{B}[alph]|\\ +% \end{quote} +% +% \section{Per-page Footnotes Numbering} +% +% The per-page resetting of counters can be implemented with the |perpage| +% package by David Kastrup. For example, if you need to +% reset the |footnoteA| counter every page, just insert the following +% in the preamble of you document (after declaring the footnote level A of course): +% \begin{quote} +% |\usepackage{perpage}|\\ +% |\MakePerPage{footnoteA}| +% \end{quote} +% If all new footnote levels declared with the |\DeclareNewFootnote| command +% must reset every page, use the |perpage| option: +% \begin{quote} +% |\usepackage[perpage]{manyfoot}| +% \end{quote} +% In this case, the |perpage| package is loaded automatically and the +% |\MakePerPage| command is applied to every counter created with the +% |\DeclareNewFootnote|. +% +% \section{Splitting of Para-Footnotes} +% +% The algorithm proposed by Donald Knuth for processing run-in +% paragraph footnotes has some shortages. Namely, small overfulls of +% output page frequently arise and the automatical splitting of long +% footnotes is impossible. First bug is corrected here (look at the +% implementation section below), but the second one couldn't be easily +% eliminated. +% +% \DescribeMacro\SplitNote +% To split a long footnote near the end of the output page we propose +% the following method. You should decide where the splitting have to be +% done. Then you split footnote ``by hands" into two parts. You leave +% \emph{the first part} at the same position in the text and complete its +% text by the command |\SplitNote|. You move \emph{the second part} down +% in the source file and attach it to any text corresponding to the next +% page via the |\Footnotetext...| command with \emph{the empty marker}. +% E.g. you source text will look as follows: +% \begin{verbatim} +% This text goes on the current +% page\footnoteB{This is the beginning of the long +% footnote ... the splitting must be here\SplitNote} +% ... +% This text goes on the next +% page\FootnotetextB{}{and the end of the split +% footnote is here ...}\end{verbatim} +% If both parts of split footnote get into the same output page, the +% splitting is ignored. +% +% \section{Footnotes within Minipages and Multicolumns} +% +% If you attach an additional level footnote to some text inside a +% minipage, it will appear at the bottom of the page nor the minipage. +% +% The package correctly works together with |multicol| package and +% gives good results when switching between one and two columns by +% \LaTeX's commands |\twocolumn| and |\onecolumn|. +% +% \section{Compatibility with footmisc} +% +% The |footmisc| package also provides the |para| option. You cannot +% use this option with |footmisc| if you plan to use it (or |para*|) +% with |manyfoot|. +% +% The footnote margins management from the |footmisc| package acts on the +% |manyfoot| also, but with some limitations concerning to footnotes +% in the |para| style: +% \begin{itemize} +% \item If the |manyfoot| package is loaded with the |para*| option, +% the margin management options of the |footmisc| package have no +% influence on additional footnotes of |manyfoot| in |para| style. +% \item If the |manyfoot| package is loaded with the |para| option, +% the margin management options |flushmargin| and |hang| of the +% |footmisc| package appropriately change the indentation of |para| +% footnotes created with the |manyfoot| package. More exactly, a +% nonnegative value of the |\footnotemargin| is taken into +% account in this case. But if a width of the starting footnote +% marker becomes greater than |0.8em|, the hang indentation of such +% footnote will exceed the value of |\footnotemargin|. +% \end{itemize} +% Footnotes having the |plain| style inherit all +% formatting specified in the |footmisc|, because they use the +% standard |\@makefntext| hook. +% +% \section{Add Extra Skip for Para-Footnotes} +% +% The algorithm used for calculation the vertical space occupied +% with para-footnotes has one serious disadvantage. It cannot exactly +% calculate how many vertical space the collected para-footnotes will +% occupy because the formatting of such footnotes in vertical box is +% applied in the output routine \textit{after} \TeX\ decides on page +% breaking. For example, if collected para-footnotes occupy 2.25 lines, +% the algorithm reserves the vertical space of |2.25\normalbaselineskip| +% for them, but when such footnotes will be formatted in vbox, 3 lines +% will be necessary of course. This is the reason why the use of +% para-footnotes can lead to page overfull. To compensate this +% overfull we use a special trick: we add a special space to +% a value of skip for all insert registers taking part with +% para-inserts. +% When the insertions are formatted in the output routine, the +% adjusted space is turned back. So, the additional space appears +% and the overfull disappears. +% +% The value of space to be adjusted is calculated as follows: +% \begin{center} +% |max(\footnotesep-\height\strut,0)+0.5\normalbaselineskip| +% \end{center} +% We take into account here that the +% value of |\footnotesep| can be larger than the height of |\strut| +% and the total height of para-footnotes is less than the required +% height by |0.5\baselineskip| on the average. +% +% \DescribeMacro\ExtraParaSkip +% Sometimes, the assumptions on the required extra space are wrong +% and footnotes can overlap on the text (this situation can occur +% in long tables). So, the new command, |\ExtraParaSkip|\marg{space}, +% was introduced since version 1.7 (by the proposal of Uwe L\"uck +% || and Florian Kragl ||) +% to adjust the default extra space. +% The command can be used in the preamble only. +% It can be used more than once. The later use of the command +% overrides the previous one. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% First we load |nccfoots| package, containing hand footnote mark +% commands and the command |\NCC@makefnmark|\marg{marker} which +% generates marker in |\@thefnmark| command. +% \begin{macrocode} +%<*package> +\RequirePackage{nccfoots} +% \end{macrocode} +% +% \begin{macro}{\extrafootnoterule} +% Then we define the empty |\extrafootnoterule| command and implement |ruled| +% option that sets the |\extrafootnoterule| to be equal to the +% |\defaultfootnoterule|. The |\defaulfootnoterule| is later defined +% at the beginning +% of document. It is set to the |\pagefootnoterule| if the last is specified +% or to the |\footnoterule| if not. +% This trick provides the compatibility with the |splitrule| option of the +% \textbf{footmisc} package in which the default |\footnoterule| is saved +% in |\pagefootnoterule| and then redefined. +% \begin{macrocode} +\newcommand{\extrafootnoterule}{} +\DeclareOption{ruled}{\def\extrafootnoterule{\defaultfootnoterule}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@columnwidth} +% \begin{macro}{\MFL@floathook} +% We use the dimen |\MFL@columnwidth| instead of |\columnwidth| while +% producing the footnote for insertion. We set this dimen to be equal +% to |\columnwidth| at the beginning of document and within the +% |\@floatplacement| command. The command |\MFL@floathook| does this +% job. Later, in |para| option, we'll add to this hook the resetting of +% the fudge factor. +% \begin{macrocode} +\newdimen\MFL@columnwidth +\def\MFL@floathook{\MFL@columnwidth\columnwidth} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\MFL@insert} +% The command |\MFL@insert|\marg{insert register}\marg{text} +% inserts the text to the insert register and sets the standard +% splitting parameters. We let this command to be equal |\MFL@mpinsert| +% when go into a minipage. To use this command after a minipage we save +% its value in |\MFL@realinsert| command. +% To support |multiple| option from |footmisc| we add the +% |\FN@mf@prepare| command from |footmisc| (suggested by Frank Mittelbach). +% \begin{macrocode} +\long\def\MFL@insert#1#2{% + \insert#1{\splittopskip\footnotesep \splitmaxdepth \dp\strutbox + \floatingpenalty\@MM #2% + }% + \FN@mf@prepare +} +\providecommand\FN@mf@prepare{} +\let\MFL@realinsert\MFL@insert +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@applyhook} +% The command |\MFL@applyhook|\marg{insert register} applies a hook +% corresponding to the given insert register. +% \begin{macrocode} +\def\MFL@applyhook#1{\csname MFL@hook\string#1\endcsname} +% \end{macrocode} +% \end{macro} +% +% \subsection{Footnote Styles Support} +% +% \DescribeMacro{\MFL@start...} +% Every additional footnote level has deal with its own +% \emph{insert register} +% which is allocated by the |\newfootnote| command. This insert register is +% automatically initialized with the same values as the |\footins| +% register. You can modify its parameters and do something more in +% the command +% \begin{quote} +% |\MFL@start|\meta{style}\marg{insert register} +% \end{quote} +% You must do all modifications globally, because this command is called +% within the group. It is called at the beginning of the document for +% every +% footnote of such style and is needed in the preamble only. +% +% \DescribeMacro{\MFL@fnote...} +% To put footnote into the insert register the command +% \begin{quote} +% |\MFL@fnote|\meta{style}\marg{insert +% register}\marg{marker}\marg{inserted text} +% \end{quote} +% is used. Note that you have to define it with |\long| modifier if you +% allow footnotes consisting of a number of paragraphs. You have to use +% the macros |\MFL@insert| and |\MFL@columnwidth| instead of |\insert| +% and |\columnwidth|. +% +% \DescribeMacro{\MFL@process...} +% And the last style customization command +% \begin{quote} +% |\MFL@process|\meta{style}\marg{insert register} +% \end{quote} +% is called within the output routine to prepare the box of the +% \meta{insert register} for joining it with another footnote inserts. +% +% Do some comments on joining algorithm. It joins together all nonempty +% footnote insert boxes and puts the result into |\footins| box. Special +% vertical space and footnote rule are added between every +% two neighboring nonempty inserts. This space +% is defined by the skip value from the second neighbor. In other words the skip +% of the \meta{insert register} is the vertical space to be added +% between +% this insert and any nonempty footnote insert coming before it in the +% \emph{list of footnote inserts}. Note that this skip can be +% modified while processing of the document (the |multicol| package +% multiplies |\skip| and |\count| of |\footins| to the number of columns +% when goes into multicolumns mode; we do the same with these parameters +% of all another footnote inserts to provide the compatibility with +% |multicol| package). +% +% \DescribeMacro{\MFL@skip} +% This command adds the vertical space just before the +% |\MFL@process...| command. The value of this space is also calculated +% in |\@tempskipa|. Note that this command is inserted +% \emph{between} vertical boxes in joining procedure. If processed box +% is the first nonempty footnote box (|\footins| register and all +% registers going in footins list before the processed insert are +% empty), the command |\MFL@skip| is ignored. +% +% \subsection{Plain Footnote Style} +% +% \begin{macro}{\MFL@startplain} +% \begin{macro}{\MFL@fnoteplain} +% \begin{macro}{\MFL@processplain} +% It is very simple. The commands +% |\MFL@startplain| and |\MFL@processplain| do nothing +% \begin{macrocode} +\let\MFL@startplain\@gobble +\@onlypreamble\MFL@startplain +\let\MFL@processplain\@gobble +% \end{macrocode} +% and the command |\MFL@fnoteplain| does near the same as the usual +% \@footnotetext command. +% \begin{macrocode} +\long\def\MFL@fnoteplain#1#2#3{\NCC@makefnmark{#2}% + \MFL@insert#1{\reset@font\footnotesize + \interlinepenalty\interfootnotelinepenalty + \hsize\MFL@columnwidth \@parboxrestore + \protected@edef\@currentlabel{\@thefnmark}% + \color@begingroup + \MFL@applyhook{#1}% + \@makefntext{% + \rule\z@\footnotesep\ignorespaces#3\@finalstrut\strutbox}% + \color@endgroup + }% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{Para Footnote Style} +% +% \begin{macro}{\ifMFL@paraindent} +% This style is too complicated. We load its +% commands optionally. First we define |\ifMFL@paraindent| command to +% switch between indented and non-indented versions of |para| footnotes. +% \begin{macrocode} +\newif\ifMFL@paraindent \MFL@paraindenttrue +% \end{macrocode} +% \end{macro} +% +% Now we implement the |para| option. +% \begin{macrocode} +\DeclareOption{para}{% +% \end{macrocode} +% +% \begin{macro}{\footglue} +% The |\footglue| skip is the horizontal space between footnotes in +% run-in paragraph. It's name goes from \TeX book +% (Appendix D. Dirty Tricks) and we don't rename this +% register. This gives us an additional protection from the usage +% this package in the document where another package also provides +% footnotes in |para| style. +% \begin{macrocode} + \newskip\footglue +% \end{macrocode} +% Contrarily to |footmisc| package we initialize this skip in terms of +% the footnote size (nor the normal size). +% \begin{macrocode} + {\footnotesize \global\footglue=1em plus.3em minus.3em } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\SplitNote} +% \begin{macro}{\ifMFL@split} +% The switch |MFL@split| provides footnote splitting and +% the command |\SplitNote| simply sets this switch to \emph{true}. +% \begin{macrocode} + \newif\ifMFL@split \MFL@splitfalse + \newcommand\SplitNote{\MFL@splittrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\MFL@startpara} +% Now we prepare |para| support routines. The first is the starting +% routine. +% \begin{macrocode} + \def\MFL@startpara#1{% +% \end{macrocode} +% It adds to insert's skip additional space |\MFL@paraskip| (it is +% non-stretchable and is calculated at the beginning of the document). +% \begin{macrocode} + \global\advance\skip#1\MFL@paraskip +% \end{macrocode} +% Then we define the command named |\MFL@split\footins|\meta{suffix} +% which saves splitting information for the corresponding footnote +% level. While processing the document this command will have the +% |\MFL@applyhook|\marg{insert register} value (without splitting) or +% |\noindent| value (with splitting). +% \begin{macrocode} + \MFL@setsplit{#1}{\MFL@applyhook{#1}}% + } + \@onlypreamble\MFL@startpara +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@fnotepara} +% The next command inserts footnote into \meta{insert register}. +% We use Knuth's trick to inform the output procedure how many +% horizontal space occupy the footnote by modifying its vertical size +% as \emph{fudgefactor}${}\times{}$\emph{footnotebaselineskip} where +% \emph{fudgefactor} is the ratio of \emph{footnotebaselineskip} to +% |\columnwidth|. The real vertical size of such footnote is not needed +% because the footnote is save in |\hbox| nor |\vbox| and +% while processing to the run-in paragraph will be unboxed. +% +% This footnote command is not |\long| because the |\par| command cannot +% be used in |\hbox|. At the beginning we make footnote mark and +% set current label only if footnote mark was nonempty. We use below the +% temporary switch |@tempswa| to select the case of nonempty footnote +% mark. +% \begin{macrocode} + \def\MFL@fnotepara#1#2#3{\let\@thefnmark\@empty + \NCC@makefnmark{#2}% + \MFL@insert#1{\reset@font\footnotesize + \ifx\@thefnmark\@empty \@tempswafalse \else + \@tempswatrue + \protected@edef\@currentlabel{\@thefnmark}% + \fi + \color@begingroup +% \end{macrocode} +% Now we test the width of the footnote mark and if\/ it less than +% |0.8em| we calculate in |\@tempdima| the difference between |0.8em| +% and the natural width of the marker. This horizontal space is +% inserted before the footnote mark. Why it is needed? While the +% processing of |para| insert we set |\parindent| to |1em|. And taking +% into account that the marker width is at least |0.8em| we obtain the +% distance at least |1.8em| between the footnote text and the left +% margin. It is exactly the same distance as for footnotes in |plain| +% style. Why we add this space using |\hskip|? It should be removed +% when line will be broken at this point. +% We add this space when the switch |MFL@paraindent| is true. +% \begin{macrocode} + \if@tempswa + \setbox\@tempboxa\hbox{\@makefnmark}% + \ifMFL@paraindent + \@tempdima.8em \advance\@tempdima-\wd\@tempboxa + \ifdim \@tempdima<\z@ \@tempdima\z@ \fi + \else + \@tempdima\z@ + \fi + \fi + \setbox\@tempboxa\hbox{% + \if@tempswa + \hskip\@tempdima\unhbox\@tempboxa\nobreak + \fi +% \end{macrocode} +% Well. Now we insert the footnote text into hbox and test the +% |MFL@split| switch. +% If it is true (splitting needed) we add at the end of text the special +% small penalty |-1|. It will indicate us where the splitting needed. +% In false case we set penalty |-10| and insert |\footglue| space. +% \begin{macrocode} + \ignorespaces#3\unskip\strut + \ifMFL@split \penalty\m@ne\space \else + \penalty-10 \hskip\footglue + \fi + }% +% \end{macrocode} +% And finally we use Knuth's trick. +% \begin{macrocode} + \dp\@tempboxa\z@ \ht\@tempboxa\MFL@fudgefactor\wd\@tempboxa + \box\@tempboxa + \color@endgroup + }% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@processpara} +% This is the last procedure of |para| style which is called in the +% output routine. We must reorganize the box of the \meta{insert +% register} which is the ``vbox of hboxes". +% \begin{macrocode} + \def\MFL@processpara#1{% +% \end{macrocode} +% Firstly we redefine |\MFL@skip| command decreasing its skip by +% |\MFL@paraskip|. +% \begin{macrocode} + \advance\@tempskipa -\MFL@paraskip + \edef\MFL@skip{\vskip\the\@tempskipa\relax}% + \setbox#1\vbox{% +% \end{macrocode} +% Now we execute the first step of Knuth's algorithm: convert the ``vbox +% of hboxes" to ``hbox of hboxes". +% \begin{macrocode} + \unvbox#1\setbox\@tempboxa\hbox{}\MFL@makehhbox +% \end{macrocode} +% The second step is unhboxing of all first level hboxes. After that we +% have the normal hbox which can be easily converted to paragraph vbox. +% \begin{macrocode} + \setbox\@tempboxa\hbox{\unhbox\@tempboxa\MFL@removehboxes}% +% \end{macrocode} +% Now we set all needed parameters to prepare run-in paragraph. +% When we set a |\parindent|, we do test on the compatibility with +% |footmisc| package. If this package is in use, the |\footnotemargin| +% register is specified. To provide just the same indent of the first line +% for para footnotes as for ordinary footnotes, we calculate the par indent +% as |\footnotemargin-0.8em| (|0.8em| is the width of marker going after). +% This calculation is executed in the only case of nonnegative +% |\footnotemargin| value. +% \begin{macrocode} + \footnotesize + \hsize\MFL@columnwidth \@parboxrestore + \ifMFL@paraindent + \@ifundefined{footnotemargin}% + {\parindent\footglue}% + {\parindent\footnotemargin\relax + \ifdim\parindent<\z@ \parindent\footglue + \else \advance\parindent -0.8em \fi}% + \fi +% \end{macrocode} +% Then we call |\MFL@split\footins|\meta{suffix} macro to set |\noindent| +% if\/ it is needed (this case occurs when the footnote was splitted at +% the previous page) or apply its hook otherwise. +% \begin{macrocode} + \csname MFL@split\string#1\endcsname +% \end{macrocode} +% Here is the right place where |\footnotesep| rule have to be inserted. +% \begin{macrocode} + \rule\z@\footnotesep +% \end{macrocode} +% Finally, we convert prepared hbox to vbox and test the last penalty +% (it is +% the penalty of the last |para| footnote inserted into this vbox). This +% penalty is |-10| or |-1|. The case |-1| means that the last +% footnote continues onto the next page (splitting case; see the +% command |\MFL@fnotepara|). In this case we adjust the last line of +% paragraph to the right margin and set |\MFL@split\footins|\meta{suffix} +% macro to |\noindent|. Otherwise, we apply the hook as its default value. +% \begin{macrocode} + \unhbox\@tempboxa\unskip + \ifnum\lastpenalty=\m@ne \parfillskip\z@ + \MFL@setsplit{#1}{\noindent}% + \else + \MFL@setsplit{#1}{\MFL@applyhook{#1}}% + \fi + }% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@makehhbox} +% This procedure converts ``vbox of hboxes" to ``hbox of hboxes". +% Its implementation has minimal distinctions from the original code +% described in \TeX book. We removed from it the initialization of +% the accumulating box (|\@tempboxa|) and added a possibility some boxes +% in the list to be vboxes nor hboxes. Such vboxes arises because +% while processing a minipage we put all internal footnotes +% into vbox to prevent their splitting. +% We use the box 0 as the temporary box here. +% \begin{macrocode} + \def\MFL@makehhbox{% + \loop\setbox\z@\lastbox \ifhbox\z@ + \setbox\@tempboxa\hbox{\box\z@\unhbox\@tempboxa}% + \repeat + \ifvbox\z@ \unvbox\z@ \MFL@makehhbox \fi + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@removehboxes} +% This is an internal procedure described in \TeX book to unboxing ``hbox +% of hboxes". +% \begin{macrocode} + \def\MFL@removehboxes{\setbox\@tempboxa\lastbox + \ifhbox\@tempboxa{\MFL@removehboxes}\unhbox\@tempboxa\fi + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@setsplit} +% This macro sets the value of |\MFL@split\footins|\meta{suffix} macro. +% \begin{macrocode} + \def\MFL@setsplit#1#2{% + \expandafter\gdef\csname MFL@split\string#1\endcsname{#2}% + } +% \end{macrocode} +% \end{macro} +% +% Finally, we have to prepare something for work. +% We add to |\MFL@floathook| the calculation of the fudge factor. +% Such a calculation is needed when we switch between one and two +% columns by the standard \LaTeX{} commands. The original Knuth's +% version of the algorithm produces an overflow if |\normalbaselineskip| +% greater or equal to |16pt|. In version 1.10, the calculation +% was improved to remove overflow. Now overflow appears when +% |\normalbaselineskip| is |64pt|. I think it will be enough for +% all applications. By the way, in ordinary cases the new version +% calculates the fudge factor two times more accurate than the +% Knuth's one. +% \begin{macrocode} + \g@addto@macro\MFL@floathook{% + \begingroup + \footnotesize \@tempdima\normalbaselineskip + \multiply \@tempdima \@cclvi + \@tempdimb \columnwidth + \divide \@tempdimb \@cclvi + \divide \@tempdima \@tempdimb + \xdef\MFL@fudgefactor{\strip@pt\@tempdima}% + \endgroup + } +% \end{macrocode} +% +% \begin{macro}{\MFL@paraskip} +% The last trick is the calculation of |\MFL@paraskip|~--- the skip +% which has to be added to the skip of all |para| style footnote +% inserts and then ``turned back" while preparing of run-in paragraph. +% Why it is needed? Two reasons. The first, the +% value of |\footnotesep| may be larger than the height of |\strut|. +% And we nowhere take into account this exceeding. The second, the +% total height of |para| footnotes is less then the real height of +% the prepared run-in paragraph by |0.5\baselineskip| on the average. +% So we have to add it to the |\skip| register for the compensation. +% +% \begin{macro}{\ExtraParaSkip} +% I new command, |\ExtraParaSkip|\marg{space}, is introduced here +% by the proposal of Uwe L\"uck ||. Using it, +% everyone can adjust a value of skip to be added to all |\skip| +% registers of para-inserts. +% \begin{macrocode} + \newcommand*\ExtraParaSkip[1]{% + \def\MFL@xparaskip{\advance\@tempdima#1\relax}% + } + \let\MFL@xparaskip\relax + \@onlypreamble\ExtraParaSkip + \@onlypreamble\MFL@xparaskip +% \end{macrocode} +% \end{macro} +% +% We do calculations of the |\MFL@paraskip| at the beginning of +% the document. +% \begin{macrocode} + \AtBeginDocument{% + \begingroup + \footnotesize + \@tempdima\footnotesep + \advance\@tempdima -\ht\strutbox + \ifdim\@tempdima<\z@ \@tempdima\z@ \fi + \advance\@tempdima.5\normalbaselineskip + \MFL@xparaskip % Add extra para skip + \xdef\MFL@paraskip{\the\@tempdima\relax}% + \endgroup + } +} +% \end{macrocode} +% \end{macro} +% +% Finally, we implement |para*| option which suppresses indentation of +% |para| footnotes. +% \begin{macrocode} +\DeclareOption{para*}{% + \@ifundefined{MFL@startpara}{\ExecuteOptions{para}}{}% + \MFL@paraindentfalse +} +% \end{macrocode} +% +% \subsection{Perpage Option} +% +% The |perpage| option just sets the true value for the |MFL@perpage|: +% \begin{macrocode} +\newif\ifMFL@perpage \MFL@perpagefalse +\DeclareOption{perpage}{\MFL@perpagetrue} +% \end{macrocode} +% Now we can process the package options: +% \begin{macrocode} +\ProcessOptions\relax +% \end{macrocode} +% After that, we test the |MFL@perpage| and load the |perpage| package +% on demand: +% \begin{macrocode} +\ifMFL@perpage \RequirePackage{perpage}\fi +% \end{macrocode} +% +% \subsection{Additional Footnotes Support} +% +% \begin{macro}{\MFL@list} +% We initialize the list of all additional footnote levels to be empty. +% \begin{macrocode} +\def\MFL@list{} +% \end{macrocode} +% Its items will have the form |\@elt|\marg{style}\meta{insert register} +% \end{macro} +% +% \begin{macro}{\SelectFootnoteRule} +% Next we implement the footnote rule selection command. +% It defines the |\MFL@rule| command that is later used in the +% |\MFL@newinsert| command to specify accompany footnote level rule. +% \begin{macrocode} +\newcommand*{\SelectFootnoteRule}[2][0]{% + \edef\@tempa{\noexpand\MFL@selectrule{#1}{% + \expandafter\noexpand\csname #2footnoterule\endcsname}}% + \@ifnextchar[{\@tempa}{\@tempa[]}% +} +\def\MFL@selectrule#1#2[#3]{\def\MFL@rule{\MFL@joinrule{#1}{#2}{#3}}} +\SelectFootnoteRule{extra}% Set the default footnote rule +\@onlypreamble\SelectFootnoteRule +\@onlypreamble\MFL@selectrule +\@onlypreamble\MFL@rule +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\SetFootnoteHook} +% |\SetFootnoteHook|\marg{hook} saves a hook in the internal command. +% When a new footnote is created, this hook is applied to it. +% \begin{macrocode} +\newcommand{\SetFootnoteHook}[1]{\def\MFL@footnotehook{\MFL@fhook{#1}}} +\@onlypreamble\SetFootnoteHook +\@onlypreamble\MFL@footnotehook +\SetFootnoteHook{}% Empty hook by default +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@fhook} +% |\MFL@fhook|\marg{hook}\marg{insert register} associates a hook with +% the given insert register and resets the current hook. +% \begin{macrocode} +\long\def\MFL@fhook#1#2{% + \expandafter\def\csname MFL@hook\string#2\endcsname{#1}% + \SetFootnoteHook{}% +} +\@onlypreamble\MFL@fhook +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\newfootnote} +% Then we implement the basic command which generates additional +% footnote levels. +% \begin{macrocode} +\newcommand*{\newfootnote}[2][plain]{% +% \end{macrocode} +% Firstly, we test the \meta{style} to be valid. +% \begin{macrocode} + \@ifundefined{MFL@fnote#1}{% + \PackageError{manyfoot}{Unknown footnote style #1}% + {Known styles are `plain' and `para'\MessageBreak + (if the package was loaded with the para or para* option)}}{}% +% \end{macrocode} +% Then we allocate and initialize a new insert +% \begin{macrocode} + \expandafter\MFL@newinsert\csname footins#2\endcsname +% \end{macrocode} +% generate |\Footnotetext|\meta{suffix} and its hook +% \begin{macrocode} + \edef\@tempa{\noexpand\newcommand + \expandafter\noexpand\csname Footnotetext#2\endcsname + {\expandafter\noexpand\csname MFL@fnote#1\endcsname{% + \expandafter\noexpand\csname footins#2\endcsname}}% + \noexpand\MFL@footnotehook{% + \expandafter\noexpand\csname footins#2\endcsname}% + }% + \@tempa +% \end{macrocode} +% and finally add the description of this insert to the list of +% additional footnote inserts. +% \begin{macrocode} + \@cons\MFL@list{{#1}\csname footins#2\endcsname}% +} +\@onlypreamble\newfootnote +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@newinsert} +% The initialization of a new insert. A current rule selection command +% is linked with the new insert by the insert count number. +% \begin{macrocode} +\def\MFL@newinsert#1{\newinsert#1% + \expandafter\let\csname MFL@join\number #1\endcsname \MFL@rule + \SelectFootnoteRule{extra}% Reset to default rule again + \skip#1\skip\footins \dimen#1\dimen\footins \count#1\count\footins +} +\@onlypreamble\MFL@newinsert +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@makemark} +% All additional footnote mark commands with automatic numbering are based +% on the following command: +% \begin{quote} +% |\MFL@makemark|\marg{counter}\marg{stepcounter}\marg{command}\oarg{number} +% \end{quote} +% This command tests an optional parameter and, if it exists, prepares the marker +% using the specified number. Otherwise, it at first executes the +% \meta{stepcounter}\marg{counter} command (it is either |\stepcounter| or |\@gobble|) +% and then makes a mark. Finally, it executes the \meta{command} parameter. +% Check for |multiple| footnotes added as suggested by Frank Mittelbach. +% \begin{macrocode} +\def\MFL@makemark#1#2#3{% + \FN@mf@check + \@ifnextchar[{\MFL@xmkmark{#1}{#3}}{#2{#1}\MFL@mkmark{#1}{#3}}% +} +\providecommand\FN@mf@check{} +\def\MFL@xmkmark#1#2[#3]{% + \begingroup + \csname c@#1\endcsname #3\relax + \unrestored@protected@xdef\@thefnmark{\csname the#1\endcsname}% + \endgroup + #2% +} +\def\MFL@mkmark#1#2{\protected@xdef\@thefnmark{\csname the#1\endcsname}% + #2% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DeclareNewFootnote} +% Now we define the service command simplifying creation of footnotes +% in almost all cases. +% \begin{macrocode} +\newcommand*{\DeclareNewFootnote}[2][plain]{% + \@ifnextchar[{\MFL@declare{#1}{#2}}{\MFL@declare{#1}{#2}[arabic]}% +} +\def\MFL@declare#1#2[#3]{% +% \end{macrocode} +% We start from creation a new footnote level: +% \begin{macrocode} + \newfootnote[#1]{#2}% +% \end{macrocode} +% Now we prepare the |\@tempa| command which will create other commands +% at the end of macro. A counter creation command is prepared at first: +% \begin{macrocode} + \edef\@tempa{\noexpand\newcounter{footnote#2}% +% \end{macrocode} +% After that we prepare the redefinition of the enumeration style +% \begin{macrocode} + \noexpand\renewcommand + \expandafter\noexpand\csname thefootnote#2\endcsname{% + \expandafter\noexpand\csname @#3\endcsname + \expandafter\noexpand\csname c@footnote#2\endcsname + }% +% \end{macrocode} +% and specify the per-page resetting if necessary: +% \begin{macrocode} + \ifMFL@perpage \noexpand\MakePerPage{footnote#2}\fi +% \end{macrocode} +% Next we prepare the |\footnote|\meta{suffix} command: +% \begin{macrocode} + \noexpand\newcommand + \expandafter\noexpand\csname footnote#2\endcsname{% + \noexpand\MFL@makemark{footnote#2}{\noexpand\stepcounter}{% + \noexpand\@footnotemark + \noexpand\let\noexpand\@tempb\noexpand\@thefnmark + \expandafter\noexpand\csname Footnotetext#2\endcsname{% + \noexpand\@tempb + }% + }% + }% +% \end{macrocode} +% After that we prepare the |\footnotemark|\meta{suffix} command: +% \begin{macrocode} + \noexpand\newcommand + \expandafter\noexpand\csname footnotemark#2\endcsname{% + \noexpand\MFL@makemark{footnote#2}{\noexpand\stepcounter}{% + \noexpand\@footnotemark + }% + }% +% \end{macrocode} +% Then we prepare the |\footnotetext|\meta{suffix} command: +% \begin{macrocode} + \noexpand\newcommand + \expandafter\noexpand\csname footnotetext#2\endcsname{% + \noexpand\MFL@makemark{footnote#2}{\noexpand\@gobble}{% + \noexpand\let\noexpand\@tempb\noexpand\@thefnmark + \expandafter\noexpand\csname Footnotetext#2\endcsname{% + \noexpand\@tempb + }% + }% + }% +% \end{macrocode} +% Finally, we provide suffixed equivalents for |\Footnotemark| +% and |\Footnote| commands: +% \begin{macrocode} + \noexpand\newcommand + \expandafter\noexpand\csname Footnotemark#2\endcsname{% + \noexpand\Footnotemark + }% + \noexpand\newcommand + \expandafter\noexpand\csname Footnote#2\endcsname[1]{% + \noexpand\Footnotemark{####1}% + \expandafter\noexpand\csname Footnotetext#2\endcsname{####1}% + }% + }% +% \end{macrocode} +% And now all prepared commands are created: +% \begin{macrocode} + \@tempa +} +\@onlypreamble\DeclareNewFootnote +\@onlypreamble\MFL@declare +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@start} +% This command executes the |\MFL@start|\meta{suffix} command. +% It works at the preamble of the document only once for every +% additional footnote level. +% \begin{macrocode} +\def\MFL@start#1{\csname MFL@start#1\endcsname} +\@onlypreamble\MFL@start +% \end{macrocode} +% \end{macro} +% +% \subsection{The Basic Implementation Part} +% +% Now we have to build into \LaTeXe{} the support for additional +% footnote levels. There are a number of points where the modifications +% should be done. We do all real modifications at the beginning of the +% document. Here we prepare macros needed. +% +% \subsubsection{Modifications of Output Routine} +% +% \begin{macro}{\MFL@joinnotes} +% First point of modifications is the output routine. We choose the +% strategy of joining of the additional footnotes with |\footins| +% at the points where it is really needed. The procedure +% |\MFL@joinnotes| implements this job. It will be added later to the +% beginning of |\@makecol| and |\@doclearpage| macros.\footnote{The +% version 1.2 of this package added this procedure to the beginning of +% \texttt{\bslash @specialoutput} instead of \texttt{\bslash +% @doclearpage}. It was incorrect because +% the special output routine is often called to add the next float to +% the output page without ejecting it. As a result the additional +% footnotes disappeared before floats. Thanks to Fran\c cois Patte who +% found this bug.} +% +% Since version 1.5, the |\MFL@joinnotes| has a parameter~--- +% a command the joining procedure is called before. We add a protection +% from double attempt for joining and restore the |\footnoterule| after +% execution of the parameter command. The |MFL@joined| conditional command +% is used for this purpose. Another improvement is concerned with the +% footnote rule customization procedure introduced. We now manage +% the footnote rule to be inserted before levels using the priorities. +% The default priority for the standard |\footnoterule| is defined +% with the |\footnoterulepriority| command. +% \begin{macrocode} +\newcommand{\footnoterulepriority}{1} +\newif\ifMFL@joined \MFL@joinedfalse +\def\MFL@joinnotes#1{% + \ifMFL@joined #1% + \else + \let\MFL@savedrule \footnoterule +% \end{macrocode} +% After saving a footnote rule we test the standard footnote insert, +% and prepare the current footnote rule for additional levels. +% \begin{macrocode} + \let\MFL@currule \defaultfootnoterule + \ifvoid \footins + \let\MFL@curpriority \footnoterulepriority + \else + \let\MFL@curpriority \m@ne + \fi +% \end{macrocode} +% Now we join inserts. +% \begin{macrocode} + \let\MFL@elt\@elt + \let\@elt\MFL@join \MFL@list + \let\@elt\MFL@elt +% \end{macrocode} +% And finally, we process the parameter command and restore the |\footnoterule|. +% \begin{macrocode} + \MFL@joinedtrue #1\MFL@joinedfalse + \let\footnoterule \MFL@savedrule + \fi +} +% \end{macrocode} +% The insert joining procedure simply calls the numbered join command +% linked with the insert. +% \begin{macrocode} +\def\MFL@join#1#2{\csname MFL@join\number #2\endcsname{#1}{#2}} +% \end{macrocode} +% The last one calls the |\MFL@joinrule| command with 5 parameters: +% \begin{quote} +% |\MFL@joinrule|\marg{priority}\marg{rule}\marg{action}\marg{style}\marg{register} +% \end{quote} +% First we select the rule comparing the priority of current rule and +% the new one. +% \begin{macrocode} +\def\MFL@joinrule#1#2#3#4#5{% + \ifnum #1<\MFL@curpriority \else + \let\MFL@currule#2% + \def\MFL@curpriority{#1}% + \fi + \ifvoid#5\else +% \end{macrocode} +% Well. The current insert is nonempty. At first, we calculate the skip +% of insert. Within |multicols| environment it has the size multiplied +% in |\col@number| times matching to its natural size. Therefore, we +% have to divide it by |\col@number| in such a case. +% \begin{macrocode} + \@tempskipa\skip#5% + \MFL@ifmcol{\divide\@tempskipa\col@number}{}% + \edef\MFL@skip{\vskip\the\@tempskipa\relax}% +% \end{macrocode} +% Now we process the current insert by the style processing driver +% \begin{macrocode} + \csname MFL@process#4\endcsname #5% +% \end{macrocode} +% and finally we join it with |\footins| insert and decrease the +% current priority to |-1|. +% \textit{Change request from Fank Mittelbach (version 1.11):} +% The |\footins| insert should be set globally +% for compatibility with the last version of multicol. +% \begin{macrocode} + \ifvoid\footins + \let\footnoterule\MFL@currule + \global\setbox\footins\vbox{#3\unvbox#5}% + \else + \global\setbox\footins\vbox{% + \unvbox\footins\MFL@skip\MFL@currule#3\unvbox#5% + }% + \fi + \let\MFL@curpriority \m@ne + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@reinsout} +% When the special output is called to process float insertion, all +% accumulated footnotes should be reinserted after the output box. +% This job carries out |\@reinserts| command. We will add to it +% the reinsertion of all additional footnotes with the help of +% |\MFL@reinsout| macro. Note that |\@reinserts| command is called at +% two points: when the float is the marginal note +% (|\count\@currbox|~=~0) or when it is the real float. At the second +% case we must take into account the height of all additional footnotes +% by adding it to the |\@pageht| value. +% \begin{macrocode} +\def\MFL@reinsout#1#2{\ifvoid#2\else + \ifnum\count\@currbox>\z@ + \advance\@pageht \ht#2% + \advance\@pageht \skip#2% + \advance\@pageht \dp#2% + \fi + \insert#2{\unvbox#2}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Minipages Support} +% +% \begin{macro}{\MFL@reinsert} +% The command reinserts all additional footins by adding if\/ +% necessary the empty insertion (such a way is used in |multicol|). +% It is used in |minipage| and |multicols| environments. +% The point of using it at a minipage is the beginning of the minipage. +% Using this command we release the additional footnote boxes to +% accumulate footnotes inside the minipage. +% \begin{macrocode} +\def\MFL@reinsert{{\let\@elt\MFL@reins \MFL@list}} +\def\MFL@reins#1#2{\ifvoid#2\else\insert#2{}\fi} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@mpinsert} +% Here we define the minipage insertion command which manually adds +% vbox to the insertion box. The last footnote within minipage can +% split. So, we specially enclose it into vbox and unvbox the +% previous last footnote. +% \begin{macrocode} +\long\def\MFL@mpinsert#1#2{% + \global\setbox#1\vbox{% + \unvbox#1\setbox\@tempboxa\lastbox + \ifvbox\@tempboxa \unvbox\@tempboxa \fi + \vbox{#2}% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@mpreinsert} +% This macro is useful when we really insert footnotes at the end of the +% minipage. We suppress splitting of all minipage insertions except +% the last one. To do this we extract the last box from the insertion +% box, then put another footnotes into the insert enclosing them into +% vbox, and then put the last unvboxed footnote. +% \begin{macrocode} +\def\MFL@mpreinsert#1#2{% + \ifvoid#2\else + \setbox\@tempboxa\vbox{\unvbox#2\global\setbox#2\lastbox}% + \setbox\z@\box#2% + \ifdim\ht\@tempboxa>\z@ \MFL@realinsert#2{\box\@tempboxa}\fi + \MFL@realinsert#2{\unvbox\z@}% + \fi +} +% \end{macrocode} +% Then we define two hooks which will be added to the beginning and to +% the end of a minipage. We do them in not inner mode only (for +% the first level minipages). +% \end{macro} +% +% \begin{macro}{\MFL@minipage} +% We release all box registers of the additional inserts at the +% beginning of\/ minipage to use +% them inside the minipage to accumulate inner inserts. +% \begin{macrocode} +\def\MFL@minipage{% + \ifinner\else + \MFL@reinsert \let\MFL@insert\MFL@mpinsert + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@endminipage} +% We simply reinsert all footnotes at the end of the first level +% minipage. +% \begin{macrocode} +\def\MFL@endminipage{% + \ifinner\else + {\let\@elt\MFL@mpreinsert \MFL@list}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsubsection{Multicol Package Support} +% +% \begin{macro}{\MFL@mult} +% The command modifies parameters of the insert register. +% It is useful in the scope of |multicol| package only. +% \begin{macrocode} +\def\MFL@mult#1#2{% + \multiply\count#2\col@number + \multiply\skip#2\col@number +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\MFL@ifmcol} +% The next macro tests the multicolumn mode. There are two +% conditions which have to be satisfied if we are in the multicolumn +% mode: the value of |\col@number| should be greater then 1 and the +% value of |\footins| count should be at least 2000. +% \begin{macrocode} +\def\MFL@ifmcol#1#2{\@tempswafalse + \ifnum\col@number>\@ne + \ifnum\count\footins>1999 \@tempswatrue \fi + \fi + \if@tempswa #1\else #2\fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{What Do We Do at the Beginning of Document?} +% +% \begin{macrocode} +\AtBeginDocument{% +% \end{macrocode} +% Firstly, we process starting commands for every level +% \begin{macrocode} + {\let\@elt\MFL@start \MFL@list} +% \end{macrocode} +% Then we define the |\defaultfootnoterule| to provide compatibility +% with \textbf{footmisc}. We set it equal to |\pagefootnoterule| +% or |\footnoterule|. +% \begin{macrocode} + \@ifundefined{defaultfootnoterule}{% + \@ifundefined{pagefootnoterule}% + {\let\defaultfootnoterule\footnoterule}% + {\let\defaultfootnoterule\pagefootnoterule}% + }{}% +% \end{macrocode} +% Then we modify |\@doclearpage| and |\@makecol| commands by added +% the joining algorithm at their beginning. +% \begin{macrocode} + \let\MFL@doclearpage\@doclearpage + \def\@doclearpage{\MFL@joinnotes\MFL@doclearpage} + \let\MFL@makecol\@makecol + \def\@makecol{\MFL@joinnotes\MFL@makecol} +% \end{macrocode} +% Then we modify |\@reinserts| command of the output routine to +% process reinsertion of all additional footnotes. +% \begin{macrocode} + \g@addto@macro\@reinserts{% + \let\MFL@elt\@elt + \let\@elt\MFL@reinsout \MFL@list + \let\@elt\MFL@elt + } +% \end{macrocode} +% Then we execute |\MFL@floathook| and add it into |\@floatplacement| +% command which is called when the column mode is +% changed. One important note: in the multicolumn mode of |multicol| +% package the width of footnotes is unchanged. So, we test +% this case by the command |\MFL@ifmcol|. +% \begin{macrocode} + \MFL@floathook + \g@addto@macro\@floatplacement{\MFL@ifmcol{}{\MFL@floathook}} +% \end{macrocode} +% +% The next is the |minipage| environment. We modify |\@iiiminipage| and +% |\endminipage| adding to them hooks describe earlier. +% \begin{macrocode} + \let\MFL@iminipage\@iiiminipage + \def\@iiiminipage{\MFL@minipage\MFL@iminipage} + \g@addto@macro\endminipage\MFL@endminipage +% \end{macrocode} +% +% Finally, we do some tricks to provide the compatibility with +% |multicol| package. If this package is loaded, the command +% |\multi@column@out| should be defined +% \begin{macrocode} + \@ifundefined{multi@column@out} +% \end{macrocode} +% If it is undefined, the |multicol| specific commands are not useful. +% So, we delete |\MFL@mult| command and modify |\MFL@ifmcol| command to +% choose the second case every time. +% \begin{macrocode} + {\@onlypreamble\MFL@mult \let\MFL@ifmcol\@secondoftwo} +% \end{macrocode} +% If |multicol| package presents, we add the joining algorithm to the +% beginning of |\multi@column@out| command +% \begin{macrocode} + {\let\MFL@mcolout\multi@column@out + \def\multi@column@out{\MFL@joinnotes\MFL@mcolout} +% \end{macrocode} +% and add the multiplication of additional footins parameters +% by the number of columns to the end of |\init@mult@footins| command. +% We can't do this globally. So, we save the previous value of |\@elt| +% command and then restore it after the calculation. +% We also modify |\reinsert@footnotes| command. +% \begin{macrocode} + \g@addto@macro\init@mult@footins{% + \let\MFL@elt\@elt + \let\@elt\MFL@mult \MFL@list + \let\@elt\MFL@elt + } + \g@addto@macro\reinsert@footnotes{\MFL@reinsert} + } +} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/mboxfill.dtx b/macros/latex/contrib/ncctools/source/mboxfill.dtx new file mode 100644 index 0000000000..cd831649fe --- /dev/null +++ b/macros/latex/contrib/ncctools/source/mboxfill.dtx @@ -0,0 +1,131 @@ +% \iffalse +%% +%% File: mboxfill.dtx Copyright (C) 2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{mboxfill} +% [2005/05/13 v1.0 Fill space with mbox (NCC)] +% +% \changes{v1.0}{2005/05/13}{This version was uploaded to CTAN} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{mboxfill} +\GetFileInfo{mboxfill.sty} +\begin{document} +\title{The \textsf{mboxfill} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{mboxfill.dtx} +\end{document} +% +% \fi +% +% \section{User Interface} +% +% \DescribeMacro\mboxfill +% This package implements the command +% \begin{quote} +% |\mboxfill|\oarg{width}\oarg{leader-type}\marg{pattern} +% \end{quote} +% filling a free horizontal space with \meta{pattern}. +% +% The \meta{width} parameter specifies a width of box pattern +% to be used as leaders. If it is omitted, the pattern width is used. +% The |\width|, |\height|, |\depth|, +% and |\totalheight| macros can be used in this parameter. +% Length expressions are also allowed if the \textsf{calc} +% package is loaded. +% +% The \meta{leader-type} parameter specifies a type of leaders +% to be used: |c| means |\cleaders|, |x| means |\xleaders|, and +% empty value (default) means |\leaders|. Depending on type, an +% extra space is distributed between fill entries as follows: +% in |c| case, fill entries are centered, in |x| case, fill entries +% are uniformly distributed, and in other cases, fill entries are +% aligned to the multiple of their width counted from the +% left boundary of filled box. +% +% When the specified \meta{width} differs from the pattern +% width, the pattern is centered inside the box to fill with. +% As a consequence, when |x|-leaders are used, a bit of space +% will be left from both sides of fill area. To remove this +% space, use the special value of \meta{leader-type} parameter, +% namely |s|. +% +% Example: +% \begin{quote} +% |\noindent\mboxfill{*}\mbox{}\\|\\ +% |\mbox{}\mboxfill[2\width]{+}\mbox{}\\|\\ +% |\mbox{}\mboxfill[2\width]{\hfill+}\mbox{}\\|\\ +% |\mbox{}\mboxfill[2\width]{+\hfill}\mbox{}\\|\\ +% |A text\mboxfill[1.5\width]{*}\mbox{}\\|\\ +% |\mbox{}\mboxfill[1.5\width]{*}\mbox{}\\|\\ +% |\mbox{}\mboxfill[1.5\width][c]{*}\mbox{}\\|\\ +% |\mbox{}\mboxfill[1.5\width][x]{*}\mbox{}\\|\\ +% |\mbox{}\mboxfill[1.5\width][s]{*}\mbox{}\\[-2ex]|\\ +% |\mbox{}\hrulefill| +% \end{quote} +% It produces the following: +% +% \noindent\mboxfill{*}\mbox{}\\ +% \mbox{}\mboxfill[2\width]{+}\mbox{}\\ +% \mbox{}\mboxfill[2\width]{\hfill+}\mbox{}\\ +% \mbox{}\mboxfill[2\width]{+\hfill}\mbox{}\\ +% A text\mboxfill[1.5\width]{*}\mbox{}\\ +% \mbox{}\mboxfill[1.5\width]{*}\mbox{}\\ +% \mbox{}\mboxfill[1.5\width][c]{*}\mbox{}\\ +% \mbox{}\mboxfill[1.5\width][x]{*}\mbox{}\\ +% \mbox{}\mboxfill[1.5\width][s]{*}\mbox{}\\[-2ex] +% \mbox{}\hrulefill +% +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macrocode} +%<*package> +\newcommand*\mboxfill[1][\width]{% + \def\@tempa{\setlength\@tempdima{#1}}% + \@ifnextchar[{\NCC@mboxfill}{\NCC@mboxfill[]}% +} +\def\NCC@mboxfill[#1]#2{% + \@begin@tempboxa\hbox{#2}% +% \end{macrocode} +% Set the required box width in |\@tempdima|: +% \begin{macrocode} + \@tempa +% \end{macrocode} +% Test the case of |s|-leaders. They work like |x|-leaders, +% but a special kern is added to both sides of the fill area +% to compensate extra-space added in the box. +% \begin{macrocode} + \edef\@tempa{#1}\def\@tempb{s}% + \ifx\@tempa\@tempb + \@tempdimb\width + \advance\@tempdimb -\@tempdima + \let\@tempa\xleaders + \def\@tempb{\kern.5\@tempdimb}% + \else +% \end{macrocode} +% Other cases: if leader-type is incorrect, we use |\leaders|. +% \begin{macrocode} + \@ifundefined{#1leaders}{\let\@tempa\leaders}% + {\def\@tempa{\csname#1leaders\endcsname}}% + \let\@tempb\@empty + \fi +% \end{macrocode} +% |\@tempa| contains required leaders, |\@tempb| is a kern or empty. +% Fill the space. +% \begin{macrocode} + \leavevmode\@tempb\@tempa + \hb@xt@\@tempdima{\hss\unhbox\@tempboxa\hss}\hfill\@tempb + \@end@tempboxa +} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccbbb.dtx b/macros/latex/contrib/ncctools/source/nccbbb.dtx new file mode 100644 index 0000000000..2337fdc20d --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccbbb.dtx @@ -0,0 +1,94 @@ +% \iffalse +%% +%% File: nccbbb.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccbbb} +% [2004/11/24 v1.1 Pure Black Board Bold (NCC)] +% +% \changes{v1.0}{2002/01/31}{This version was uploaded to CTAN} +% \changes{v1.1}{2004/11/24}{Bug in |\bbbz| command fixed} +% \changes{v1.1}{2004/11/24}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccbbb} +\GetFileInfo{nccbbb.sty} +\begin{document} +\title{The \textsf{nccbbb} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccbbb.dtx} +\end{document} +% +% \fi +% \section{User Interface} +% +% \DescribeMacro{\bbb...} +% The package implements the following poor black board bold math symbols: +% \begin{center} +% \begin{tabular}{l@{\qquad}c@{\qquad\vrule\qquad}l@{\qquad}c} +% Command & Symbol & Command & Symbol\\ +% |\bbbb| & $\bbbb$ & |\bbbm| & $\bbbm$ \\ +% |\bbbc| & $\bbbc$ & |\bbbn| & $\bbbn$ \\ +% |\bbbd| & $\bbbd$ & |\bbbo| & $\bbbo$ \\ +% |\bbbe| & $\bbbe$ & |\bbbp| & $\bbbp$ \\ +% |\bbbf| & $\bbbf$ & |\bbbq| & $\bbbq$ \\ +% |\bbbg| & $\bbbg$ & |\bbbr| & $\bbbr$ \\ +% |\bbbh| & $\bbbh$ & |\bbbs| & $\bbbs$ \\ +% |\bbbi| & $\bbbi$ & |\bbbz| & $\bbbz$ \\ +% |\bbbk| & $\bbbk$ & |\bbbzero| & $\bbbzero$ \\ +% |\bbbl| & $\bbbl$ & |\bbbone| & $\bbbone$ \\ +% \end{tabular} +% \end{center} +% It was designed to provide the compatibility with old macros of NCC-\LaTeX. +% We recommend use the |\mathbb| command from the |amsfonts| package +% instead. +% \StopEventually{} +% +% \section{The Implementation} +% Declare commands of the user interface: +% \begin{macrocode} +%<*package> +\newcommand\bbbb{\NCC@bbb{B}} +\newcommand\bbbc{{\NCC@bbbz{C{\NCC@bbbr{.03}{.35}{.9}{.1}}}}} +\newcommand\bbbd{\NCC@bbb{D}} +\newcommand\bbbe{\NCC@bbb{E}} +\newcommand\bbbf{\NCC@bbb{F}} +\newcommand\bbbg{{\NCC@bbbz{G{\NCC@bbbr{.05}{.3}{.88}{.09}}}}} +\newcommand\bbbh{\NCC@bbb{H}} +\newcommand\bbbi{\NCC@bbb{I}} +\newcommand\bbbk{\NCC@bbb{K}} +\newcommand\bbbl{\NCC@bbb{L}} +\newcommand\bbbm{\NCC@bbbi{M}} +\newcommand\bbbn{\NCC@bbbi{N}} +\newcommand\bbbo{{\NCC@bbbz{O{\NCC@bbbr{.05}{.3}{.9}{.09}}}}} +\newcommand\bbbp{\NCC@bbb{P}} +\newcommand\bbbq{{\NCC@bbbz{Q{\NCC@bbbr{.05}{.3}{.9}{.09}}}}} +\newcommand\bbbr{\NCC@bbb{R}} +\newcommand\bbbs{{\NCC@bbbz{S{\NCC@bbbr{.5}{.3}{.45}{.07}% + \NCC@bbbr{0}{.55}{.5}{.07}}}}} +\newcommand\bbbz{{\NCC@bbbz{{\mathsf Z}{\@tempdima\wd\z@\wd\z@ 0.33\@tempdima}}% + \mathsf Z}} +\newcommand\bbbzero{{\NCC@bbbz{O{\NCC@bbbr{.05}{.3}{.9}{.06}% + \NCC@bbbr{.05}{.6}{.9}{.06}}}}} +\newcommand\bbbone{\mathrm{1\NCC@bbbz{l{\kern -0.88\wd\z@}}}} +% \end{macrocode} +% +% Define base commands: +% \begin{macrocode} +\def\NCC@bbb#1{\mathrm{I\mskip -3.5mu#1}} +\def\NCC@bbbi#1{\mathrm{I\NCC@bbbz{{\mskip -3.5mu I}{\wd\z@\z@}}% + \mskip -3mu#1}} +\def\NCC@bbbz{\mathpalette\NCC@bbbz@} +\def\NCC@bbbz@#1#2{\NCC@bbbz@@{#1}#2} +\def\NCC@bbbz@@#1#2#3{\setbox\z@\hbox{$\m@th#1{\mathrm{#2}}$}#3\box\z@} +\def\NCC@bbbr#1#2#3#4{\raise #1\ht\z@\hbox to \z@{\kern #2\wd\z@ + \vrule \@height #3\ht\z@ \@width #4\wd\z@\hss}} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccboxes.dtx b/macros/latex/contrib/ncctools/source/nccboxes.dtx new file mode 100644 index 0000000000..da1a1b8ff0 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccboxes.dtx @@ -0,0 +1,428 @@ +% \iffalse +%% +%% File: nccboxes.dtx Copyright (C) 2002--2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccboxes} +% [2005/02/07 v1.2 Additional Boxes (NCC)] +% +% \changes{v1.03}{2002/01/29}{This version is uploaded to CTAN} +% \changes{v1.04}{2002/03/20}{Internal changes in |\jvbox|} +% \changes{v1.04}{2002/03/20}{The |\jparbox| command introduced} +% \changes{v1.05}{2002/05/24}{Bug in |\jparbox| (incorrect width) fixed} +% \changes{v1.1}{2004/11/28}{Documentation was prepared} +% \changes{v1.2}{2005/02/07}{Add |\tc| command} +% \changes{v1.2}{2005/02/07}{Allow lengthes in the Strut parameter} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccboxes} +\GetFileInfo{nccboxes.sty} +\begin{document} +\title{The \textsf{nccboxes} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccboxes.dtx} +\end{document} +% +% \fi +% +% The package implement special boxes and struts from NCC-\LaTeX. +% +% \section{User Interface} +% +% \DescribeMacro{\jhbox} +% This macro specifies a horizontal box whose width is calculate +% using a prototype and alignment position is specified in the same manner +% as in the |\makebox| command. The syntax: +% \begin{quote} +% |\jhbox|\marg{prototype}\oarg{pos}\marg{text} +% \end{quote} +% Here \meta{prototype} is a text whose width will be the width of generated +% box, \meta{pos} is an alignment parameter (|l|, |c|, |r|, or |s|; +% default is |c|). +% +% \DescribeMacro{\jvbox} +% This macro specifies a horizontal box whose height, depth, and vertical +% alignment is calculated using a prototype. The syntax: +% \begin{quote} +% |\jvbox|\marg{prototype}\oarg{pos}\marg{text} +% \end{quote} +% The \meta{text} argument is vertically aligned with respect to the +% strut defined by the \meta{prototype} parameter. The optional +% \meta{pos} parameter defines an alignment position +% (|t|, |c|, or |b|; default is |c|). If |t| is used, the \meta{text} is +% raised in such a way that its height will be equal to the height of +% the prototype's strut. For the |b| case, the depths will be equal, and, +% for the |c| case, the \meta{text} is vertically centered with respect to +% the prototype's strut. The height and depth of the prepared box are +% calculated as a maximum between the corresponding parameters of the +% \meta{prototype} and the vertically adjusted \meta{text}. +% +% \DescribeMacro{\jparbox} +% This macro prepares a paragraph box of the required width and +% vertically aligns it with respect to the prototype just in the same manner +% as the |\jvbox|. The syntax: +% \begin{quote} +% |\jparbox|\marg{prototype}\oarg{pos}\marg{width}\marg{text} +% \end{quote} +% The \meta{prototype} and \meta{pos} parameters have the same meaning +% as described for |\jvbox|. The \meta{width} is the width +% of the paragraph box and the \meta{text} is the box content.\pagebreak +% +% \DescribeMacro{\addbox} +% This macro specifies a horizontal box whose height and depth are +% adjusted using the given values. The syntax: +% \begin{quote} +% |\addbox|\marg{height-adjust}\marg{depth-adjust}\marg{text} +% \end{quote} +% For example, |\addbox{.5ex}{.5ex}{text}| increases the height +% and depth of produced box on |0.5ex|. +% +% \DescribeMacro{\pbox} +% This macro implements a simple one-column table. The syntax: +% \begin{quote} +% |\pbox|\oarg{pos}\marg{body} +% \end{quote} +% The \meta{pos} parameter may consist of two letters defining +% a relative alignment of the table rows in the column +% (|l|, |c|, or |r|) and the vertical alignment of the whole table +% with respect to surrounding text (|t|, |c|, or |b|). +% Centering is the default alignment. The distance between +% table rows does not depend on the |\arraystretch| value. +% +% \DescribeMacro{\picbox} +% The |\picbox|\marg{body} macro is equivalent to +% \begin{quote} +% |\begin{picture}(0,0)(0,0)|\meta{body}|\end{picture}|. +% \end{quote} +% +% To prepare fancy tables, the following commands can be used: +% +% \DescribeMacro{\Strut} +% \DescribeMacro{\Strutletter} +% The |\Strut/|\meta{value}|/| command is a special strut whose +% height and depth are calculated from the strut prototype +% command |\Strutletter| (letter |A| by default) as follows: +% if \meta{value} is positive, the full height of the current +% |\strutbox| multiplied by the \meta{value} is added to the +% height of strut prototype, otherwise the depth of strut prototype +% increases with the modulus of \meta{value} multiplied +% by the full height of |\strutbox|. For example, +% |\Strut/1/| inserts a strut which height exceeds the height +% of the letter |A| from the current font on the interline distance. +% A natural length is also possible as a value of |\Strut|'s +% parameter. So, the |\Strut/2mm/| means a strut with the height +% exceeding the height of strut letter over 2~mm. +% The |\Strut| without parameter is equal to |\Strut/0/|. +% Spaces after the |\Strut| are ignored. +% +% \DescribeMacro{\tstrut} +% \DescribeMacro{\bstrut} +% \DescribeMacro{\tbstrut} +% \DescribeMacro{\Strutstretch} +% The |\tstrut|, |\bstrut|, and |\tbstrut| commands insert +% struts exceeding the height, depth, and both height and depth +% of the strut prototype |\Strutletter| by a special small amount. +% This amount is calculated in such a way that the full height +% of |\tbstrut| will be equal to 1.5 of full height of the +% current |\strutbox|. The stretch factor 1.5 is specified in +% the |\Strutstretch| command. These commands are used in tables +% to insert a space between a horizontal line and a table row. +% But if the height and depth of row contents exceeds the +% height and depth of inserted strut, the inserted strut will +% take no effect. +% +% \DescribeMacro{\cbox} +% The |\cbox/|\meta{value}|/|\oarg{pos}\marg{body} command +% prepares a box whose body is a one-column table. Its height and +% depth are enlarged using |\tstrut| at the beginning and +% |\bstrut| at the end of body. The horizontal alignment +% (|l|, |c|, or |r|) in the column and the vertical +% alignment (|t|, |c|, or |b|) are defined in the +% \meta{pos} parameter. Centered alignment is used by +% default. The resulting box is vertically aligned with +% respect to the |\Strut/|\meta{value}|/| using the +% |\jvbox| command. The |\cbox*| command does the same +% but vanishes the height and depth of the resulting box. +% The |\cbox| command is used in the headers of tables. +% Its star form is useful in cells having vertical spans. +% +% \DescribeMacro{\cboxstyle} +% The |\cboxstyle| specifies a style applied to all +% |\cbox| commands. It can set a font size, shape, color, +% etc. The default value of |\cboxstyle| is empty. +% +% We demonstrate the usage of struts and |\cbox| on the +% following example: +% \begin{center}\catcode`|=12 +% \renewcommand\cboxstyle{\small\bf} +% \setlength{\tabcolsep}{10pt} +% \begin{tabular}{|l|c|c|c|}\hline +% \cbox*/-1.5/{Vertically\\spanned head} & \cbox{Simple head} +% &\multicolumn2{c|}{\cbox{Very long head\\of two lines}}\\\cline{2-4} +% &\cbox{subhead} &\cbox{subhead} &\cbox{subhead}\\\hline +% \Strut/1/ Text & field & field & field \\ +% Text & field & field & field \\ +% \bstrut Text & field & field & field \\\hline +% \end{tabular} +% \end{center} +% It was produced as follows: +% \begin{quote} +% |\begin{center}|\\ +% | \renewcommand\cboxstyle{\small\bf}|\\ +% | \setlength{\tabcolsep}{10pt}|\\ +% \verb+ \begin{tabular}{|l|c|c|c|}\hline+\\ +% | \cbox*/-1.5/{Vertically\\spanned head} & \cbox{Simple head}|\\ +% \verb+ &\multicolumn2{c|}{\cbox{Very long head\\of two lines}}\\+\\ +% | \cline{2-4}|\\ +% | &\cbox{subhead} &\cbox{subhead} &\cbox{subhead}\\\hline|\\ +% | \Strut/1/ Text & field & field & field \\|\\ +% | Text & field & field & field \\|\\ +% | \bstrut Text & field & field & field \\\hline|\\ +% | \end{tabular}|\\ +% |\end{center}| +% \end{quote} +% +% \DescribeMacro{\tc} +% To center a table field, the |\tc|\marg{field} command is introduced +% since version 1.2 of the package. It inserts |\hspace*{\fill}| +% before and after the \meta{field}. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\addbox} +% The implementation of +% |\addbox|\marg{height-adjust}\marg{depth-adjust}\marg{text}. +% We use the |\setlength| in calculations +% of box's height and depth for compatibility with the |calc| +% package. +% \begin{macrocode} +%<*package> +\newcommand*{\addbox}[3]{% + \@begin@tempboxa\hbox{#3}% + \setlength\@tempdima{#1}% + \advance\@tempdima \ht\@tempboxa + \ht\@tempboxa \@tempdima + \setlength\@tempdima{#2}% + \advance\@tempdima \dp\@tempboxa + \dp\@tempboxa \@tempdima + \leavevmode\box\@tempboxa + \@end@tempboxa +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\jhbox} +% The implementation of |\jhbox|\marg{prototype}\oarg{pos}\marg{text} +% is very simple: +% \begin{macrocode} +\newcommand*{\jhbox}[1]{\settowidth\@tempdima{#1}\makebox[\@tempdima]} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\jvbox} +% The |\jvbox|\marg{prototype}\oarg{pos}\marg{text} is implemented +% as follows. We prepare a vertical strut +% in zero box using the \meta{prototype}. Then we vertically adjust the +% content of the |\jvbox| and put the strut and the adjusted box. +% \begin{macrocode} +\newcommand*{\jvbox}[1]{% + \setbox\z@\hbox{\color@begingroup#1\color@endgroup}% + \setbox\z@\hbox{\vrule \@width\z@ \@height\ht\z@ \@depth\dp\z@}% + \NCC@jvbox +} +\newcommand*{\NCC@jvbox}[2][]{% + \setbox\@tempboxa\hbox{\color@begingroup#2\color@endgroup}% + \let\m@t\vss \let\m@b\vss + \@tfor\@tempa :=#1\do {% + \expandafter\let\csname m@\@tempa\endcsname\relax}% + \@tempdima\ht\z@ \advance\@tempdima -\ht\@tempboxa + \ifx\m@t\relax \else + \@tempdimb\dp\@tempboxa \advance\@tempdimb -\dp\z@ + \ifx\m@b\relax \@tempdima \@tempdimb \else + \advance\@tempdimb \@tempdima \@tempdima .5\@tempdimb + \fi + \fi + \leavevmode \box\z@ \raise\@tempdima\box\@tempboxa +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\jparbox} +% The implementation of +% |\jparbox|\marg{prototype}\oarg{pos}\marg{width}\marg{body} +% is based on |\jvbox|, but we prepare the +% \meta{body} in the vertical box. +% \begin{macrocode} +\newcommand*{\jparbox}[1]{% + \@ifnextchar[{\NCC@jparbox{#1}}{\NCC@jparbox{#1}[]}% +} +\long\def\NCC@jparbox#1[#2]#3#4{% + \@begin@tempboxa\vtop{\setlength\@tempdima{#3}% + \hsize\@tempdima\@parboxrestore#4\@@par}% + \setlength\@tempdima{#3}% vbox containing only display equations can + \wd\@tempboxa\@tempdima % have lesser width. We correct it here + \jvbox{#1}[#2]{\box\@tempboxa}% + \@end@tempboxa +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\pbox} +% Now we implement the |\pbox|\oarg{pos}\marg{body} command. +% It is a simple one-column table. The |\arraystretch| +% has no effect on it. The \meta{pos} is a combination of +% vertical (tbc) and horizontal (lcr) positions. For example, +% |lt| means left adjusted table with first line on the base line. +% \begin{macrocode} +\newcommand*{\pbox}[2][]{% + \let\m@l\hss \let\m@r\hss \let\m@t\vss \let\m@b\vss + \@tfor\@tempa:=#1\do{% + \expandafter\let\csname m@\@tempa\endcsname\relax% + }% + \leavevmode\hbox{\color@begingroup + $\ifx\m@t\relax \vtop \else\ifx\m@b\relax \vbox\else \vcenter\fi\fi + \bgroup \baselineskip\z@\lineskip\z@ + \def\\{\strut\@stackcr}% + \halign{\m@l\ignorespaces ##\unskip\m@r\cr #2\strut\crcr}% + \egroup$\color@endgroup + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\picbox} +% The |\picbox|\marg{body} command: +% \begin{macrocode} +\newcommand*{\picbox}[1]{% + \setbox\@tempboxa\hb@xt@\z@{\ignorespaces#1\hss}% + \ht\@tempboxa\z@\dp\@tempboxa\z@ + \leavevmode\box\@tempboxa +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Strutletter} +% \begin{macro}{\Strutstretch} +% Here we specify macros for preparing special struts. +% The |\Strutletter| is the prototype for special struts. +% The |\Strutstretch| is a stretch of line height in |\cbox| +% with respect to |\strut|. We prepare special struts in +% the |\NCC@strutbox|. The |\NCC@strutsep| is a half +% of difference between stretched |\strut| and the full height +% of the |\Strutletter|. +% \begin{macrocode} +\newcommand{\Strutletter}{A} +\newcommand{\Strutstretch}{1.5} +\newsavebox\NCC@strutbox +\newdimen\NCC@strutsep +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@setstrut} +% The |\NCC@setstrut|\marg{command}|/|\meta{value}|/| +% tests the sequence |/|\meta{value}|/|, prepares the specified +% strut in the |\NCC@strutbox|, calculates the |\NCC@strutsep|, +% and then calls the \meta{command}. +% The |/|\meta{value}|/| sequence is optional. If it is omitted, +% |/0/| is supposed. +% \begin{macrocode} +\def\NCC@setstrut#1{% + \setbox\NCC@strutbox\hbox{\vphantom{\Strutletter}}% + \@tempdima\ht\strutbox \advance\@tempdima\dp\strutbox + \NCC@strutsep \Strutstretch\@tempdima + \advance\NCC@strutsep -\ht\NCC@strutbox + \advance\NCC@strutsep -\dp\NCC@strutbox + \NCC@strutsep .5\NCC@strutsep + \@ifnextchar/{\NCC@setstrutn{#1}}{\NCC@setstrutl{#1}\z@}% +} +\def\NCC@setstrutn#1/#2/{\NCC@setstrutl{#1}{#2\@tempdima}} +\def\NCC@setstrutl#1#2{% + \@defaultunits\@tempdima#2\relax\@nnil + \ifdim\@tempdima>\z@ + \advance\@tempdima \ht\NCC@strutbox + \ht\NCC@strutbox \@tempdima + \else + \@tempdima -\@tempdima + \advance\@tempdima \dp\NCC@strutbox + \dp\NCC@strutbox \@tempdima + \fi + #1% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Strut} +% Now we define the |\Strut/|\meta{value}|/|. +% It is quite simple: +% \begin{macrocode} +\newcommand{\Strut}{% + \NCC@setstrut{\leavevmode\copy\NCC@strutbox\ignorespaces}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\tstrut} +% \begin{macro}{\bstrut} +% \begin{macro}{\tbstrut} +% Next we define |\tstrut|, |\bstrut|, and |\tbstrut| via the |\addbox| +% command. All these struts use the |\NCC@setstrut| to calculate +% special strut parameters. +% \begin{macrocode} +\newcommand{\tstrut}{% + \NCC@setstrut{}\addbox\NCC@strutsep\z@{\copy\NCC@strutbox}% +} +\newcommand{\bstrut}{% + \NCC@setstrut{}\addbox\z@\NCC@strutsep{\copy\NCC@strutbox}% +} +\newcommand{\tbstrut}{% + \NCC@setstrut{}\addbox\NCC@strutsep\NCC@strutsep{\copy\NCC@strutbox}% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cbox} +% \begin{macro}{\cboxstyle} +% Now, we define the +% |\cbox/|\meta{value}|/|\oarg{pos}\marg{body} command and its +% star-form. It is useful in headers of tables. The |\cboxstyle| is +% a styling command applied to every |\cbox|. +% \begin{macrocode} +\newcommand{\cboxstyle}{} +\newcommand{\cbox}{% + \@ifstar{\def\@tempa{\ht\@tempboxa\z@ \dp\@tempboxa\z@}\NCC@xcbox}% + {\let\@tempa\relax\NCC@xcbox}% +} +\def\NCC@xcbox{% + \leavevmode \hbox\bgroup\color@begingroup + \cboxstyle\NCC@setstrut{\NCC@ycbox}% +} +\newcommand*{\NCC@ycbox}[2][]{% + \setbox\@tempboxa\hbox{% + \jvbox{\addbox\NCC@strutsep\NCC@strutsep{\copy\NCC@strutbox}}[#1]% + {\pbox[#1t]{\tstrut\ignorespaces #2\unskip\bstrut}}}% + \@tempa \box\@tempboxa + \color@endgroup\egroup +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\tc} +% And finally, we define the |\tc|\marg{field} command. +% \begin{macrocode} +\newcommand{\tc}[1]{\hspace*{\fill}#1\hspace*{\fill}} +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/ncccomma.dtx b/macros/latex/contrib/ncctools/source/ncccomma.dtx new file mode 100644 index 0000000000..8488370b2f --- /dev/null +++ b/macros/latex/contrib/ncctools/source/ncccomma.dtx @@ -0,0 +1,101 @@ +% \iffalse +%% +%% File: ncccomma.dtx Copyright (C) 2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{ncccomma} +% [2005/02/10 v1.0 Smart Math Comma Package (NCC)] +% +% \changes{v1.0}{2005/02/10}{Initial version} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{ncccomma} +\GetFileInfo{ncccomma.sty} +\begin{document} +\title{The \textsf{ncccomma} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{ncccomma.dtx} +\end{document} +% +% \fi +% +% The package implements the smart comma in math mode. +% Let us compare this solution with the concurrent solution from +% the |icomma| package by Walter Schmidt: +% \begin{itemize} +% \item In |icomma|, a comma in math works as the +% punctuation mark if a space goes after it. Otherwise, +% it work as an ordinary character; +% \item In |ncccomma|, a comma in math works as an ordinary +% character if a decimal character goes after it. +% Otherwise, it works as a punctuation mark. +% \end{itemize} +% The solution used in this package is more expansive because +% we compare the next character with up to ten decimal chars. +% But this solution needs less number of spaces to be inserted into +% original document (the space is only necessary in the place +% of a comma delimiting something and a decimal number). +% +% \DescribeMacro{\mathcomma} +% The original math comma is saved in the |\mathcomma| macro. +% This macro is useful together with the |dcolumn| package. +% If a comma should be \emph{printed} as the +% decimal separator in a column of type |D|, it must be specified +% as |{\mathcomma}|, rather than |{,}|, since the latter +% leads to an error. For example: +% \begin{quote} +% |\begin{tabular}{D{,}{\mathcomma}{-1}}| +% \end{quote} +% +% \DescribeMacro{\ordcommalist} +% The list of decimal characters is saved in the |\ordcommalist|. +% It initial definition is +% \begin{quote} +% |\newcommand\ordcommalist{0123456789}| +% \end{quote} +% You can redefine it if necessary. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% We save the original comma in |\mathcomma| and then specify +% the comma to be an active char in math. +% \begin{macrocode} +%<*package> +\mathchardef\mathcomma\mathcode`\, +\mathcode`\,="8000 +% \end{macrocode} +% No we define the meaning of comma using the well-known trick with +% upper case. +% \begin{macrocode} +\bgroup + \uccode`\~`\,% + \uppercase{% +\egroup + \def~}{\futurelet\@let@token\NCC@comma} +% \end{macrocode} +% The smart comma compares the next char with a character of the +% |\ordcommalist| in cycle. This cycle is a bit expansive, +% but it is the payment for smartness. +% \begin{macrocode} +\newcommand\ordcommalist{0123456789} +\def\NCC@comma{% + \let\@tempb\@empty + \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=% + \ordcommalist\do{% + \expandafter\ifx\@tempa\@let@token + \let\@tempb\mathord \@break@tfor + \fi + }% + \@tempb\mathcomma +} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/ncccropbox.dtx b/macros/latex/contrib/ncctools/source/ncccropbox.dtx new file mode 100644 index 0000000000..e0c80dbd48 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/ncccropbox.dtx @@ -0,0 +1,167 @@ +% \iffalse +%% +%% File: ncccropbox.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{ncccropbox} +% [2004/11/24 v1.1 Crop Box Package (NCC)] +% +% \changes{v1.02}{2002/01/31}{This version is uploaded to CTAN} +% \changes{v1.03}{2002/02/08}{The package is renamed to ncccropbox} +% \changes{v1.1}{2004/11/24}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{ncccropbox} +\GetFileInfo{ncccropbox.sty} +\begin{document} +\title{The \textsf{ncccropbox} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{ncccropbox.dtx} +\end{document} +% +% \fi +% +% \section{User Interface} +% +% \DescribeMacro{\cropbox} +% The package implements the command +% \begin{quote} +% |\cropbox|\oarg{width}\oarg{height}\marg{content} +% \end{quote} +% preparing a horizontal box with crop-marks at its corners looking like angles. +% The crop-box is aligned at the bottom and is lowered at the |\lineskip| value. +% The optional \meta{width} and \meta{height} parameters specify the width and +% height of the crop-box respectively. If some of them is omitted or is +% empty, the width or height of the crop-box \meta{content} is used for calculation +% the omitted dimension. In this case, the doubled value of the +% \textit{crop-box separation\/} parameter is added to the natural dimension +% of the box's \meta{content}. The \meta{content} is centered inside the crop-box. +% +% \DescribeMacro{\cropboxsep} +% The |\cropboxsep|\marg{length} command specifies the separation value to be used +% in calculation of crop-box dimensions when any of optional parameters is +% omitted or empty. The default is |\cropboxsep{5pt}|. +% +% \DescribeMacro{\croplinewidth} +% The |\croplinewidth|\marg{length} command specifies a width of crop-lines. +% The default is |\croplinewidth{.4pt}|. +% +% \DescribeMacro{\croplinelength} +% The |\croplinelength|\marg{length} command specifies a length and direction +% of crop-lines: the absolute value of \meta{length} specifies +% a length of crop-lines and the sign of \meta{length} specifies a direction. +% If the \meta{length} is negative, the angles look outside the crop-box. +% Otherwise, they look inside the crop-box. +% +% The following example shows how crop-boxes are docked together: +% \begin{center} +% \cropbox[30mm][10mm]{Box 1}\cropbox[30mm][10mm]{Box 2}\cropbox[30mm][10mm]{Box 3}\cropbox[30mm][10mm]{Box 4}\\ +% \cropbox[30mm][10mm]{Box 5}\cropbox[30mm][10mm]{Box 6}\cropbox[30mm][10mm]{Box 7}\cropbox[30mm][10mm]{Box 8} +% \end{center} +% It was prepared as follows: +% \begin{quote} +% |\begin{center}|\\ +% |\cropbox[30mm][10mm]{Box 1}\cropbox[30mm][10mm]{Box 2}%|\\ +% |\cropbox[30mm][10mm]{Box 3}\cropbox[30mm][10mm]{Box 4}\\|\\ +% |\cropbox[30mm][10mm]{Box 5}\cropbox[30mm][10mm]{Box 6}%|\\ +% |\cropbox[30mm][10mm]{Box 7}\cropbox[30mm][10mm]{Box 8}|\\ +% |\end{center}| +% \end{quote} +% You can see that crop-lines of neighbour boxes exactly coincide. +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\croplinelength} +% \begin{macro}{\croplinewidth} +% \begin{macro}{\cropboxsep} +% Styling macros: +% \begin{macrocode} +%<*package> +\newcommand*{\croplinelength}[1]{\def\CRB@length{#1}} +\newcommand*{\croplinewidth}[1]{\def\CRB@width{#1}} +\newcommand*{\cropboxsep}[1]{\def\CRB@sep{#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\cropbox} +% The |\cropbox| command: +% \begin{macrocode} +\newcommand*{\cropbox}[1][]{\@ifnextchar[{\CRB@box[#1]}{\CRB@box[#1][]}} +\def\CRB@box[#1][#2]#3{% +% \end{macrocode} +% Calculate crop-box dimensions in |\@tempdima| and |\@tempdimb|: +% \begin{macrocode} + \@begin@tempboxa\hbox{#3}% + \def\@tempa{#1}\ifx\@tempa\@empty + \@tempdima\width \advance\@tempdima 2\CRB@sep\relax + \else + \setlength\@tempdima{#1}% + \fi + \def\@tempa{#2}\ifx\@tempa\@empty + \@tempdimb\totalheight \advance\@tempdimb 2\CRB@sep\relax + \else + \setlength\@tempdimb{#2}% + \fi +% \end{macrocode} +% Prepare crop-marks in 0th box of zero width: +% \begin{macrocode} + \setbox\z@\hb@xt@\z@{% + \linethickness{\CRB@width}% + \setlength\unitlength{\CRB@length}% + \ifdim\unitlength=\z@ \else + \ifdim\unitlength>\z@ + \CRB@hcross\z@\z@\@ne\@ne + \CRB@hcross\@tempdima\z@\m@ne\@ne + \CRB@hcross\z@\@tempdimb\@ne\m@ne + \CRB@hcross\@tempdima\@tempdimb\m@ne\m@ne + \else \unitlength -\unitlength + \CRB@hcross\z@\z@\m@ne\m@ne + \CRB@hcross\@tempdima\z@\@ne\m@ne + \CRB@hcross\z@\@tempdimb\m@ne\@ne + \CRB@hcross\@tempdima\@tempdimb\@ne\@ne + \fi + \fi + }% +% \end{macrocode} +% Put crop-marks as a background for vertical box containing the +% crop-box content. We decrease the height of vertical box on +% the |\lineskip| to make the exact docking of vertically neighbour +% crop-boxes. +% \begin{macrocode} + \leavevmode \ht\z@\z@ \dp\z@\z@ \box\z@ + \advance\@tempdimb -\lineskip + \vbox to\@tempdimb{\vss\vskip -\lineskip + \hb@xt@\@tempdima{\hss\unhbox\@tempboxa\hss}\vss\kern\z@ + }% + \@end@tempboxa +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\CRB@hcross} +% This command prepares a crop-mark. +% \begin{macrocode} +\def\CRB@hcross#1#2#3#4{% + \@killglue\raise#2\hb@xt@\z@{\kern#1\line(#3,0)\@ne\hss}\hss + \@killglue\raise#2\hb@xt@\z@{\kern#1\line(0,#4)\@ne\hss}\hss +} +% \end{macrocode} +% \end{macro} +% +% Initial settings: +% \begin{macrocode} +\croplinelength{10pt} +\croplinewidth{.4pt} +\cropboxsep{5pt} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/ncccropmark.dtx b/macros/latex/contrib/ncctools/source/ncccropmark.dtx new file mode 100644 index 0000000000..735bb5d75a --- /dev/null +++ b/macros/latex/contrib/ncctools/source/ncccropmark.dtx @@ -0,0 +1,156 @@ +% \iffalse +%% +%% File: ncccropmark.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{ncccropmark} +% [2004/11/29 v1.1 Cropmarks (NCC)] +% +% \changes{v1.02}{2002/01/31}{This version is uploaded to CTAN} +% \changes{v1.03}{2002/02/08}{The package is renamed to ncccropbox} +% \changes{v1.1}{2004/11/29}{Bug fix on misusing the bottom skip instead of top one} +% \changes{v1.1}{2004/11/29}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{ncccropmark,watermark} +\GetFileInfo{ncccropmark.sty} +\begin{document} +\title{The \textsf{ncccropmark} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{ncccropmark.dtx} +\end{document} +% +% \fi +% +% \watermark{\cropmark[f]{10mm}{10mm}{10mm}{10mm}{5mm} +% \cropmark[f]{10mm}{10mm}{10mm}{10mm}{-5mm}} +% \thiswatermark{\cropmark[f]{10mm}{10mm}{10mm}{10mm}{5mm}} +% +% \section{User Interface} +% +% \DescribeMacro{cropmark} +% The package implements the command +% \begin{quote} +% |\cropmark|\oarg{fields}\marg{left}\marg{right}\marg{top}\marg{bottom}\marg{length} +% \end{quote} +% useful as a watermark. The command was desired for use together with the +% |watermark| package. It must be called inside the picture environment +% (a watermark content is prepared in such a way). +% +% The optional \meta{fields} parameter contains a combination of letters +% |h| (header), |f| (footer), and |m| (marginal notes). +% It determines the additional fields of paper area to be taken into account +% in crop area when the crop-mark is typed out. If the optional parameter is omitted, +% the crop area coincides with the text area only. +% +% Next four parameters mean padding values for crop-mark corners with respect to +% the crop area and the last parameter is equal to crop lines length. +% Its positive value means crop-mark corners looking on the crop area. +% Otherwise, the corners look outside of the crop area. +% To prepare crosses, you need to use the crop-mark twice with positive +% and negative values. +% +% In two-side mode the left and right padding are swapped for +% every even page. +% +% For example, |\watermark{\cropmark[f]{10mm}{10mm}{10mm}{10mm}{5mm}}| +% means a crop-mark indented on 10mm in all directions from the crop area +% containing the text area and the page footer. You can see the result +% on this page. The crosses on the next page were prepared with +% the following command: +% \begin{quote} +% |\watermark{\cropmark[f]{10mm}{10mm}{10mm}{10mm}{5mm}|\\ +% | \cropmark[f]{10mm}{10mm}{10mm}{10mm}{-5mm}}| +% \end{quote} +% \StopEventually{} +% +% \section{The Implementation} +% This package requires the |ncccropbox| package to prepare a +% crop-mark and the |tocenter| package to calculate crop-area +% dimensions. +% \begin{macrocode} +%<*package> +\RequirePackage{ncccropbox,tocenter} +% \end{macrocode} +% +% \begin{macro}{\cropmark} +% We suppose here that the |\cropmark| will be +% used at the beginning of header. The |\NCC@pos| command +% from the |tocenter| package parses the \meta{fields} parameter +% and prepares |\NCC@h|\marg{register}, |\NCC@f|\marg{register}, +% and |\NCC@m|\marg{register} commands to adjust values of skip +% registers. See the |tocenter| package for more details. +% \begin{macrocode} +\newcommand*{\cropmark}[6][]{\NCC@pos{#1}% +% \end{macrocode} +% At the first, we calculate the width of crop-box and the +% left skip from the beginning of header. +% The |\@tempswatrue| means reverse left and right paddings. +% \begin{macrocode} + \@tempswafalse + \if@twoside \ifodd\c@page \else \@tempswatrue \fi\fi +% \end{macrocode} +% Set |\@tempdima| to the left padding and |\@tempdimb| to the right +% padding. +% \begin{macrocode} + \if@tempswa + \setlength{\@tempdima}{#3}% + \setlength{\@tempdimb}{#2}% + \else + \setlength{\@tempdima}{#2}% + \setlength{\@tempdimb}{#3}% + \fi +% \end{macrocode} +% Adjust values of |\@tempdima| and |\@tempdimb| with margin +% widths: +% \begin{macrocode} + \if@twocolumn + \NCC@m\@tempdima \NCC@m\@tempdimb + \else + \if@tempswa + \if@reversemargin \NCC@m\@tempdimb \else \NCC@m\@tempdima \fi + \else + \if@reversemargin \NCC@m\@tempdima \else \NCC@m\@tempdimb \fi + \fi + \fi +% \end{macrocode} +% Calculate the left skip in |\@tempskipa| and the crop-box width +% in |\@tempdima|: +% \begin{macrocode} + \@tempskipa -\@tempdima + \advance\@tempdima\@tempdimb + \advance\@tempdima\textwidth +% \end{macrocode} +% Now we calculate the height of crop-box in the |\@tempdimb| register +% and the bottom skip in the |\@tempskipb| register: +% \begin{macrocode} + \@tempdimb\headsep + \advance\@tempdimb\textheight + \NCC@f\@tempdimb + \addtolength{\@tempdimb}{#5}% + \@tempskipb -\@tempdimb + \advance\@tempdimb -\headsep + \NCC@h\@tempdimb + \addtolength{\@tempdimb}{#4}% +% \end{macrocode} +% All necessary calculations are done. Put the crop-box at +% the relative position |\@tempskipa,\@tempskipb|: +% \begin{macrocode} + \begingroup + \croplinelength{#6}% + \lineskip\z@ + \@killglue\raise\@tempskipb + \hb@xt@\z@{\kern\@tempskipa + \cropbox[\@tempdima][\@tempdimb]{}\hss}\hss% + \endgroup +} +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccfancyhdr.dtx b/macros/latex/contrib/ncctools/source/nccfancyhdr.dtx new file mode 100644 index 0000000000..877e367184 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccfancyhdr.dtx @@ -0,0 +1,1056 @@ +% \iffalse +%% +%% File: nccfancyhdr.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccfancyhdr} +% [2004/12/07 v1.1 Improved Fancy Header Package (NCC)] +% +% \changes{v1.00}{2002/02/01}{This version was uploaded to CTAN} +% \changes{v1.01}{2002/02/07}{|\fancycenter| command added} +% \changes{v1.01}{2002/02/07}{Header and footer struts are moved out of par-boxes} +% \changes{v1.1}{2004/12/07}{The |\newpagestyle| command added} +% \changes{v1.1}{2004/12/07}{The |\headrule| and |\footrule| commands added} +% \changes{v1.1}{2004/12/07}{Add optional \meta{stretch} parameter in |\fancycenter|} +% \changes{v1.1}{2004/12/07}{Remove |\fancycentersep| and |\fancycenterstretch| macros} +% \changes{v1.1}{2004/12/07}{Add conditional testing of floats within |testfloats| option} +% \changes{v1.1}{2004/12/07}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccboxes} +\usepackage[headings]{nccfancyhdr} +\newpagestyle{lheadings}[headings]{% + \fancyhead[ce]{\nouppercase{\fancycenter{\thepage}{}{\slshape\leftmark}}}% + \fancyhead[co]{\nouppercase{\fancycenter{\slshape\rightmark}{}{\thepage}}}% +} +\pagestyle{lheadings} +\addtolength{\headwidth}{\marginparsep} +\addtolength{\headwidth}{0.6\marginparwidth} +\renewcommand{\headrulewidth}{0.6pt} +\makeatletter +\renewcommand{\headrule}{% + \setlength\@tempdima{\headrulewidth}% + \hrule\@height\@tempdima\@width\headwidth + \vskip 2\@tempdima + \hrule\@height\@tempdima\@width\headwidth + \vskip -4\@tempdima +} +\makeatother +\GetFileInfo{nccfancyhdr.sty} +\begin{document} +\title{The \textsf{nccfancyhdr} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccfancyhdr.dtx} +\end{document} +% +% \fi +% This package is originated on the |fancyhdr| package by Piet van Oostrum. +% It provides almost the same functionality but implements it in more safe +% and simple way. +% The most important reason for re-implementation the |fancyhdr| was that +% |fancy| page style breaks conventions on page styles definition: +% avoiding global definitions in page styling commands. If this contract is +% broken, a page style cannot be used locally as a parameter of the +% |\thispagestyle| command. Other reasons for such re-implementation were +% the following: some commands in |fancyhdr| do more than it is +% necessary (e.g.\ the |fancy| page style redefines section marks), +% incorrect vertical alignment in headers leads to raising headers a bit +% (this produces a page overfull if header height is exactly the same as +% a height of text in it), some features introduced in the |fancyhdr| +% are unsafe (a special cycle |\@forc| is introduced with the |\def| +% command), and the implementation of commands is frequently too +% complicated. All these disadvantages of |fancyhdr| set off me to +% prepare a new version of |fancyhdr| packaged named as the |nccfancyhdr|. +% +% \tableofcontents +% +% \section{Using the Package} +% +% \thispagestyle{plain} +% The package supports three-part headers and footers separated +% from the text area with optional decorative lines. Using fancy headers +% and footers you can easy customize page layout. +% +% The first and the most useful benefit of fancy page styles is +% the possibility of decoration of headers and footers with a rule. +% If you want to add +% a rule to some of standard page styles (|empty|, |plain|, |myheadings|, +% and |headings|), put their names in the list of +% options of the |\usepackage| command: +% \begin{quote} +% |\usepackage|\oarg{style-list}|{nccfancyhdr}| +% \end{quote} +% For example, the command +% \begin{quote} +% |\usepackage[plain,headings]{nccfancyhdr}| +% \end{quote} +% loads the |nccfancyhdr| package and redefines the |plain| and |headings| +% styles on the base of |fancy| page style. It also sets the last style +% in the list (e.g.\ |headings| style) as a default page style. +% +% \section{Rule Control} +% +% \DescribeMacro{\headrulewidth} +% \DescribeMacro{\footrulewidth} +% The widths of decorative rules for header and footer are coded in the\linebreak +% |\headrulewidth| and |\footrulewidth| commands respectively +% (these commands were ported from the |fancyhdr| package). +% The default values for these commands are |0.4pt| (standard head rule width) +% and |0pt| (no foot rule). +% To change defaults, you should redefine corresponding commands. +% For example, to set a head rule of |0.6pt| width in this document, +% we use the following command: +% \begin{quote} +% |\renewcommand{\headrulewidth}{0.6pt}| +% \end{quote} +% +% \DescribeMacro{\headstrutheight} +% \DescribeMacro{\footstrutheight} +% A distance between rules and headers/footers is controlled with the\linebreak +% |\headstrutheight| and |\footstrutheight| commands. +% Here is a distinction with the |fancyhdr| package. The |fancyhdr| allows +% control the distance between the decoration rule and the page foot only +% in the |\footruleskip| command. Moreover, we use another technique to provide +% separation between header/footer and its rule: we insert special struts +% in headers and footers whose height and depth are calculated using the +% values of the mentioned commands. The defaults for both |\headstrutheight| +% and |\footstrutheight| are |0.3\normalbaselineskip|. You can redefine +% them in just the same manner as rule width commands above. +% +% \DescribeMacro{\headrule} +% \DescribeMacro{\footrule} +% The decorative rules in the header and footer are prepared with the\linebreak +% |\headrule| and |\footrule| commands. These commands work in vertical +% mode. They put an |\hrule| and do a negative |\vskip| to compensate +% the rule height (see the implementation section for more details). +% You can redefine these rules to produce custom decoration lines. For example, +% the double line in the header of this document is produced with the following +% code: +% \begin{quote} +% |\makeatletter|\\ +% |\renewcommand{\headrule}{%|\\ +% | \setlength\@tempdima{\headrulewidth}%|\\ +% | \hrule\@height\@tempdima\@width\headwidth|\\ +% | \vskip 2\@tempdima|\\ +% | \hrule\@height\@tempdima\@width\headwidth|\\ +% | \vskip -4\@tempdima|\\ +% |}|\\ +% |\makeatother| +% \end{quote} +% +% \DescribeMacro{\headwidth} +% \DescribeMacro{\normalheaders} +% \DescribeMacro{\extendedheaders} +% The width of header and footer (and, of course, the widths of their rules) +% is controlled with the |\headwidth| register. It is usually equal to the +% |\textwidth| but can exceed it. In the last case, the headers and footers are +% expanded on the marginal area. To simplify control of the |\headwidth|, +% two service commands are introduced in the package. The |\normalheaders| +% command sets the |\headwidth| to the |\textwidth|. The +% |\extendedheaders| enlarges the headers and footers on the whole marginal area: +% in two-column mode, header and footer are expanded to both margins and, in +% one-column mode, header and footer are expanded to the +% outer margin, but, if reverse margin mode is on, they are expanded to +% the inner margin. In this document, the |\headwidth| is expanded to marginal +% area as follows: +% \begin{quote} +% |\addtolength{\headwidth}{\marginparsep}|\\ +% |\addtolength{\headwidth}{0.6\marginparwidth}| +% \end{quote} +% +% \section{Page Style Customization} +% +% To customize a page style of your document, you can do the following: +% set the |\pagestyle{fancy}| in the preamble of the document +% and specify values of header and footer marks with the following +% commands:\vspace{-\baselineskip} +% \begin{center}\catcode`|=12 +% \small +% \renewcommand\cboxstyle{\footnotesize} +% \begin{tabular}{|l|c|l|}\hline +% \hfill\cbox{Command}\hfill\mbox{} & +% \hfill\cbox{Default optional\\parameter}\hfill\mbox{} & +% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline +% \Strut/.8/ +% \verb+\fancyhf+\oarg{pos-list}\marg{mark} & +% \verb+[lh,ch,rh,lf,cf,rf]+ & +% Set a mark for header/footer \\ +% \verb+\fancyhead+\oarg{pos-list}\marg{mark} & +% \verb+[l,c,r]+ & +% Set a mark for header \\ +% \verb+\fancyfoot+\oarg{pos-list}\marg{mark} & +% \verb+[l,c,r]+ & +% Set a mark for footer \\ +% \verb+\lhead+\oarg{even-mark}\marg{odd-mark} & +% \oarg{odd-mark} & +% Set the left mark of header\\ +% \verb+\chead+\oarg{even-mark}\marg{odd-mark} & +% \oarg{odd-mark} & +% Set the center mark of header\\ +% \verb+\rhead+\oarg{even-mark}\marg{odd-mark} & +% \oarg{odd-mark} & +% Set the right mark of header\\ +% \verb+\lfoot+\oarg{even-mark}\marg{odd-mark} & +% \oarg{odd-mark} & +% Set the left mark of footer\\ +% \verb+\cfoot+\oarg{even-mark}\marg{odd-mark} & +% \oarg{odd-mark} & +% Set the center mark of footer\\ +% \verb+\rfoot+\oarg{even-mark}\marg{odd-mark} & +% \oarg{odd-mark} & +% Set the right mark of footer\\\hline +% \end{tabular} +% \end{center} +% +% All these commands are ported from the |fancyhdr| package. +% +% \DescribeMacro{\fancyhf} +% The |\fancyhf| command allows specify any mark of header or footer. +% The \meta{pos-list} argument specifies marks to set. +% A~mark position selector in the \meta{pos-list} argument consists +% of up to three letters: header/footer selector (|h| or |f|), +% horizontal position selector (|l| or |c| or |r|), odd/even page +% selector (|o|~or~|e|). The odd/even page selector is optional. +% If it is omitted, the command is applied to the corresponding mark +% on both odd and even pages. For example, |\fancyhf[hco]{mark}| +% sets the center mark of a header for odd pages. +% +% \textit{Note\/}: the even page selector has a sense for two-side mode only. +% In one-side documents (e.g.\ reports), even page marks are ignored. +% +% \DescribeMacro{\fancyhead} +% \DescribeMacro{\fancyfoot} +% The |\fancyhead| and |\fancyfoot| commands allows specify any +% mark of header and footer respectively. +% A~mark position selector in the \meta{pos-list} argument consists +% of up to two letters: horizontal position selector (|l| or |c| or |r|) +% and odd/even page selector (|o|~or~|e|). The odd/even page selector +% is also optional. For example, |\fancyhead[l]{mark}| +% sets the left mark of a header for both odd and even pages. +% +% \textit{Note\/}: The command |\fancyhf{}| clears all marks of headers and footers. +% The |\fancyhead{}| and |\fancyfoot{}| commands clear all marks in headers +% and footers respectively. +% +% \DescribeMacro{\lhead} +% \DescribeMacro{\chead} +% \DescribeMacro{\rhead} +% \DescribeMacro{\lfoot} +% \DescribeMacro{\cfoot} +% \DescribeMacro{\rfoot} +% We also implement the old-style macros |\lhead|, |\chead|, |\rhead|, +% |\lfoot|, |\cfoot|, and |\rfoot|. Their meaning is clear enough. +% For example, the command |\rhead[even-mark]{odd-mark}| is equivalent +% to the following commands: +% \begin{quote} +% |\fancyhead[le]{even-mark}|\\ +% |\fancyhead[lo]{odd-mark}| +% \end{quote} +% If an optional parameter of these commands is omitted, the same mark +% is set for both odd and even pages. For example, the command +% |\cfoot{mark}| is equivalent to the |\fancyfoot[c]{mark}|. +% +% \DescribeMacro{\nouppercase} +% You can use the |\nouppercase|\marg{text} command within a mark +% commands to ignore the |\uppercase| and |\MakeUppercase| commands +% in its parameter. For example, the +% |\rhead{\nouppercase{\rightmark}}| command ignores conversion the contents +% of |\rightmark| to uppercase. +% +% \section{Fancy Centering} +% +% The marks in a fancy header and footer are prepared using |\parbox| +% command. So, you can use multiline marks. In the header, they are +% aligned to the bottom line, but, in the footer, they are aligned to +% the top line. The maximum width of every mark is equal to the +% |\headwidth|. This can lead to overlapping of neighbour marks. +% +% \DescribeMacro{\fancycenter} +% If you want to prepare marks in more traditional way in a line +% not exceeding the |\headwidth|, you can use +% the following command in any mark command: +% \begin{quote} +% |\fancycenter|\oarg{distance}\oarg{stretch}\\ +% | |\marg{left-mark}\marg{center-mark}\marg{right-mark} +% \end{quote} +% This command works like +% \begin{center} +% |\hbox to\linewidth{|\marg{left-mark}|\hfil|\marg{center-mark}|\hfil|\marg{right-mark}|}| +% \end{center} +% but does this work more carefully trying to exactly center the central part of +% the text if possible. The solution for exact centering +% is applied if the width of \meta{center-mark} is less than +% \begin{quote} +% |\linewidth - 2*(|\meta{stretch}|*|\meta{distance}| +|\\ +% | max(width(|\meta{left-mark}|), width(|\meta{right-mark}|)))|. +% \end{quote} +% Otherwise the \meta{center-mark} will slightly migrate to a shorter item +% (\meta{left-mark} or \meta{right-mark}), but at least \meta{distance} +% space between all parts of line is provided. +% The default values of \meta{distance} and \meta{stretch} +% are |1em| and |3|. +% +% If the \meta{center-mark} is empty, the |\fancycenter| is equivalent to +% the following command: +% \begin{center} +% |\hbox to\linewidth {|\marg{left-mark}|\hfil |\marg{right-mark}|}| +% \end{center} +% +% \textit{Note\/}: The usage of |\fancycenter| command is not limited with the +% argument of header/footer marks only. You can use it anywhere in your document. +% +% \section{Prepare Custom Page Styles} +% +% \DescribeMacro{\newpagestyle} +% In the |nccfancyhdr| package, we recommend to set fancy marks within +% definition of a custom page style. In this case, +% you can easy select a custom style with the +% |\pagestyle| or |\thispagestyle| command. To support this, the +% |\newpagestyle| command is introduced: +% \begin{quote} +% |\newpagestyle|\marg{style-name}\oarg{base-style}\marg{definitions} +% \end{quote} +% It is allowed in the preamble only. The \meta{base-style} is a style +% the new style will be based on. If the optional parameter is omitted, the +% |fancy| style is used as the base style. +% The |fancy| style works as the |empty| style, but support decorative +% rules and extended headers/footers and allows fancy marks. +% A desired page style works as follows: +% at the first, the base style is applied; after that, the \meta{definitions} +% customize the base style. +% +% \textit{Note\/}: You can use any existing \meta{base-style} in the +% definition of a new style, but, if you apply fancy mark commands in the +% \meta{definitions} parameter, the base style should be based on the +% |fancy| style. +% +% For example, all pages of this document except the first one were prepared +% with the custom page style as follows: +% \begin{quote} +% |\usepackage[headings]{nccfancyhdr}|\\ +% |\newpagestyle{lheadings}[headings]{%|\\ +% | \fancyhead[ce]{\nouppercase{%|\\ +% | \fancycenter{\thepage}{}{\slshape\leftmark}}}%|\\ +% | \fancyhead[co]{\nouppercase{%|\\ +% | \fancycenter{\slshape\rightmark}{}{\thepage}}}%|\\ +% |}|\\ +% |\pagestyle{lheadings}| +% \end{quote} +% As you can see from here, the fancy versions of |headings| and +% |myheadings| styles use the center mark only and prepare it +% with the help of the |\fancycenter| command. +% +% \section{How to Change a Page Style in Floatpages?} +% +% A floatpage is a page consisting of floats only. You cannot +% directly change a page style for such a page, because it is prepared +% in whole in the \LaTeX\ Output Routine. +% We recommend to change a page style for floatpages with the help of the +% |afterpage| package. Just add a command |\usepackage{afterpage}| +% in the preamble and put the command: +% \begin{quote} +% |\afterpage{\thispagestyle|\marg{special-style}|}| +% \end{quote} +% anywhere in the page going before the floatpage. +% The \meta{special-style} is a style you want to apply for +% floatpages. +% +% \DescribeMacro{\iffloatpage} +% \DescribeMacro{\iftopfloat} +% \DescribeMacro{\ifbotfloat} +% Another way for change a page style on pages with floats +% consists in using the following conditional commands within marks of +% a page style: +% \begin{quote} +% |\iffloatpage|\marg{true-clause}\marg{false-clause}\\ +% |\iftopfloat|\marg{true-clause}\marg{false-clause}\\ +% |\ifbotfloat|\marg{true-clause}\marg{false-clause} +% \end{quote} +% These commands were ported from the |fancyhdr| package. +% The |\iffloatpage| command executes the \meta{true-clause} if +% this is a floatpage. Otherwise, it executes the \meta{false-clause}. +% Analogously, the |\iftopfloat| and |\ifbotfloat| test the +% lists of top floats and bottom floats of the page to be nonempty. +% +% Whereas these commands are rare used, they are defined if the +% package is loaded with the |testfloats| option. +% +% \section{Package Options} +% +% In conclusion, we enumerate all package options available: +% \begin{center}\catcode`|=12 +% \small\tabcolsep=10pt +% \renewcommand\cboxstyle{\footnotesize} +% \begin{tabular}{|l|l|}\hline +% \hfill\cbox{Option}\hfill\mbox{} & +% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline +% \Strut/.8/ +% \texttt{empty} & redefine the \texttt{empty} page style to be fancy-based style \\ +% \texttt{plain} & redefine the \texttt{plain} page style to be fancy-based style \\ +% \texttt{headings} & redefine the \texttt{headings} page style to be fancy-based style \\ +% \texttt{myheadings} & redefine the \texttt{myheadings} page style to be fancy-based style \\ +% \texttt{testfloats} & define \verb+\iffloatpage+, \verb+\iftopfloat+, +% and \verb+\ifbotfloat+ commands\\ +% \hline +% \end{tabular} +% \end{center} +% The options are executed in the order they are specified in the list of options. +% Every page +% style redefinition option sets a redefined style to be the current page style. +% Therefore, after loading of this package, the style redefined in the last order +% will be the current page style. +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\newpagestyle} +% We start with the |\newpagestyle| command. It was introduced in +% the version~1.1 of the package. It is available in the preamble only. +% \begin{macrocode} +%<*package> +\newcommand*{\newpagestyle}[1]{% + \@ifnextchar[{\NCC@newpagestyle{#1}}{\NCC@newpagestyle{#1}[fancy]}% +} +\long\def\NCC@newpagestyle#1[#2]#3{% + \@ifundefined{ps@#2}{% + \PackageError{nccfancyhdr} + {\string\newpagestyle: Unknown base page style `#2'}{}% + }{}% + \edef\@tempa{\noexpand\newcommand \expandafter\noexpand + \csname ps@#1\endcsname}% + \expandafter\@tempa\expandafter{\csname ps@#2\endcsname #3}% +} +\@onlypreamble\newpagestyle +\@onlypreamble\NCC@newpagestyle +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\fancyhf} +% \begin{macro}{\fancyhead} +% \begin{macro}{\fancyfoot} +% Now we define the new-style fancy marking commands. They are based +% on the |\NCC@fancyhf| command. +% \begin{macrocode} +\newcommand*{\fancyhf}[1][lh,ch,rh,lf,cf,rf]{\NCC@fancyhf{}{#1}} +\newcommand*{\fancyhead}[1][l,c,r]{\NCC@fancyhf h{#1}} +\newcommand*{\fancyfoot}[1][l,c,r]{\NCC@fancyhf f{#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\lhead} +% \begin{macro}{\chead} +% \begin{macro}{\rhead} +% \begin{macro}{\lfoot} +% \begin{macro}{\cfoot} +% \begin{macro}{\rfoot} +% The old-style fancy-marking commands are based on the |\NCC@fancy| +% command. +% \begin{macrocode} +\newcommand{\lhead}{\@dblarg{\NCC@fancy{lh}}} +\newcommand{\chead}{\@dblarg{\NCC@fancy{ch}}} +\newcommand{\rhead}{\@dblarg{\NCC@fancy{rh}}} +\newcommand{\lfoot}{\@dblarg{\NCC@fancy{lf}}} +\newcommand{\cfoot}{\@dblarg{\NCC@fancy{cf}}} +\newcommand{\rfoot}{\@dblarg{\NCC@fancy{rf}}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@fancy} +% The |\NCC@fancy|\marg{selector}\oarg{even-mark}\marg{odd-mark} +% command sets a pair of marks. A \meta{selector} consists of two +% letters: (lcr) and (hf). We need not test the \meta{selector} on +% correctness because this command is applied internally. +% \begin{macrocode} +\def\NCC@fancy#1[#2]#3{ + \expandafter\def\csname NCC@f@e#1\endcsname{#2}% + \expandafter\def\csname NCC@f@o#1\endcsname{#3}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fancyhf} +% The |\NCC@fancyhf|\marg{hf}\marg{pos-list}\marg{mark} command +% parses the \meta{pos-list} by selectors and executes the +% |\NCC@fancydef| for every selector. The \meta{hf} argument +% contains the common part of all selectors added at their +% beginning. +% \begin{macrocode} +\def\NCC@fancyhf#1#2#3{% + \@for\@tempa:=#2\do + {\edef\@tempa{\noexpand\NCC@fancydef{#1\@tempa}}\@tempa{#3}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fancydef} +% The |\NCC@fancydef|\marg{selector}\marg{mark} command analyzes +% the \meta{selector} and defines corresponding fancy mark. +% It uses the |\NCC@fancyclass| command that prevents using many letters +% of the same class in the \meta{selector}. For example, it will be an +% error if more that one `l' or `c' or `r' letter appears in the +% selector. +% \begin{macrocode} +\def\NCC@fancydef#1#2{% +% \end{macrocode} +% The |\NCC@hf|, |\NCC@lcr|, and |\NCC@oe| will contain a letter +% of the corresponding class found in selector. Before the cycle, +% they are set to |\relax|. +% \begin{macrocode} + \let\NCC@hf\relax \let\NCC@lcr\relax \let\NCC@oe\relax + \@tfor \@nextchar:=#1\do +% \end{macrocode} +% Prepare in |\@tempa| a next letter in uppercase. +% \begin{macrocode} + {\edef\@tempa{\noexpand\uppercase{\noexpand\def% + \noexpand\@tempa{\@nextchar}}}\@tempa +% \end{macrocode} +% Test the letter and specify corresponding class. +% \begin{macrocode} + \if\@tempa H\NCC@fancyclass\NCC@hf{h}{#1}\else + \if\@tempa F\NCC@fancyclass\NCC@hf{f}{#1}\else + \if\@tempa L\NCC@fancyclass\NCC@lcr{l}{#1}\else + \if\@tempa C\NCC@fancyclass\NCC@lcr{c}{#1}\else + \if\@tempa R\NCC@fancyclass\NCC@lcr{r}{#1}\else + \if\@tempa O\NCC@fancyclass\NCC@oe{o}{#1}\else + \if\@tempa E\NCC@fancyclass\NCC@oe{e}{#1}\else + \NCC@fancyerror{Illegal char `\@nextchar' in argument `#1'}% + \fi + \fi + \fi + \fi + \fi + \fi + \fi + }% +% \end{macrocode} +% After cycle, we test that the |\NCC@hf| and |\NCC@lcr| classes +% are specified. The |\NCC@oe| class is optional. So, we do not test it. +% Finally, we define appropriate mark commands. +% \begin{macrocode} + \ifx\NCC@hf\relax \NCC@fancyerror{No `h' or `f' specified}\else + \ifx\NCC@lcr\relax \NCC@fancyerror{No `l' or `c' or `r' specified}\else + \ifx\NCC@oe\relax + \expandafter\def\csname NCC@f@o\NCC@lcr\NCC@hf\endcsname{#2}% + \expandafter\def\csname NCC@f@e\NCC@lcr\NCC@hf\endcsname{#2}% + \else + \expandafter\def\csname NCC@f@\NCC@oe\NCC@lcr\NCC@hf\endcsname{#2}% + \fi + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fancyclass} +% The |\NCC@fancyclass|\marg{command}\marg{letter}\marg{selector} +% command tests the\linebreak \meta{command} to be |\relax| and defines +% it with the \meta{letter} argument. If the command is already defined, +% the error message is generated. +% \begin{macrocode} +\def\NCC@fancyclass#1#2#3{% + \ifx#1\relax + \def#1{#2}% + \else + \NCC@fancyerror{Misusing the char `\@nextchar' in argument `#3'}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fancyerror} +% A handler of errors in fancy mark definitions. +% \begin{macrocode} +\def\NCC@fancyerror#1{% + \PackageError{nccfancyhdr}% + {Fancy mark definitions:\MessageBreak#1}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\headwidth} +% \begin{macro}{\extendedheaders} +% \begin{macro}{\normalheaders} +% Now we allocate the |\headwidth| register and define +% its control commands. +% \begin{macrocode} +\newdimen\headwidth +\newcommand{\extendedheaders}{ + \@tempdima\marginparwidth \advance\@tempdima\marginparsep + \@tempdimb\textwidth \advance\@tempdimb\@tempdima + \if@twocolumn \advance\@tempdimb\@tempdima \fi + \global\headwidth\@tempdimb +} +\newcommand{\normalheaders}{\global\headwidth\textwidth} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\headrulewidth} +% \begin{macro}{\footrulewidth} +% \begin{macro}{\headstrutheight} +% \begin{macro}{\footstrutheight} +% Now we specify parameters of decoration rules: widths and struts. +% \begin{macrocode} +\newcommand{\headrulewidth}{.4\p@} +\newcommand{\footrulewidth}{\z@} +\newcommand{\headstrutheight}{.3\normalbaselineskip} +\newcommand{\footstrutheight}{.3\normalbaselineskip} +% \end{macrocode} +% \textit{Note\/}: Really, the head strut height is zero but its depth is equal +% to the value of |\headstrutheight|. Moreover, the foot strut height +% is a sum of |0.55\normalbaseskip| and the value of |\footstrutheight|. +% But we prefer the universal notations for command names instead of strict one, +% because users do not interested in implementation details. +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\headrule} +% The default implementation of the |\headrule|. It works in vertical mode. +% At first it draws a rule and then it inserts a negative skip for compensation. +% \begin{macrocode} +\newcommand{\headrule}{% + \setlength\@tempdima{\headrulewidth}% + \hrule\@height\@tempdima\@width\headwidth + \vskip-\@tempdima +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\footrule} +% The |\footrule| works in reverse order: at first it inserts a negative skip +% and after that it draws a rule. +% \begin{macrocode} +\newcommand{\footrule}{% + \setlength\@tempdima{\footrulewidth}% Can use calc here + \vskip -\@tempdima + \hrule \@height\@tempdima \@width\headwidth +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fancyreset} +% The |\NCC@fancyreset| command is used at the beginning +% of fancy headers and footers. It resets font, removes +% baseline stretch and locally defines the |\nouppercase| command. +% In comparison with the |fancyhdr| package, we do not +% call the |\restorecr| command because it is obsolete now. +% We also redefine the |\uppercase| and |\MakeUppercase| +% commands in more appropriate way than in |fancyhdr|. +% \begin{macrocode} +\def\NCC@fancyreset{\let\baselinestretch\@empty + \long\def\nouppercase##1{% + \begingroup + \long\def\uppercase####1{####1}% + \long\def\MakeUppercase####1{####1}% + ##1% + \endgroup + }% + \reset@font +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fancyhead} +% The |\NCC@fancyhead|\marg{left-mark}\marg{center-mark}\marg{right-mark} +% command prepares the fancy header. It differs from the implementation in +% the |fancyhdr| at the following issue: the vertical box in this command +% (|\@tempboxa|) is prepared as |\vtop| box, but in the |fancyhdr| package +% it is prepared as |\vbox| box. As a consequence, in the |fancyhdr| version, +% the base line of the vertical box goes at the rule and the header slightly +% moves up. +% \begin{macrocode} +\def\NCC@fancyhead#1#2#3{% + \hb@xt@\headwidth{\NCC@fancyreset + \setbox\@tempboxa\vtop{% + \hbox{% +% \end{macrocode} +% Prepare the left mark: +% \begin{macrocode} + \rlap{\parbox[b]\headwidth{\raggedright#1}}% +% \end{macrocode} +% Insert the strut: +% \begin{macrocode} + \setlength\@tempdima{\headstrutheight}% + \vrule\@width\z@\@height\z@\@depth\@tempdima +% \end{macrocode} +% Prepare the center mark: +% \begin{macrocode} + \parbox[b]\headwidth{\centering#2}% +% \end{macrocode} +% Prepare the right mark: +% \begin{macrocode} + \llap{\parbox[b]\headwidth{\raggedleft#3}}% + }% +% \end{macrocode} +% Draw decoration rule: +% \begin{macrocode} + \headrule + }% +% \end{macrocode} +% Compare the height of |\@tempboxa| with the |\headheaght| +% and correct the last one if vertical overfull appears: +% \begin{macrocode} + \NCC@fancytest\headheight +% \end{macrocode} +% Put the fancy header: +% \begin{macrocode} + \box\@tempboxa + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fancyfoot} +% The |\NCC@fancyfoot|\marg{left-mark}\marg{center-mark}\marg{right-mark} +% command prepares the fancy footer. Its implementation is similar to +% the |\NCC@fancyhead|. +% \begin{macrocode} +\def\NCC@fancyfoot#1#2#3{% + \hb@xt@\headwidth{\NCC@fancyreset + \setbox\@tempboxa\vbox{% + \footrule + \hbox{% + \rlap{\parbox[t]\headwidth{\raggedright#1}}% + \@tempdima .55\normalbaselineskip + \addtolength\@tempdima{\footstrutheight}% + \vrule\@width\z@\@height\@tempdima\@depth\z@ + \parbox[t]\headwidth{\centering#2}% + \llap{\parbox[t]\headwidth{\raggedleft#3}}% + }% + }% + \NCC@fancytest\footskip + \box\@tempboxa + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fancytest} +% The |\NCC@fancytest|\marg{register} command compares +% a value of the \meta{register} with the height of |\@tempboxa| +% and modifies the \meta{register} value if necessary. +% \begin{macrocode} +\def\NCC@fancytest#1{% + \ifdim\ht\@tempboxa>#1% + \PackageWarning{nccfancyhdr}% + {\string#1 is too small (\the#1):\MessageBreak + Make it at least \the\ht\@tempboxa.\MessageBreak + We now enlarge it for the rest of the document.\MessageBreak + This may cause the page layout to be inconsistent, however}% + \@tempdima#1\global\setlength{#1}{\ht\@tempboxa}% + \ht\@tempboxa\@tempdima + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@ihss} +% \begin{macro}{\NCC@ohss} +% The |\NCC@ihss| and |\NCC@ohss| hooks insert the |\hss| command +% at the outer and/or inner sides of header/footer to provide the proper +% enlargement it on margins. +% \begin{macrocode} +\def\NCC@ihss{\if@twocolumn\hss\else\if@reversemargin\hss\fi\fi} +\def\NCC@ohss{\if@twocolumn\hss\else\if@reversemargin\else\hss\fi\fi} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\fancycenter} +% |\fancycenter|\oarg{dist}\oarg{stretch}\marg{left-mark}\marg{center-mark}\marg{right-mark} +% \begin{macrocode} +\newcommand*{\fancycenter}[1][1em]{% + \@ifnextchar[{\NCC@fancycenter{#1}}{\NCC@fancycenter{#1}[3]}% +} +\def\NCC@fancycenter#1[#2]#3#4#5{% +% \end{macrocode} +% At first, we execute the case when the \meta{center-mark} is empty: +% \begin{macrocode} + \def\@tempa{#4}\ifx\@tempa\@empty + \hb@xt@\linewidth{\color@begingroup{#3}\hfil {#5}\color@endgroup}% + \else +% \end{macrocode} +% All that we need to do is to calculate skips inserted before and after +% \meta{center-mark}. We will calculate them in the |\@tempskipa| +% and |\@tempskipb|. At first: +% \begin{quote} +% |\@tempdima:=|\meta{dist};\\ +% |\@tempdimb:=|\meta{dist}|*|\meta{stretch};\\ +% |\@tempdimc:=|\meta{dist}|*|\meta{stretch}|-|\meta{dist};\\ +% |\@tempskipa:=\@tempskipb:=\@tempdimb + 1fil - \@tempdimc|; +% \end{quote} +% \begin{macrocode} + \setlength\@tempdima{#1}% + \setlength{\@tempdimb}{#2\@tempdima}% + \@tempdimc \@tempdimb \advance\@tempdimc -\@tempdima + \setlength\@tempskipa{\@tempdimb \@plus 1fil \@minus \@tempdimc}% + \@tempskipb\@tempskipa +% \end{macrocode} +% At this point, the |\@tempskipa| and |\@tempskipb| registers +% have the natural size \meta{dist}|*|\meta{stretch}, +% unlimited stretchability, and the minimum size \meta{dist}. +% Now we decrease the minimum size of |\@tempskipa| to zero if +% the \meta{left-mark} is empty: +% \begin{macrocode} + \def\@tempa{#3}\ifx\@tempa\@empty + \addtolength\@tempskipa{\z@ \@minus \@tempdima}% + \fi +% \end{macrocode} +% Do the same things with the |\@tempskipb| register if the +% \meta{right-mark} is empty: +% \begin{macrocode} + \def\@tempa{#5}\ifx\@tempa\@empty % empty right + \addtolength\@tempskipb{\z@ \@minus \@tempdima}% + \fi +% \end{macrocode} +% Finally, we correct the left and right glues taking into +% account the difference between lengthes of \meta{left-mark} +% and \meta{right-mark}. We calculate what mark is shorter +% and increase the natural size of corresponding register +% on the difference between their lengthes. +% \begin{macrocode} + \settowidth{\@tempdimb}{#3}% + \settowidth{\@tempdimc}{#5}% + \ifdim\@tempdimb>\@tempdimc + \advance\@tempdimb -\@tempdimc + \addtolength\@tempskipb{\@tempdimb \@minus \@tempdimb}% + \else + \advance\@tempdimc -\@tempdimb + \addtolength\@tempskipa{\@tempdimc \@minus \@tempdimc}% + \fi +% \end{macrocode} +% The |\@tempskipa| and |\@tempskipb| are calculated. Put the box. +% \begin{macrocode} + \hb@xt@\linewidth{\color@begingroup{#3}\hskip \@tempskipa + {#4}\hskip \@tempskipb {#5}\color@endgroup}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% The rest of the package consists of games with styles and options. +% +% \begin{macro}{\ps@fancy} +% We start from declaring the |fancy| page style. It extends the +% |empty| page style. So, we simply call the empty style and then +% redefine |\@oddhead|, |\@evenhead|, |\@oddfoot|, and |\@evenfoot| +% to be fancy one. The |\NCC@ihss| and |\NCC@ohss| hooks provide +% proper enlargement of headers/footers on margins. The |\fancyhf{}| +% command at the end of macro clears all marks. +% \begin{macrocode} +\def\ps@fancy{\ps@empty + \def\@oddhead{% + \NCC@ihss \NCC@fancyhead\NCC@f@olh\NCC@f@och\NCC@f@orh \NCC@ohss}% + \def\@evenhead{% + \NCC@ohss \NCC@fancyhead\NCC@f@elh\NCC@f@ech\NCC@f@erh \NCC@ihss}% + \def\@oddfoot{% + \NCC@ihss \NCC@fancyfoot\NCC@f@olf\NCC@f@ocf\NCC@f@orf \NCC@ohss}% + \def\@evenfoot{% + \NCC@ohss \NCC@fancyfoot\NCC@f@elf\NCC@f@ecf\NCC@f@erf \NCC@ihss}% + \fancyhf{}% +} +% \end{macrocode} +% \end{macro} +% +% Standard styles are redefined optionally. +% +% \begin{macro}{\ps@empty} +% When we redefine the |empty| style, we must take into account +% that it can be also redefined (as in |amsart| and |amsbook| classes). +% So, we save its previous meaning in the |\NCC@psempty| macro and base the +% |empty| style on the saved style. +% \begin{macrocode} +\DeclareOption{empty}{% + \let\NCC@psempty\ps@empty + \def\ps@empty{\NCC@psempty + \def\@oddhead{% + \NCC@ihss \NCC@fancyhead\NCC@f@olh\NCC@f@och\NCC@f@orh \NCC@ohss}% + \def\@evenhead{% + \NCC@ohss \NCC@fancyhead\NCC@f@elh\NCC@f@ech\NCC@f@erh \NCC@ihss}% + \def\@oddfoot{% + \NCC@ihss \NCC@fancyfoot\NCC@f@olf\NCC@f@ocf\NCC@f@orf \NCC@ohss}% + \def\@evenfoot{% + \NCC@ohss \NCC@fancyfoot\NCC@f@elf\NCC@f@ecf\NCC@f@erf \NCC@ihss}% + \fancyhf{}% + }% + \pagestyle{empty}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ps@plain} +% The redefinition of the |plain| style is quite simple: +% \begin{macrocode} +\DeclareOption{plain}{% + \def\ps@plain{\ps@fancy \let\@mkboth\@gobbletwo + \fancyfoot[c]{\thepage}% + }% + \pagestyle{plain}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ps@myheadings} +% The redefinition of the |myheadings| style is conditional. +% We test the |\chapter| command on existence and redefine the +% style in a bit different ways. +% \begin{macrocode} +\DeclareOption{myheadings}{% + \@ifundefined{chapter}{% + \def\ps@myheadings{\ps@fancy \let\@mkboth\@gobbletwo + \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% + \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% + \let\sectionmark\@gobble + \let\subsectionmark\@gobble + }% + }{\def\ps@myheadings{\ps@fancy \let\@mkboth\@gobbletwo + \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% + \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% + \let\chaptermark\@gobble + \let\sectionmark\@gobble + }% + }% + \pagestyle{myheadings}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ps@headings} +% The redefinition of the |headings| style also differs for +% book-like and article-like classes. It also differs for +% one-side and two-side modes. +% \begin{macrocode} +\DeclareOption{headings}{% + \@ifundefined{chapter}{% + \if@twoside +% \end{macrocode} +% An article in two-side mode: +% \begin{macrocode} + \def\ps@headings{\ps@fancy \let\@mkboth\markboth + \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% + \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% + \def\sectionmark##1{% + \markboth{\MakeUppercase{% + \ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}{}}% + \def\subsectionmark##1{% + \markright{% + \ifnum \c@secnumdepth >\@ne \thesubsection\quad \fi##1}}% + }% + \else +% \end{macrocode} +% An article in one-side mode: +% \begin{macrocode} + \def\ps@headings{\ps@fancy \let\@mkboth\markboth + \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% + \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% + \def\sectionmark##1{% + \markright {\MakeUppercase{% + \ifnum \c@secnumdepth >\z@ \thesection\quad \fi##1}}}% + \let\subsectionmark\@gobble % Not needed but inserted for safety + }% + \fi + }{\if@twoside +% \end{macrocode} +% A book in two-side mode: +% \begin{macrocode} + \def\ps@headings{\ps@fancy \let\@mkboth\markboth + \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% + \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% + \def\chaptermark##1{% + \markboth{\MakeUppercase{% + \ifnum \c@secnumdepth >\m@ne \if@mainmatter + \@chapapp\ \thechapter. \ \fi\fi##1}}{}}% + \def\sectionmark##1{% + \markright {\MakeUppercase{% + \ifnum \c@secnumdepth >\z@ \thesection. \ \fi##1}}}% + }% + \else +% \end{macrocode} +% A book in one-side mode: +% \begin{macrocode} + \def\ps@headings{\ps@fancy \let\@mkboth\markboth + \fancyhead[ce]{\fancycenter{\thepage}{}{\slshape\leftmark}}% + \fancyhead[co]{\fancycenter{\slshape\rightmark}{}{\thepage}}% + \def\chaptermark##1{% + \markright{\MakeUppercase{% + \ifnum \c@secnumdepth >\m@ne \if@mainmatter + \@chapapp\ \thechapter. \ \fi\fi##1}}}% + \let\sectionmark\@gobble % Not needed but inserted for safety + }% + \fi + }% + \pagestyle{headings}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\iffloatpage} +% \begin{macro}{\iftopfloat} +% \begin{macro}{\ifbotfloat} +% These macros are defined in the |testfloats| option. +% They were ported from the |fancyhdr| and modified a bit +% in more \LaTeX\ way. It is no warrantee that these macros +% will proper work in all cases. They must be used inside +% fancy mark commands. +% \begin{macrocode} +\DeclareOption{testfloats}{% + \let\NCC@fancymakecol\@makecol + \let\NCC@fancytoplist\@empty + \let\NCC@fancybotlist\@empty + \def\@makecol{% + \let\NCC@fancytoplist\@toplist + \let\NCC@fancybotlist\@botlist + \NCC@fancymakecol + }% + \newcommand\iftopfloat{% + \ifx\NCC@fancytoplist\@empty + \expandafter\@secondoftwo + \else + \expandafter\@firstoftwo + \fi + }% + \newcommand\ifbotfloat{% + \ifx\NCC@fancybotlist\@empty + \expandafter\@secondoftwo + \else + \expandafter\@firstoftwo + \fi + }% + \newcommand\iffloatpage{% + \if@fcolmade + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi + }% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% +% Finally, we process the options in the order they are specified +% in the options list and set the defaults. +% \begin{macrocode} +\ProcessOptions* +\normalheaders +\fancyhf{} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccfloats.dtx b/macros/latex/contrib/ncctools/source/nccfloats.dtx new file mode 100644 index 0000000000..bcf55b5e2e --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccfloats.dtx @@ -0,0 +1,647 @@ +% \iffalse +%% +%% File: nccfloats.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccfloats} +% [2006/01/07 v1.2 More Float Management (NCC)] +% +% \changes{v1.00}{2002/03/23}{This version is uploaded to CTAN} +% \changes{v1.01}{2002/05/17}{Handling of side floats improved} +% \changes{v1.1}{2004/12/05}{Width parameters can have units now} +% \changes{v1.1}{2004/12/05}{Documentation was prepared} +% \changes{v1.2}{2006/01/07}{Extend |\FloatStyle| syntax} +% \changes{v1.2}{2006/01/07}{Cover base floats with |\FloatStyle|} +% \changes{v1.2}{2006/01/07}{Introduce |\newminifloat| command} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{desclist,nccfloats} +\GetFileInfo{nccfloats.sty} +\begin{document} +\title{The \textsf{nccfloats} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccfloats.dtx} +\end{document} +% +% \fi +% +% The standard \LaTeX\ floating environments, namely |figure| +% and |table|, allow user to place floating material in a +% document. But they do not introduce a style in which this +% material must be formatted. In this package, styles are +% joined with floats and mini-floats are introduced. Mini-floats +% are prepared at a mini-page and allow captions within. +% Basing on mini-floats, a number of service commands for +% figures and tables are defined. The ability to create +% other types of mini-floats is introduced with the +% |\newminifloat| command. +% +% \tableofcontents +% +% \section{Basic Commands} +% +% \DescribeMacro{\FloatStyle} +% The |\FloatStyle|\oarg{type}\marg{style} command sets a style for +% the float of the given \meta{type}. If the \meta{type} is omitted, +% the default style is specified. It will be applied to a float or +% mini-float if no specialized style was defined. +% This command is available in the preamble only. +% +% To specify the style of a mini-float and of service commands based on it, +% add the `|mini|' prefix to the float type. The default styles are +% \begin{quote} +% |\FloatStyle{}|\\ +% |\FloatStyle[minifigure]{\footnotesize\centering}|\\ +% |\FloatStyle[minitable]{\footnotesize\centering}| +% \end{quote} +% This means that the formatting of floats prepared with standard +% |figure| and |table| environments does not changed, but service +% commands based on mini-figures and mini-tables use a special +% formatting with |\footnotesize| font and the centered alignment. +% +% \DescribeMacro\normalfloatstyle +% This command is applied inside floats or mini-floats to reset +% formatting style of subsequent floating material to the standard +% formatting with paragraph alignment and the normal font of +% normal size. +% +% \DescribeMacro{\minifig} +% \DescribeMacro{\minitabl} +% We start with the basic commands, namely |\minifig| and +% |\minitabl|. They prepare a material in a mini-page and allow +% using the |\caption| command in the body. Their syntax is +% similar to the |\parbox| command: +% \begin{quote} +% |\minifig |\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body}\\ +% |\minitabl|\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body} +% \end{quote} +% The \meta{pos} is a vertical alignment parameter for +% mini-page (|t|, |b|, or |c|) with respect to +% surrounding text; the \meta{height} is a mini-page height +% required; the \meta{inner-pos} is a vertical alignment +% of text inside the mini-page (|t|, |b|, |c|, or |s|); +% and the \meta{width} is the mini-page width. +% The \meta{body} is prepared in the style specified by the +% |\FloatingStyle| command and can contain the |\caption| command inside. +% +% All other floating extension commands are based on +% these two commands. +% +% \section{Side Figures and Tables} +% +% For small figures and tables, it is preferable to insert them +% inside a text instead of using floating mechanism. The +% typographic rules usually require an illustrative material to +% occupy an outer side of page. In two-side mode, this means +% figure and tables should be on the right side if a page number is +% odd and on the left side if page number is even. In one-side +% mode, figures and tables must occupy the right side of page. +% +% \DescribeMacro{\sidefig} +% \DescribeMacro{\sidetabl} +% The following commands support such a placement: +% \begin{quote} +% |\sidefig|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{figure}\marg{text}\\ +% |\sidefig*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{figure}\marg{text}\\ +% |\sidetabl|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{table}\marg{text}\\ +% |\sidetabl*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{table}\marg{text} +% \end{quote} +% We use the term \textit{mini-float} for the +% small illustrating material (figure or table), however +% taking into account that it is not a float at all. It is inserted in +% the main flow next to a paragraph box specified in the last +% parameter of above described commands. +% +% The no-star forms of above described commands place a mini-float +% next to the specified text on the outer side of page (to the +% right for odd page and to the left for even page). In two-column +% or one-side mode, mini-float is always posed to the right. The +% star-forms provide the reverse placement. By default, mini-float +% is vertically centered with respect to the text and the +% |\strut| command is inserted at the beginning and at the end +% of the \meta{text} to provide normal baseline +% distances of the first and last lines of the text from +% surrounding text lines. +% +% All parameters in square and round brackets are optional and mean +% the following: +% \begin{desclist}{}{}[\meta{pos}] +% \item[\meta{pos}] specifies mini-float alignment (|t|, +% |b|, or |c|; default is |c|) with respect to text +% box and can contain additional chars controlling the text body +% preparation: |j| means the last line of the text to be +% justified to the right and |n| means suppressing of struts +% insertion (they should be inserted manually if necessary); +% +% \item[$w_1$] is the width of mini-float; and +% +% \item[$w_2$] is the width of the text box. +% \end{desclist} +% +% You can omit units in the width parameters. In this case, +% the width value is considered as a multiple of |\unitlength| +% (similarly to the use of length dimensions in the picture environment). +% +% If both width parameters are absent, the width of both mini-float and +% text body is calculated as |(\linewidth-1.5em)/2|. If $w_2$ is absent, +% the text body width is calculated as |\linewidth-|$w_1$|-1.5em|. +% +% The placement of side-floats in the document consists in the following +% steps: +% \begin{enumerate} +% \item Decide where you want to insert a side-float; +% \item Insert a |\sidefig| or |\sidetabl| command after a word that finishes +% the line before the supposed side-float position; +% \item Specify a width of float in its parameter and set the top alignment +% as the \meta{pos} parameter (e.g.\ |\sidefig[t](|$w_1$|)|); +% \item Prepare the side-float in the first mandatory parameter of the command +% (e.g.\ |\sidefig[t](|$w_1$|)|\marg{figure}); +% \item Enclose enough text going after the command in braces; +% \item Translate the document; +% \item Find what part of the text is redundant in the \meta{text} parameter; +% \item Move it after the close brace; +% \item If the same paragraph continues after the close brace, add the |j| +% letter to the \meta{pos} parameter. Also change the |t| alignment +% to |c| alignment in the \meta{pos} parameter; +% \item Translate the document once more; +% \item If the side-float has a wrong placement (this can appear when paragraph +% with a side-float begins at the end of page), insert the star after +% the side-float command and translate the document once more. +% \end{enumerate} +% +% \DescribeMacro{\ifleftsidefloat} +% While preparing a side-float, it is sometimes necessary to +% provide conditional placement depending on the side a mini-float +% is posed. The command +% \begin{quote} +% |\ifleftsidefloat|\marg{left-clause}\marg{right-clause} +% \end{quote} +% provides this. It is useful in parameters of |\sidefig| or +% |\sidetabl| and processes \meta{left-clause} if the +% mini-float is posed to the left and \meta{right-clause} +% otherwise. +% +% Side-floats can be also used within floating environments to pos +% a caption near a figure or table. +% +% \section{Floating Figures and Tables} +% +% \DescribeMacro{\fig} +% \DescribeMacro{\tabl} +% The following commands envelop floating +% environments: +% \begin{quote} +% |\fig|\oarg{placement}|(|$w$|)|\marg{body}\\ +% |\fig*|\oarg{placement}|(|$w$|)|\marg{body}\\ +% |\tabl|\oarg{placement}|(|$w$|)|\marg{body}\\ +% |\tabl*|\oarg{placement}|(|$w$|)|\marg{body} +% \end{quote} +% The \meta{placement} is a float placement parameter +% describing places where a float can appear. The default value is +% |ht| (here or at the top of page). +% The optional $w$ parameter defines a +% width of box occupied by the float (the width of nested +% |\minifig| or |\minitabl|). If it +% is omitted, the float has the maximum width equal to the +% |\linewidth|. +% +% The |\fig| and |\tabl| commands envelop the |figure| +% and |table| environments respectively. Their star-forms +% envelop |figure*| or |table*| environments respectively. +% +% \section{Two Floating Figures or Tables Side by Side} +% +% \DescribeMacro{\figs} +% \DescribeMacro{\tabls} +% The following commands place two figures or tables side by side. +% \begin{quote} +% |\figs|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\ +% |\figs*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\ +% |\tabls|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2}\\ +% |\tabls*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\marg{body1}\marg{body2} +% \end{quote} +% The \meta{body1} is a body of the left figure or table and +% the \meta{body2} is a body of the right figure or table. +% Other parameters are optional. The meaning and default value of +% the \meta{placement} parameter is the same as described +% above. The $w_1$ and $w_2$ parameters are +% widths of left and right boxes. If +% they both are omitted, the left and right boxes will have the +% width equal to |(\linewidth-1em)/2|. If $w_2$ +% is omitted, the right box will occupy the rest of horizontal space +% minus |1em|. If both parameters are specified, the rest +% space is inserted between boxes. If the total width of left and +% right floats exceeds the |\linewidth|, the floats will overlap +% at the middle (a negative horizontal space is inserted between them). +% +% In the |\tabls| command, boxes of the left and right bodies are +% top-aligned, but, in the |\figs| command, the bottom alignment is +% used. The star-forms of this commands are based on the |figure*| +% or |table*| environments respectively. +% +% \section{Declare a Mini-float and Service Commands} +% +% \DescribeMacro\newminifloat +% If a new type of float is introduced, the respective mini-float +% and service commands can be helpful for it. To prepare them, use +% the following declaration: +% \begin{quote} +% |\newminifloat|\marg{gen}\marg{type}\marg{placement}\marg{pos} +% \end{quote} +% Here \meta{gen} is a root for command names to be generated, \meta{type} +% is a float type, \meta{placement} is a default placement on the page, +% and \meta{pos} is a vertical alignment for pair of floats. +% +% This command declares 4 commands: |\mini|\meta{gen}, |\side|\meta{gen}, +% |\|\meta{gen}, and |\|\meta{gen}|s|. For example, the commands +% described in previous sections are declared as follows: +% \begin{quote} +% |\newminifloat{fig}{figure}{ht}{b}|\\ +% |\newminifloat{tabl}{table}{ht}{t}| +% \end{quote} +% +% \StopEventually{} +% +% \section{The Implementation} +% +% The package uses some commands of the |nccboxes| package. +% Load it here: +% \begin{macrocode} +%<*package> +\RequirePackage{nccboxes}[2002/03/20] +% \end{macrocode} +% +% \subsection{Float Style} +% +% \begin{macro}{\FloatStyle} +% |\FloatStyle|\oarg{type}\marg{style} specifies a style for +% a given float type. +% \begin{macrocode} +\newcommand*{\FloatStyle}[2][]{% + \expandafter\def\csname NCC@fltstyle@#1\endcsname{#2}} +\@onlypreamble\FloatStyle +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@setfltstyle} +% |\NCC@setfltstyle|\marg{prefix} applies a style for a +% float of |\@captype| type. While selection a style to be +% applied it adds the given \meta{prefix} to the float type. +% \begin{macrocode} +\def\NCC@setfltstyle#1{% + \edef\@tempa{NCC@fltstyle@#1\@captype}% + \@ifundefined{\@tempa}{\NCC@fltstyle@}{\csname\@tempa\endcsname}% +} +% \end{macrocode} +% We add this style with empty prefix to the |\@floatboxreset| +% hook which is applied at the end of preamble of a float. +% \begin{macrocode} +\g@addto@macro\@floatboxreset{\NCC@setfltstyle{}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\normalfloatstyle} +% Reset a float style to par-box formatting with normal font of the +% normal size. +% \begin{macrocode} +\newcommand\normalfloatstyle{% + \leftskip\z@skip \rightskip\z@skip \@rightskip\z@skip + \parfillskip\@flushglue \let\\\@normalcr + \reset@font \normalsize +} +% \end{macrocode} +% \end{macro} +% +% \subsection{The Kernel} +% +% \begin{macro}{\NCC@minifloat} +% The base for mini-floats +% \begin{quote} +% |\NCC@minifloat|\oarg{pos}\oarg{height}\oarg{inner-pos}\marg{width}\marg{body} +% \end{quote} +% It finishes a mini-float with extra |\endgroup| command. +% A |\@captype| should be specified before it. +% \begin{macrocode} +\newcommand*\NCC@minifloat[1][c]{% + \@ifnextchar[{\NCC@mflt{#1}}{\NCC@@mflt{#1}\relax[s]}} +\def\NCC@mflt#1[#2]{% + \@ifnextchar[{\NCC@@mflt{#1}{#2}}{\NCC@mflt{#1}{#2}[#1]}} +\long\def\NCC@@mflt#1#2[#3]#4#5{% + \@iiiminipage{#1}{#2}[#3]{#4}\normalfloatstyle + \NCC@setfltstyle{mini}#5\endminipage\endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@pair} +% The command +% \begin{quote} +% |\NCC@pair|\marg{c1}\marg{c2}\marg{def-dist}\marg{def-place}|*|\oarg{place}|(|$w_1$|)(|$w_2$|)| +% \end{quote} +% executes \meta{c1}\marg{place}|{|$w_1$|}{|$w_2$|}| if star is absent or +% \meta{c2}\marg{place}|{|$w_1$|}{|$w_2$|}| if star presents. +% Four first parameters are mandatory. Others a optional. +% The \meta{def-dist} parameter contains a default distance +% value. It is saved in the |\@tempdimc| register. +% The \meta{def-place} parameter contains the default value for +% the \meta{place} parameter. If the last one is omitted, +% the \meta{def-place} is used instead. +% \begin{macrocode} +\def\NCC@pair#1#2#3#4{\setlength\@tempdimc{#3}% + \@ifstar{\NCC@pair@{#2}{#4}}{\NCC@pair@{#1}{#4}}} +\def\NCC@pair@#1#2{\@ifnextchar[{\NCC@pair@@{#1}}{\NCC@pair@@{#1}[#2]}} +\def\NCC@pair@@#1[#2]{\def\@tempa{#1{#2}}% + \@ifnextchar({\NCC@pair@@@}{\NCC@@pair()()}} +\def\NCC@pair@@@(#1){\@ifnextchar({\NCC@@pair(#1)}{\NCC@@pair(#1)()}} +\def\NCC@@pair(#1)(#2){\@tempa{#1}{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@setwidth} +% The |\NCC@setwidth|\marg{register}\marg{width} command sets +% the given \meta{width} for the \meta{register}. If units +% in \meta{width} are omitted, the |\unitlength| unit is used. +% In other words, if \meta{width} is a real number, it is considered +% as a multiple of |\unitlength|. +% \begin{macrocode} +\def\NCC@setwidth#1#2{\@defaultunits#1#2\unitlength\relax\@nnil} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@wcalc} +% The |\NCC@wcalc{|$w_1$|}{|$w_2$|}| calculates widths +% of left and right boxes in the |\@tempdima| and |\@tempdimb| +% registers. The distance between boxes must be specified in +% |\@tempdimc| register before the call. The algorithm: +% \begin{itemize} +% \item If $w_1$ is empty, |\@tempdima:=(\linewidth-\@tempdimc)/2|, +% otherwise, |\@tempdima:=|$w_1$; +% \item If $w_2$ is empty, |\@tempdimb:=\linewidth-\@tempdima-\@tempdimc|, +% otherwise, |\@tempdimb:=|$w_2$; +% \item If $w_2$ is nonempty, +% |\@tempdimc:=\linewidth-\@tempdima-\@tempdimb|. +% \end{itemize} +% \begin{macrocode} +\def\NCC@wcalc#1#2{% + \if!#1!\@tempdima .5\linewidth \advance\@tempdima -.5\@tempdimc + \else \NCC@setwidth\@tempdima{#1}% + \fi + \if!#2!\@tempdimb \linewidth \advance\@tempdimb -\@tempdima + \advance\@tempdimb -\@tempdimc + \else \NCC@setwidth\@tempdimb{#2}% + \@tempdimc \linewidth \advance\@tempdimc -\@tempdima + \advance\@tempdimc -\@tempdimb + \fi +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Side Floats} +% +% \begin{macro}{\ifleftsidefloat} +% This command is used in parameters of side-floats. +% \begin{macrocode} +\newif\ifNCC@smfltleft +\newcommand{\ifleftsidefloat}{% + \ifNCC@smfltleft + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@sidemfloat} +% The command +% \begin{quote} +% |\NCC@sidemfloat|\marg{command}|*|\oarg{pos}|(|$w_1$|)(|$w_2$|)|\marg{mini-float}\marg{text} +% \end{quote} +% is used for preparing a side-float. The \meta{command} parameter +% contains a |\mini|\meta{gen} command. The \meta{pos} parameter +% specifies vertical alignment and additional flags. The +% $w_1$ and $w_2$ parameters (if present) specify widthes of +% \meta{mini-float} and \meta{text} boxes. Starred version +% reverses the position of side-float and text boxes. +% The implementation of these commands is based +% on the |\NCC@pair| command that parses all optional +% parameters. Finally the |\NCC@smflt| command is +% executed. +% \begin{macrocode} +\def\NCC@sidemfloat#1{% + \NCC@smfltleftfalse + \if@twocolumn \else + \if@twoside + \ifodd\c@page \else \NCC@smfltlefttrue \fi + \fi + \fi + \NCC@pair{\NCC@smflt{#1}}% + {\ifNCC@smfltleft \NCC@smfltleftfalse \else \NCC@smfltlefttrue\fi + \NCC@smflt{#1}}% + {1.5em}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@smflt} +% The command +% \begin{quote} +% |\NCC@smflt|\marg{command}\marg{pos}|{|$w_1$|}{|$w_2$|}|\marg{mini-float}\marg{text} +% \end{quote} +% prepares a side-float. The |\@tempdimc| register +% contains the default distance between the mini-float and text. +% \begin{macrocode} +\long\def\NCC@smflt#1#2#3#4#5#6{% +% \end{macrocode} +% Parse the \meta{pos} parameter. Create a |\NCC@|\meta{letter} +% command with empty content for every \meta{letter} from the \meta{pos}. +% \begin{macrocode} + \let\NCC@t\relax \let\NCC@b\relax \let\NCC@j\relax \let\NCC@n\strut + \@tfor\@tempa :=#2\do {% + \expandafter\let\csname NCC@\@tempa\endcsname\@empty}% +% \end{macrocode} +% Define the vertical alignment letter in the |\NCC@c| command. +% \begin{macrocode} + \ifx\NCC@t\@empty \def\NCC@c{t}\else + \ifx\NCC@b\@empty \def\NCC@c{b}\else + \def\NCC@c{c}% + \fi + \fi +% \end{macrocode} +% Define a justification hook in the |\NCC@j| command. +% \begin{macrocode} + \ifx\NCC@j\@empty \def\NCC@j{\parfillskip\z@skip}\fi +% \end{macrocode} +% Define the text starting hook in the |\NCC@t| command. +% It will contain the |\parindent| setting command and +% the optional |\noindent| command. +% \begin{macrocode} + \edef\NCC@t{\parindent\the\parindent\ifvmode\else\noindent\fi}% +% \end{macrocode} +% Complete the current paragraph and leave the horizontal mode. +% \begin{macrocode} + \ifvmode\else + \unskip{\parfillskip\rightskip\par}\vskip -\parskip + \fi +% \end{macrocode} +% Prepare the side-float in |\@tempboxa|: +% \begin{macrocode} + \setbox\@tempboxa\vbox{\hsize\linewidth\noindent +% \end{macrocode} +% Calculate widthes of left and right boxes and distance +% between them in |\@tempdima|, |\@tempdimb|, and |\@tempdimc|. +% \begin{macrocode} + \NCC@wcalc{#3}{#4}% +% \end{macrocode} +% Conditionally put a side-float to the left: +% \begin{macrocode} + \ifNCC@smfltleft + \jparbox{\Strut}[\NCC@c]\@tempdima{#1\@tempdima{#5}}% + \nobreak\hskip\@tempdimc + \fi +% \end{macrocode} +% Put a text box: +% \begin{macrocode} + \jparbox{\NCC@n\Strut}[\NCC@c]\@tempdimb{% + \everypar{\NCC@n\everypar{}}\NCC@t#6% + \ifvmode \else \unskip\NCC@n\NCC@j\fi}% +% \end{macrocode} +% Conditionally put a side-float to the right: +% \begin{macrocode} + \ifNCC@smfltleft \else + \nobreak\hskip\@tempdimc + \jparbox{\Strut}[\NCC@c]\@tempdima{#1\@tempdima{#5}}% + \fi + }% +% \end{macrocode} +% Games with height and depth the |\@temboxa| allow us +% produce right line spacing with surrounding text. +% \begin{macrocode} + \@tempdima\dp\@tempboxa \advance\@tempdima\lineskip + \dp\@tempboxa\@tempdima + \@tempdima\ht\@tempboxa \advance\@tempdima -\ht\strutbox + \noindent \raise-\@tempdima\box\@tempboxa +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Service Commands} +% +% \begin{macro}{\NCC@float} +% The command +% \begin{quote} +% |\NCC@float|\marg{type}\marg{def-place}|*|\oarg{placement}|(|$w$|)|\marg{body} +% \end{quote} +% is the envelope for a mini-float inside a float. The \meta{def-place} +% is the default placement specifier. +% \begin{macrocode} +\def\NCC@float#1#2{\@ifstar{\NCC@flt{#1*}{#2}}{\NCC@flt{#1}{#2}}} +\def\NCC@flt#1#2{\@ifnextchar[{\NCC@flt@{#1}}{\NCC@flt@{#1}[#2]}} +\def\NCC@flt@#1[#2]{\begin{#1}[#2]\normalfloatstyle\centering + \@ifnextchar({\NCC@@flt{#1}}{\NCC@@flt{#1}()}} +\long\def\NCC@@flt#1(#2)#3{% + \if!#2!\@tempdima\linewidth \else \NCC@setwidth\@tempdima{#2}\fi + \begingroup\NCC@minifloat[c]\@tempdima{#3}% + \end{#1}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@floats} +% The command +% \begin{quote} +% |\NCC@floats|\marg{type}\marg{pos}\marg{def-place}|*|\oarg{placement}|(|$w_1$|)(|$w_2$|)|\\ +% | |\marg{body1}\marg{body2} +% \end{quote} +% is the envelope for a pair of mini-floats inside a float. The implementation +% of these commands is based +% on the |\NCC@pair| command that parses all optional +% parameters. Finally the |\NCC@flts| command is +% executed. +% \begin{macrocode} +\def\NCC@floats#1#2#3{% + \NCC@pair{\NCC@@flts{#1}{#2}}{\NCC@@flts{#1*}{#2}}{1em}{#3}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@flts} +% The command +% \begin{quote} +% |\NCC@flts|\marg{type}\marg{pos}\marg{placement}|{|$w_1$|}{|$w_2$|}|\marg{body1}\marg{body2} +% \end{quote} +% prepares a pair of floats within \meta{type} environment. +% The \meta{pos} contains relative vertical alignment of floats. +% The $w_1$ and $w_2$ parameters (if present) specify widthes of +% floats. The |\@tempdimc| register contains the default distance +% between floats. +% \begin{macrocode} +\long\def\NCC@@flts#1#2#3#4#5#6#7{% + \begin{#1}[#3]\normalfloatstyle\NCC@wcalc{#4}{#5}% + \begingroup\NCC@minifloat[#2]\@tempdima{#6}% + \nobreak\hskip\@tempdimc + \begingroup\NCC@minifloat[#2]\@tempdimb{#7}% + \end{#1}% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Declare a New Mini-float and Service Commands} +% +% \begin{macro}{\newminifloat} +% The command +% \begin{quote} +% |\newminifloat|\marg{gen}\marg{type}\marg{def-place}\marg{pos} +% \end{quote} +% declares a new mini-float and 3 service commands. +% \begin{macrocode} +\newcommand*\newminifloat[4]{% + \edef\@tempa{% +% \end{macrocode} +% Prepare |\mini|\meta{gen} definition: +% \begin{macrocode} + \noexpand\newcommand\expandafter\noexpand\csname mini#1\endcsname{% + \noexpand\begingroup\noexpand\def\noexpand\@captype{#2}% + \noexpand\NCC@minifloat}% +% \end{macrocode} +% Prepare |\side|\meta{gen} definition: +% \begin{macrocode} + \noexpand\newcommand\expandafter\noexpand\csname side#1\endcsname{% + \noexpand\NCC@sidemfloat{% + \expandafter\noexpand\csname mini#1\endcsname}}% +% \end{macrocode} +% Prepare |\|\meta{gen} definition: +% \begin{macrocode} + \noexpand\newcommand\expandafter\noexpand\csname #1\endcsname{% + \noexpand\NCC@float{#2}{#3}}% +% \end{macrocode} +% Prepare |\|\meta{gen}|s| definition: +% \begin{macrocode} + \noexpand\newcommand\expandafter\noexpand\csname #1s\endcsname{% + \noexpand\NCC@floats{#2}{#4}{#3}}% + }% +% \end{macrocode} +% Define all commands: +% \begin{macrocode} + \@tempa +} +\@onlypreamble\newminifloat +% \end{macrocode} +% \end{macro} +% +% \subsection{Base Mini-floats and Defaults} +% +% \begin{macrocode} +\newminifloat{fig}{figure}{ht}{b} +\newminifloat{tabl}{table}{ht}{t} +\FloatStyle{} +\FloatStyle[minifigure]{\footnotesize\centering} +\FloatStyle[minitable]{\footnotesize\centering} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccfoots.dtx b/macros/latex/contrib/ncctools/source/nccfoots.dtx new file mode 100644 index 0000000000..c428928314 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccfoots.dtx @@ -0,0 +1,95 @@ +% \iffalse +%% +%% File: nccfoots.dtx Copyright (C) 1998-2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccfoots} +% [2005/02/03 v1.2 NCC Footnotes Package (NCC)] +% +% \changes{v1.0}{1998/12/18}{Initial version} +% \changes{v1.1}{2004/11/23}{Minor corrections of the documentation} +% \changes{v1.2}{2005/02/03}{\NCC@makemark rename to \NCC@makefnmark} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccfoots} +\GetFileInfo{nccfoots.sty} +\begin{document} +\title{The \textsf{nccfoots} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccfoots.dtx} +\end{document} +% +% \fi +% +% The package implements commands for generating footnotes marked by +% hands. +% +% \section{User Interface} +% +% \DescribeMacro\Footnotemark +% \DescribeMacro\Footnotetext +% \DescribeMacro\Footnote +% These commands are acompany to the ordinary \LaTeX's footnote mark +% command. They allow user to mark footnotes by hands. Their syntax is +% the following: +% \begin{quote} +% |\Footnotemark|\marg{marker}\\ +% |\Footnotetext|\marg{marker}\marg{inserted text}\\ +% |\Footnote|\marg{marker}\marg{inserted text} +% \end{quote} +% When \meta{marker} is empty the previous marker will be used. Hence, +% |\Footnote| command is equal to +% \begin{quote} +% |\Footnotemark|\marg{marker}|\Footnotetext{}|\marg{inserted text} +% \end{quote} +% +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\NCC@makefnmark} +% We begin with the internal command |\NCC@makemark| which tests the +% footnote marker to be empty and globally redefines \LaTeX{} +% internal command |\@thefnmark| to be equal to this marker. +% We use exactly the same expansion method as in \LaTeXe{}. +% We also initialize |\@thefnmark| command to avoid error when the +% first marking command has an empty marker. +% \begin{macrocode} +%<*package> +\def\NCC@makefnmark#1{\def\@tempa{#1}% + \ifx\@tempa\@empty \else + \begingroup + \unrestored@protected@xdef\@thefnmark{#1}% + \endgroup + \fi +} +\let\@thefnmark\@empty +% \end{macrocode} +% \textbf{Note}. If you use an automatic enumeration and produce +% marker by |\the|\meta{counter} the internal command producing the +% shape of number have to be \emph{robust}. All standard shaping +% commands like |\arabic|, |\roman|, etc., are robust. Take it +% into account if you want design your own shape. +% \end{macro} +% +% \begin{macro}{\Footnote} +% \begin{macro}{\Footnotemark} +% \begin{macro}{\Footnotetext} +% Finally, we add the handle style footnote commands which are +% companions to the respective standard ones. +% \begin{macrocode} +\newcommand*{\Footnote}[1]{\Footnotemark{#1}\@footnotetext} +\newcommand*{\Footnotemark}[1]{\NCC@makefnmark{#1}\@footnotemark} +\newcommand*{\Footnotetext}[1]{\NCC@makefnmark{#1}\@footnotetext} +% +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccmath.dtx b/macros/latex/contrib/ncctools/source/nccmath.dtx new file mode 100644 index 0000000000..23030e7b64 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccmath.dtx @@ -0,0 +1,1186 @@ +% \iffalse +%% +%% File: nccmath.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e}[1995/12/01] +%\ProvidesPackage{nccmath} +% [2006/01/20 v1.3 Additional Math Commands (NCC)] +% +% \changes{v1.01}{2002/01/20}{This version is uploaded to CTAN} +% \changes{v1.02}{2002/02/19}{|\Eq|, |\Eqs|, and |\Eqalign| are removed} +% \changes{v1.03}{2002/03/16}{|\useshortskip| command added} +% \changes{v1.1}{2004/12/08}{Do |fleqn| and |ceqn| working with all display equations} +% \changes{v1.1}{2004/12/08}{Documentation was prepared} +% \changes{v1.2}{2005/02/13}{Introduce |\medmath|, |\mfrac|, |\mbinom|, |mmatrix|} +% \changes{v1.2}{2005/02/14}{Introduce |\medop|, |\medint|, |\medintkern|, |medsize|} +% \changes{v1.2}{2005/02/15}{Introduce |mediummath|} +% \changes{v1.2}{2005/02/16}{Remove redefinition of equations tag} +% \changes{v1.2}{2005/02/21}{Avoid conflicts with the |array| package} +% \changes{v1.3}{2006/01/20}{Introduce |\dmulticolumn| to use within |darray|} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccmath,desclist} +\GetFileInfo{nccmath.sty} +\newcommand*\com[1]{{\tt\symbol{"5C}#1}} + +\begin{document} +\title{The \textsf{nccmath} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccmath.dtx} +\end{document} +% +% \fi +% The package extends the |amsmath| package adding some math +% commands from NCC-\LaTeX. It also improves spacing control +% before display equations and fixes a bug of ignoring +% the |\displaybreak| in the |amsmath| version of the +% |equation| environment. All options are passed +% to the |amsmath| package. +% +% \tableofcontents +% +% \section{Improvement to the amsmath} +% +% \DescribeMacro{eqnarray} +% In the |amsmath| package, the |eqnarray| environment leaves +% unchanged because alternative \AmS\ environments exist. We +% redefine the |eqnarray| to work in the \AmS\ style. The +% following improvements are done in it: an equation tag is +% prepared by the same manner as in \AmS\ display formulas +% (|\tag| and |\tag*| are allowed); the |\displaybreak| +% command is allowed; the intercolumn distance is reduced to the +% distance between ordinary and relational math symbols; and the +% center field is prepared in the |\displaystyle| (the original +% version uses |\textstyle| here). +% +% \DescribeMacro{\intertext} +% The |\intertext| command is improved here. It now has an optional +% parameter: +% \begin{quote} +% |\intertext|\oarg{distance}\marg{text} +% \end{quote} +% The \meta{distance} parameter specifies a vertical space inserted +% before and after the text. If it is omitted, standard \TeX's +% skips are inserted. +% +% The following changes are made in display equations: +% \begin{itemize} +% \item The |\displaybreak| command now works within the |equation| +% environment (it is ignored in the |amsmath|); +% \item The \AmS\ and \LaTeX\ display equations prepared in the +% vertical mode do not produce now an empty extra line before. +% Moreover, if a minipage starts from a display formula, +% the vertical skip before is suppressed. +% \end{itemize} +% +% \section{Extra Macros} +% +% \DescribeMacro{fleqn} +% \DescribeMacro{ceqn} +% The following environments allow change the horizontal alignment +% of formulas inside them: +% \begin{quote} +% |\begin{fleqn}|\oarg{margin} \ldots\ |\end{fleqn}|\\ +% |\begin{ceqn}| \ldots\ |\end{ceqn}| +% \end{quote} +% The |fleqn| environment prepares inner display equations in +% the flush left style. The \meta{margin} parameter specifies +% the left margin value. If it is omitted, zero value is used. +% The |ceqn| environment prepares inner display equations in the +% centered style. They have no effect on formulas prepared with the +% low-level \TeX\ command~|$$|. +% +% \DescribeMacro{darray} +% The |darray| environment produces an array of formulas in the +% |\displaystyle|. The distance between formulas is enlarged in +% just the same manner as in other multiline display equations. The +% |darray| environment has the same syntax as the |array|: +% \begin{quote} +% |\begin{darray}|\oarg{pos}\marg{columns}\\ +% \meta{body}\\ +% |\end{darray}| +% \end{quote} +% The \meta{pos} argument describes the vertical alignment of +% the array box (|t|, |b|, or |c|; default is |c|). The +% use of column specifications in the \meta{columns} argument +% is restricted in comparison with |array|: it can contain +% the |l|, |c|, and |r| specifiers, |*| and |@| commands. +% The intercolumn separation is smaller than in the |array|: +% it is reduced to the distance between ordinary and relational +% math symbols. As in the |amsmath| package, the thin skip is +% inserted before |darray|. Skips before the first and after +% the last column of |darray| are not inserted. +% To insert them manually, use |@{...}| in the \meta{columns} +% argument. +% +% The |darray| environment is implemented independently on the +% |array| environment to avoid conflicts with the |array| package. +% +% \DescribeMacro{\dmulticolumn} +% |\dmulticolumn|\marg{count}\marg{preamble}\marg{formula} +% is used in |darray| instead of |\multicolumn|. +% +% \DescribeMacro{\useshortskip} +% In \TeX, two types of skips above display formulas are used: the +% normal skip defined in the |\abovedisplayskip| register and the +% short skip defined in the |\abovedisplayshortskip| register. +% When a display formula is typed out, \TeX\ decides what skip to +% insert depending on the width of formula, its style (centered or +% flushed left, numbered left or right), and the width of the rest +% of text in the last line of the previous paragraph. But this +% algorithm works for ordinary formulas only. It does not work in +% multiline formulas prepared with |\halign| command. So, a +% manual replacement of the normal skip to the short skip is required +% in some cases. To provides this, the |\useshortskip| command is +% introduced. It forces the use of short skip in the next +% display formula but it has no effect on formulas prepared with the +% low-level \TeX\ command |$$|. +% +% \DescribeMacro{\nr} +% The vertical distance between lines of miltiline equations +% is frequently smaller than necessary. To increase it, the +% extra distance can be used as the optional parameter of the +% |\\|\oarg{dist} command. +% In most cases, it is enough to increase the distance on |0.5ex|. +% We introduce the |\nr| command here that is equivalent to the +% |\\[0.5ex]|. Its full sintax is just the same as for the |\\| command: +% \begin{quote} +% |\nr*|\oarg{dist} +% \end{quote} +% This command can be used everywhere the command |\\| is allowed. +% +% \DescribeMacro{\mrel} +% The |\mrel|\marg{column} command composes a new math relation symbol +% from a one-column stack of math formulas described in the \meta{column} +% parameter. For example, the command |$\mrel{<\\[-.7ex]>}$| produces +% $\mrel{<\\[-.7ex]>}$. +% +% \DescribeMacro{\underrel} +% The |\underrel|\marg{base}\marg{bottom} command is a twin to +% the |\overrel| command. For example, the command +% |$A\underrel{\longrightarrow}{x\to 0}B$| produces +% $A\underrel{\longrightarrow}{x\to 0}B$. +% +% \section{Medium-Size Math Commands} +% +% Since version 1.2, a collection of medium-size math commands is +% introduced. +% +% \DescribeMacro{\medmath} +% The |\medmath|\marg{formula} command decreases a size of formula +% in 1.2 times and prepares it in the display style. An example: +% \begin{quote} +% |$\medmath{\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}}$|\\ +% |\quad $\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}$| +% \end{quote} +% It produces: +% \begin{quote} +% $\medmath{\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}}$ +% \quad $\cfrac{1}{\sqrt 2 +\cfrac{1}{\sqrt 2 +\dotsb}}$ +% \end{quote} +% +% \DescribeMacro{\medop} +% The |\medop|\marg{operator} command prepares a medium-size operator +% with the required preference for limits. It can be use with |\sum| and +% others variable-size commands except integrals. An example: +% \begin{quote} +% |$\sum_{i=1}^n \medop\sum_{i=1}^n \displaystyle|\\ +% |\sum\nolimits_{i=1}^n$\quad $\sum\limits_{i=1}^n|\\ +% |\displaystyle \medop\sum_{i=1}^n \sum_{i=1}^n$| +% \end{quote} +% It produces: +% \begin{quote} +% $\sum_{i=1}^n \medop\sum_{i=1}^n \displaystyle \sum\nolimits_{i=1}^n$ +% \quad$\sum\limits_{i=1}^n \displaystyle \medop\sum_{i=1}^n \sum_{i=1}^n$ +% \end{quote} +% +% \DescribeMacro{\medint} +% The |\medint|\marg{operator} command prepares a medium-size integral +% with required preference for limits. It can be use with |\int|-family +% of commands and |\oint| command. An example: +% \begin{quote} +% |$\int_a^b \medint\int_a^b \displaystyle\int_a^b$\quad|\\ +% |$\int\limits_a^b \medint\int_a^b\limits \displaystyle|\\ +% |\int_a\limits^b$\quad $\iint_a^b \medint\iiint_a^b|\\ +% |\displaystyle\iiiint_a^b$\quad $\iint\limits_X^Y|\\ +% |\medint\iiint_X\limits^Y \displaystyle \iiiint_X^Y\limits$|\\ +% |\quad $\medint\idotsint_X\limits \medint\oint_X^Y$| +% \end{quote} +% It produces: +% \begin{quote} +% $\int_a^b \medint\int_a^b \displaystyle\int_a^b$\quad +% $\int\limits_a^b \medint\int_a^b\limits \displaystyle +% \int_a\limits^b$\quad $\iint_a^b \medint\iiint_a^b +% \displaystyle\iiiint_a^b$\quad $\iint\limits_X^Y +% \medint\iiint_X\limits^Y \displaystyle \iiiint_X^Y\limits$ +% \quad $\medint\idotsint_X\limits \medint\oint_X^Y$ +% \end{quote} +% By the way, the original limits recognizing in |amsmath| +% multi-integrals is very restrictive: it allows only one |\limits|-like +% command right after the multi-integral. In this package, the +% recognizing is improved to work as \TeX's one. +% +% \DescribeMacro{\medintcorr} +% The |\medintcorr|\marg{length} command specifies the value of +% italic correction for medium integrals. It controls a positioning indices +% in medium integrals and in multi-integrals. Its default value is |0.5em|. +% +% \DescribeMacro{\mfrac} +% \DescribeMacro{\mbinom} +% Based on the medium size formulas, the |\mfrac| and |\mbinom| commands +% are introduced. They are similar to |\frac| and |\binom|. An example: +% \begin{quote} +% |$\frac {x+y}{a-b} \mfrac {x+y}{a-b} \dfrac {x+y}{a-b}$\quad|\\ +% |$\binom {n}{k} \mbinom {n}{k} \dbinom {n}{k}$| +% \end{quote} +% It produces: +% \begin{quote} +% $\frac {x+y}{a-b} \mfrac {x+y}{a-b} \dfrac {x+y}{a-b}$\quad +% $\binom {n}{k} \mbinom {n}{k} \dbinom {n}{k}$ +% \end{quote} +% +% \DescribeMacro{medsize} +% \DescribeMacro{mmatrix} +% The |medsize| environment is introduced to prepare formulas and arrays +% in the medium size. It reduces the |\arraycolsep| value by 0.8~times. Basing +% on it, the |mmatrix| environment is introduced. It is specified as +% follows: +% \begin{quote} +% |\begin{mmatrix} ... \end{mmatrix}|\quad $\equiv$\quad\\ +% |\begin{medsize}\begin{matrix} ... \end{matrix}\end{medsize}| +% \end{quote} +% An example: +% \begin{quote} +% |$\bigl(\begin{smallmatrix} a&b\\c&d\end{smallmatrix}\bigr)$|\\ +% |$\Bigl(\begin{mmatrix} a&b\\c&d\end{mmatrix}\Bigr)$|\\ +% |$\begin{pmatrix}a&b\\c&d\end{pmatrix}$| +% \end{quote} +% It produces: +% \begin{quote} +% $\bigl(\begin{smallmatrix} a&b\\c&d\end{smallmatrix}\bigr)$ +% $\Bigl(\begin{mmatrix} a&b\\c&d\end{mmatrix}\Bigr)$ +% $\begin{pmatrix}a&b\\c&d\end{pmatrix}$ +% \end{quote} +% +% \DescribeMacro{mediummath} +% Finally, the |mediummath| option allows prepare all variable-size +% math elements in medium size. It redefines |\frac|, |\binom| and +% all math operators to the medium size. For |\frac| and |\binom|, +% the medium size is applied in the display and text styles. +% The |\dfrac|, |\tfrac|, |\dbinom|, and |\tbinom| commands have +% the old meaning. +% +% \section{NCC-\LaTeX\ Equivalents to Display Formulas} +% +% The following NCC-\LaTeX\ equivalents are provided with +% this package: +% \begin{desclist}{}{\hfill\enskip=}[\com{eqalign*}\marg{formulas}] +% \raggedright +% \item[\com{eq}\marg{formula}] +% |\begin{equation}| \meta{formula} |\end{equation}|. +% +% \item[\com{eq*}\marg{formula}] +% |\begin{equation*}| \meta{formula} |\end{equation*}|. +% +% \item[\com{eqs}\marg{formulas}] +% |\begin{eqnarray}| \meta{formulas} |\end{eqnarray}|. +% +% \item[\com{eqs*}\marg{formulas}] +% |\begin{eqnarray*}| \meta{formulas} |\end{eqnarray*}|. +% +% \item[\com{eqalign}\marg{formulas}] +% |\begin{equation} \begin{darray}{rcl}| \meta{formulas} +% |\end{darray} \end{equation}|. +% +% \item[\com{eqalign*}\marg{formulas}] +% |\begin{equation*} \begin{darray}{rcl}| \meta{formulas} +% |\end{darray} \end{equation*}|. +% \end{desclist} +% +% The |\eqs| and |\eqs*| commands have an optional parameter +% specifying a distance between columns. For example, in the command +% \begin{quote} +% \verb+\eqs[0mm]{&& -\Delta u = f, \\ && u|_\Gamma = 0,}+ +% \end{quote} +% the intercolumn distance is removed because only the 3rd column is +% used. The |eqnarray| environment has no optional parameter. +% +% The |\eqalign| and |\eqalign*| commands also have an optional +% parameter. Its meaning is the column specification +% parameter: |\eqalign|\marg{formulas} |=| +% |\eqalign[rcl]|\marg{formulas}. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% At first we load the |amsmath| package and pass all options to it +% except the |mediummath| option. +% \begin{macrocode} +%<*package> +\DeclareOption{mediummath}{\newcommand\NCC@op{}} +\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{amsmath}} +\ProcessOptions\relax +\RequirePackage{amsmath}[2000/07/18] +% \end{macrocode} +% +% \subsection{Kernel} +% +% \begin{macro}{\NCC@cr} +% Simplified version of |\\| used in some commands here. +% The low level command |\NCC@cr@@@|\marg{skip} is defined +% if necessary to |\NCC@aligncr| or to something else. +% The |\new@ifnextchar| commands from the \AmS\ does the +% same as |\@ifnextchar|, but disallows spaces before the +% tested symbol. +% \begin{macrocode} +\newif\ifNCC@star +\def\NCC@cr{\relax\iffalse{\fi\ifnum0=`}\fi + \@ifstar{\global\NCC@startrue\NCC@cr@}{\global\NCC@starfalse\NCC@cr@}% +} +\def\NCC@cr@{\new@ifnextchar[\NCC@cr@@{\NCC@cr@@[\z@]}} +\def\NCC@cr@@[#1]{\ifnum0=`{\fi \iffalse}\fi\NCC@cr@@@{#1}} +\def\NCC@aligncr#1{\cr\noalign{\vskip #1\relax}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@default@cr} +% This command sets defaults for the |\\| command. +% \begin{macrocode} +\def\NCC@default@cr{\let\\\NCC@cr \let\NCC@cr@@@\NCC@aligncr} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\nr} +% The |\nr| command has just the same syntax as |\\| +% but adds 0.5ex extra vertical space between lines. +% It can work anywhere the |\\| command is allowed. +% We temporary change in it the value of |\NCC@cr@@@| to +% |\NCC@nr| and restore it later. +% \begin{macrocode} +\newcommand{\nr}{% + \let\NCC@temp\NCC@cr@@@ + \let\NCC@cr@@@\NCC@nr + \NCC@cr +} +\def\NCC@nr#1{% + \let\NCC@cr@@@\NCC@temp + \setlength\@tempskipa{#1}\advance\@tempskipa .5ex + \ifNCC@star + \edef\@tempa{\noexpand\\*[\the\@tempskipa]}% + \else + \edef\@tempa{\noexpand\\[\the\@tempskipa]}% + \fi + \@tempa +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Additional Math Commands} +% +% \begin{macro}{\mrel} +% The |\mrel|\marg{column} command composes a new math relation and +% vertically centers it with respect to the math line. +% \begin{macrocode} +\newcommand{\mrel}{\mathpalette\NCC@rel} +\def\NCC@rel#1#2{\mathrel{\vcenter{\NCC@default@cr + \offinterlineskip \ialign{\hfil$\m@th#1##$\hfil\cr#2\crcr}}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\underrel} +% The |\underrel|\marg{base}\marg{bottom} command is a twin to +% |\overrel|. +% \begin{macrocode} +\newcommand{\underrel}[2]{\mathrel{\mathop{#1}\limits_{#2}}} +% \end{macrocode} +% \end{macro} +% +% \subsection{Medium-Size Math Commands} +% +% \begin{macro}{\NCC@select@msize} +% The |\NCC@select@msize| command prepares dimensions for medium-size math: +% \begin{itemize} +% \item In |\NCC@fracrulewidth| --- a rule width in fractions; +% \item In |@tempdima| --- a raising value; and +% \item In |@tempdimb| --- a font size to be used in medium fractions +% and matrices. +% \end{itemize} +% \begin{macrocode} +\newdimen\NCC@fracrulewidth +\def\NCC@select@msize{\relax +% \end{macrocode} +% |\@tempdima| contains the current font size +% \begin{macrocode} + \@tempdima \f@size\p@ +% \end{macrocode} +% Calculate in |\@tempdimb| a text font size in medium fraction +% \begin{macrocode} + \ifdim\@tempdima>11.5\p@ + \@tempdimb .83\@tempdima + \else + \@tempdimb .8\@tempdima + \ifdim\@tempdimb<5\p@ \@tempdimb 5\p@\fi + \fi +% \end{macrocode} +% Calculate in |\NCC@fracrulewidth| the rule width and in +% |\@tempdima| --- the raising value +% \begin{macrocode} + \NCC@fracrulewidth .04\@tempdima + \@tempdima 1.25\NCC@fracrulewidth + \ifdim\NCC@fracrulewidth>.45\p@ \else + \ifdim\NCC@fracrulewidth>.34\p@ \NCC@fracrulewidth .4\p@ + \else \NCC@fracrulewidth .3\p@ + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@innerfrac} +% \begin{macro}{\NCC@innerbinom} +% The |\NCC@innerfrac|\marg{style} prepares a fraction with a +% special width in the given style: +% \begin{macrocode} +\def\NCC@innerfrac#1{\genfrac{}{}\NCC@fracrulewidth{#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@prepare@msize} +% Select a font by rounding its pt-size to the nearest integer +% and redefine fractions to have the given rule width. The |\binom| +% command is redefined also to its original value because it can be +% changed when the |mediummath| option is applied. +% \begin{macrocode} +\def\NCC@prepare@msize{% + \@tempdima 1.2\@tempdimb + \advance\@tempdimb .5\p@ + \edef\@tempa{\strip@pt\@tempdimb}% + \expandafter\NCC@floor\expandafter\@tempa\@tempa.\@nil + \fontsize\@tempa\@tempdima\selectfont + \def\frac{\protect\NCC@innerfrac{}}% + \def\dfrac{\NCC@innerfrac\z@}% + \def\tfrac{\NCC@innerfrac\@ne}% + \def\binom{\protect\genfrac()\z@{}}% +} +\def\NCC@floor#1#2.#3\@nil{\def#1{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@op@prepare} +% |\NCC@op@prepare|\marg{integral} +% command prepares an integral. It looks forward, extracts indices +% and limits-change commands, and puts the integral with required kerning +% of indices. The |\NCC@op@print| driver is a command to print the integral. +% Its default value is |\NCC@op@printm|. The driver uses the following hooks: +% |\NCC@op| contains an integral command, |\NCC@op@lim| contains +% the selected limits-style, |\NCC@op@sb| contains a subscript, +% |\NCC@op@sp| contains a superscript, |NCC@op@kern| contains the +% kerning value for medium-size integrals. If subscript or superscript +% is omitted, the corresponding hook is equal to |\relax|. +% \begin{macrocode} +\DeclareRobustCommand*\NCC@op@prepare[1]{% + \def\NCC@op{#1}% + \let\NCC@op@print\NCC@op@printm + \NCC@op@prepare@ +} +\def\NCC@op@prepare@{% + \let\NCC@op@lim\ilimits@ + \let\NCC@op@sp\relax + \let\NCC@op@sb\relax + \NCC@op@next +} +\def\NCC@op@next{\futurelet\@let@token\NCC@op@getnext} +% \end{macrocode} +% Test the next token and get it if necessary: +% \begin{macrocode} +\def\NCC@op@getnext{% + \let\@tempa\NCC@op@skip + \ifx\@let@token\limits + \let\NCC@op@lim\limits \else + \ifx\@let@token\nolimits + \let\NCC@op@lim\nolimits \else + \ifx\@let@token\displaylimits + \let\NCC@op@lim\displaylimits \else + \ifx\@let@token\sp + \NCC@op@test\NCC@op@sp + \def\@tempa{\NCC@op@get\NCC@op@sp}\else + \ifx\@let@token\sb + \NCC@op@test\NCC@op@sb + \def\@tempa{\NCC@op@get\NCC@op@sb}\else + \ifx\@let@token\@sptoken + \let\@tempa\NCC@op@skipsp \else + \let\@tempa\NCC@op@print + \fi + \fi + \fi + \fi + \fi + \fi + \@tempa +} +% \end{macrocode} +% Skip |\limits|-like token: +% \begin{macrocode} +\def\NCC@op@skip#1{\NCC@op@next} +% \end{macrocode} +% Skip a space token. A space token is skipped within |\@ifnextchar| +% before comparing it with the first parameter. So, it does not important +% what char to test for: +% \begin{macrocode} +\def\NCC@op@skipsp{% + \@ifnextchar0{\NCC@op@next}{\NCC@op@next}% +} +% \end{macrocode} +% Test subscript or superscript to be already defined: +% \begin{macrocode} +\def\NCC@op@test#1{% + \ifx#1\relax \else + \PackageError{nccmath}{Double index in math operator}{} + \fi +} +% \end{macrocode} +% Get a subscript or superscript: +% \begin{macrocode} +\def\NCC@op@get#1#2#3{\def#1{#3}\NCC@op@next} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@op@printm} +% Driver for printing the medium-size integral with indices: +% \begin{macrocode} +\def\NCC@op@printm{% + \ifx\NCC@op@lim\nolimits \NCC@op@printm@\@ne \else + \ifx\NCC@op@lim\limits \NCC@op@printm@\z@ \else + \mathchoice{\displaystyle\NCC@op@printm@\z@}% + {\textstyle\NCC@op@printm@\@ne}% + {\scriptstyle\NCC@op@printm@\@ne}% + {\scriptscriptstyle\NCC@op@printm@\@ne}% + \fi + \fi +} +\def\NCC@op@printm@{\NCC@op@print@\NCC@op\NCC@op@kern} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@op@print@} +% |\NCC@op@print@|\marg{integral}\marg{kern}\marg{level} command +% prints an \meta{integral} using the specified \meta{kern} in indices. +% If \meta{level} = 0 use |\limits| else use |\nolimits|. +% \begin{macrocode} +\def\NCC@op@print@#1#2#3{\mathop{#1}% + \setlength\@tempdima{#2}% + \@tempswatrue + \ifx\NCC@op@sb\relax \else \ifnum#3>\z@ \@tempswafalse \fi \fi + \ifx\NCC@op@sp\relax \else \ifnum#3>\z@ \@tempswafalse \fi \fi + \edef\@tempa{% + \ifnum#3=\z@ \noexpand\limits \else \noexpand\nolimits \fi + \ifx\NCC@op@sb\relax \else + \noexpand\sb{% + \ifnum#3=\z@ \kern -\@tempdima\else \kern -.8\@tempdima \fi + \noexpand\NCC@op@sb}% + \fi + \ifx\NCC@op@sp\relax \else + \noexpand\sp{\ifnum#3=\z@ \kern \@tempdima\fi + \noexpand\NCC@op@sp}% + \fi + \if@tempswa \kern -.2\@tempdima \fi + }% + \@tempa +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\medmath} +% The |\medmath|\marg{formula} prepares a medium-size formula +% in display style: +% \begin{macrocode} +\DeclareRobustCommand*\medmath[1]{\NCC@select@msize + \mathord{\raise\@tempdima\hbox{\NCC@prepare@msize + $\displaystyle#1$}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\medop} +% The |\medop|\marg{operator} prepares an operator in the medium size: +% \begin{macrocode} +\newcommand*\medop[1]{\DOTSB\mathop{\medmath{#1}}\slimits@} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\medintcorr} +% The |\medintcorr|\marg{length} specifies an italic correction +% for a medium integral: +% \begin{macrocode} +\newcommand*\medintcorr[1]{\def\NCC@op@kern{#1}} +\medintcorr{.5em} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\medint} +% The |\medint|\marg{integral} command prepares a medium integral: +% \begin{macrocode} +\newcommand*\medint[1]{\DOTSI\NCC@op@prepare{\medmath{#1}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mfac} +% The |\mfrac|\marg{numerator}\marg{denominator} prepares +% a medium-size fraction: +% \begin{macrocode} +\DeclareRobustCommand*\mfrac[2]{\medmath{\frac{#1}{#2}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\mbinom} +% The |\mbinom|\marg{numerator}\marg{denominator} prepares +% a medium-size binomial expression: +% \begin{macrocode} +\DeclareRobustCommand*\mbinom[2]{% + \Bigl(\medmath{\genfrac{}{}{\z@}{}{#1}{#2}}\Bigr)% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{medsize} +% The |medsize| environment is useful for preparing medium-size arrays: +% \begin{macrocode} +\newenvironment{medsize}{\NCC@select@msize + \mathord\bgroup + \raise\@tempdima\hbox\bgroup\NCC@prepare@msize + \arraycolsep .8\arraycolsep $}{$\egroup\egroup} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{mmatrix} +% The |mmatrix| environment prepares a medium-size matrix: +% \begin{macrocode} +\newenvironment{mmatrix}{\medsize\begin{matrix}}{\end{matrix}\endmedsize} +% \end{macrocode} +% \end{macro} +% +% \subsection{Patches to amsmath} +% +% \begin{macro}{\MultiIntegral} +% Improve the |\MultiIntegral| kerning method on the base of +% |\NCC@op@prepare@| hook. The original method from |amsmath| works +% bad if a multi-integral is an argument of the |\medint| command. +% \begin{macrocode} +\renewcommand*{\MultiIntegral}[1]{% + \edef\NCC@op{\noexpand\intop + \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi + \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi + \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi + \noexpand\intop + }% + \let\NCC@op@print\NCC@op@printd + \NCC@op@prepare@ +} +\def\NCC@op@printd{% + \setlength\@tempdima{\NCC@op@kern}% + \ifx\NCC@op@lim\nolimits \@tempcnta\@ne \else + \ifx\NCC@op@lim\limits \@tempcnta\z@ \else + \@tempcnta\m@ne + \fi + \fi + \mathchoice{\NCC@op@printd@{\displaystyle}{1.2\@tempdima}}% + {\NCC@op@printd@{\textstyle}{.8\@tempdima}}% + {\NCC@op@printd@{\scriptstyle}{.8\@tempdima}}% + {\NCC@op@printd@{\scriptscriptstyle}{.8\@tempdima}}% +} +\def\NCC@op@printd@#1#2{#1% + \ifnum\@tempcnta>\m@ne + \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\@tempcnta + \else + \ifx#1\displaystyle + \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\z@ + \else + \NCC@op@print@{\hbox{$#1\NCC@op$}}{#2}\@ne + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\endmathdisplay@a} +% Fix the bug in the |\endmathdisplay@a| command +% from the |amsmath| package. The |\displaybreak| has no effect in +% it if a tag is specified. This is because the change +% of |\postdisplaypenalty| is done after the |\eqno| command. +% But the rest of display formula after |\eqno| up to the |$$| +% command belongs to the tag. It is prepared in the horizontal mode +% and the mentioned penalty is ignored. Fixed version of +% this command at first changes the |\postdisplaypenalty| and +% after that prints a tag. +% +% To be sure, that the required command does not fixed yet, +% we prepare its bug version in the |\@tempa| command +% \begin{macrocode} +\def\@tempa{% + \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi + \if@fleqn \@xp\endmathdisplay@fleqn + \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi + \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi + \fi + \ifnum\dspbrk@lvl>\m@ne + \postdisplaypenalty -\@getpen\dspbrk@lvl + \global\dspbrk@lvl\m@ne + \fi +} +% \end{macrocode} +% and compare it with the current value of |\endmathdisplay@a|. +% If they are identic, we fix the last command. Otherwise, +% print a warning and do nothing. +% \begin{macrocode} +\ifx\@tempa\endmathdisplay@a + \def\endmathdisplay@a{% + \ifnum\dspbrk@lvl>\m@ne + \postdisplaypenalty -\@getpen\dspbrk@lvl + \global\dspbrk@lvl\m@ne + \fi + \if@eqnsw \gdef\df@tag{\tagform@\theequation}\fi + \if@fleqn \@xp\endmathdisplay@fleqn + \else \ifx\df@tag\@empty \else \veqno \alt@tag \df@tag \fi + \ifx\df@label\@empty \else \@xp\ltx@label\@xp{\df@label}\fi + \fi + } +\else + \PackageWarning{nccmath}% + {The \string\endmathdisplay@a\ command differs from\MessageBreak + waited value in this version of amsmath package.\MessageBreak + We don't fix it!} +\fi +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\intertext} +% Redefine \AmS's |\intertext|\marg{text} to +% |\intertext|\oarg{skip}\marg{text}. Optional \meta{skip} means +% the vertical space inserted below and after the text. If it is +% omitted, the default |\belowdisplayskip| and |\abovedisplayskip| +% spaces are inserted. +% +% We need to redefine its default value used out of display +% equations: +% \begin{macrocode} +\renewcommand*{\intertext}[1][]{\@amsmath@err{\Invalid@@\intertext}\@eha} +% \end{macrocode} +% and also must redefine the |\intertext@| hook that changes the +% value of |\intertext| within display equations. Its new +% definition differs from the original one in the conditional +% inserting of skips before and after the text. +% The optional parameter is scanned inside the |\noalign| +% command. We use the ordinary trick with the |\ifnum0| to +% close the open brace in the next macro. +% \begin{macrocode} +\def\intertext@{% + \def\intertext{% + \ifvmode\else\\\@empty\fi + \noalign{\ifnum0=`}\fi + \@ifnextchar[{\NCC@intertext}{\NCC@intertext[]}% + }% +} +\def\NCC@intertext[#1]#2{% + \penalty\postdisplaypenalty + \@ifempty{#1}{\vskip\belowdisplayskip}{\vskip#1\relax}% + \vbox{\normalbaselines + \ifdim\linewidth=\columnwidth + \else \parshape\@ne \@totalleftmargin \linewidth + \fi + \noindent#2\par}% + \penalty\predisplaypenalty + \@ifempty{#1}{\vskip\abovedisplayskip}{\vskip#1\relax}% + \ifnum0=`{\fi}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\useshortskip} +% The |\useshortskip| command changes an above skip for nearest +% display formula to |\abovedisplayshortskip|. Really, it +% sets the value of inner if-macro to true and the +% actual changes are applied in the |\NCC@ignorepar| hook. +% \begin{macrocode} +\newif\ifNCC@shortskip \NCC@shortskipfalse +\newcommand{\useshortskip}{\global\NCC@shortskiptrue} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@ignorepar} +% This command removes extra vertical space before display formula +% if it starts from a new paragraph and changes the before-skip +% to |\abovedisplayshortskip| if the |\useshortskip| +% command was applied. +% \begin{macrocode} +\def\NCC@ignorepar{\relax + \ifNCC@shortskip + \abovedisplayskip\abovedisplayshortskip + \global\NCC@shortskipfalse + \fi + \ifmmode \else \ifvmode +% \end{macrocode} +% If a display equation starts in the vertical mode, we +% insert the vertical space with the |\addvspace| (this +% space will be ignored at the beginning of minipage) +% and set above display skips to zero. The below display +% skips are made equal. Then we put the |\noindent| +% command that prevents insertion an empty paragraph. +% \begin{macrocode} + \addvspace{\abovedisplayskip}% + \abovedisplayskip\z@skip + \abovedisplayshortskip\z@skip + \belowdisplayshortskip\belowdisplayskip + \noindent + \fi\fi +} +% \end{macrocode} +% \end{macro} +% +% Now we insert the |\NCC@ignorepar| command at the +% beginning of all \LaTeX\ and \AmS-\LaTeX\ display equations +% except |eqnarray|. We need to correct four \AmS\ commands only: +% \begin{macrocode} +\let\NCC@startgather\start@gather +\let\NCC@startalign\start@align +\let\NCC@startmultline\start@multline +\let\NCC@startdisplay\mathdisplay +\def\start@gather{\NCC@ignorepar\NCC@startgather} +\def\start@align{\ifingather@\else\NCC@ignorepar\fi\NCC@startalign} +\def\start@multline{\NCC@ignorepar\NCC@startmultline} +\def\mathdisplay{\NCC@ignorepar\NCC@startdisplay} +% \end{macrocode} +% +% \subsection{The darray Environment} +% +% \begin{macro}{darray} +% The implementation of |darray| is a hybrid of the +% |\start@aligned| command from the |amsmath| package +% and the |\array| command. +% \begin{macrocode} +\newenvironment{darray}[2][c]{% + \null\,% + \if #1t\vtop \else \if#1b \vbox \else \vcenter \fi \fi + \bgroup + \NCC@default@cr + \spread@equation + \NCC@mkpream{#2}% + \edef\@preamble{\ialign \bgroup \strut@ \@preamble \tabskip\z@skip \cr}% + \let\par\@empty \let\@sharp##% + \set@typeset@protect + \tabskip\z@skip + \@preamble +}{% + \crcr\egroup\egroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\dmulticolumn} +% To produce multi-columns in |darray|, the |\dmulticolumn| +% command is used. +% \begin{macrocode} +\newcommand\dmulticolumn[3]{\multispan{#1}% + \begingroup + \NCC@mkpream{#2}% + \def\@sharp{#3}\set@typeset@protect + \@preamble + \endgroup + \ignorespaces +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@mkpream} +% The |darray| environment +% is independent from |array| to avoid conflicts with +% packages customizing the |array| environment. So, +% we need to implement an independent preamble maker. +% +% The following classes can appear in the preamble: +% \begin{quote} +% 0\enskip |lcr|\\ +% 1\enskip |@|-argument\\ +% 2\enskip |@| +% \end{quote} +% The implementation of preamble maker is very similar to the +% \LaTeX's version. +% \begin{macrocode} +\def\NCC@mkpream#1{% + \@lastchclass\@ne \@firstamptrue +% \end{macrocode} +% Specify the default distance between columns in +% the |\alignsep@| register from |amsmath|. +% \begin{macrocode} + \settowidth\alignsep@{$\m@th\mskip\thickmuskip$}% + \let\@sharp\relax + \let\@preamble\@empty +% \end{macrocode} +% The |\@xexpast| command expands the argument replacing +% all instances of\linebreak |*|\marg{N}\marg{string} +% by \meta{N} copies of \meta{string}. The result is saved in +% the |\reserved@a| macro. But this command is let to |\relax| +% in the |array| package. So, we use its original definition prepared +% in the |\NCC@xexpast| macro to avoid conflicts with other +% packages. +% \begin{macrocode} + \let\protect\@unexpandable@protect + \NCC@xexpast #1*0x\@@ +% \end{macrocode} +% Now we make the preamble collecting it in the |\@preamble| hook. +% The code is very similar to the \LaTeX's |\@mkpream| command. +% \begin{macrocode} + \expandafter \@tfor \expandafter \@nextchar + \expandafter :\expandafter =\reserved@a \do + {\@chclass + \ifnum \@lastchclass=\tw@ \@ne \else + \z@ + \edef\@nextchar{\expandafter\string\@nextchar}% + \if \@nextchar @\@chclass \tw@ \else + \@chnum + \if \@nextchar c\z@ \else + \if \@nextchar l\@ne \else + \if \@nextchar r\tw@ \else + \z@ \@preamerr \z@ + \fi + \fi + \fi + \fi + \fi + \ifcase \@chclass + \ifnum \@lastchclass=\z@ \@addtopreamble{\hskip \alignsep@}\fi + \@addamp + \@addtopreamble{% + \ifcase \@chnum \hfil$\displaystyle{\@sharp}$\hfil + \or $\displaystyle{\@sharp}$\hfil + \or \hfil$\displaystyle{\@sharp}$% + \fi + }% + \or + \@addtopreamble{$\@nextchar$}% + \fi + \@lastchclass\@chclass + }% + \ifnum\@lastchclass=\tw@ \@preamerr\@ne \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@xexpast} +% The standard \LaTeX's |\@xexpast| macro is saved here: +% \begin{macrocode} +\def\NCC@xexpast#1*#2#3#4\@@{% + \edef\reserved@a{#1}% + \@tempcnta#2\relax + \ifnum\@tempcnta>\z@ + \@whilenum\@tempcnta>\z@\do + {\edef\reserved@a{\reserved@a#3}\advance\@tempcnta \m@ne}% + \let\reserved@b\NCC@xexpast + \else + \let\reserved@b\NCC@xexnoop + \fi + \expandafter\reserved@b\reserved@a #4\@@ +} +\def\NCC@xexnoop #1\@@{} +% \end{macrocode} +% \end{macro} +% +% \subsection{NCC Equations} +% +% \begin{macro}{fleqn} +% \begin{macro}{ceqn} +% The implementation of these environments is streightforward: +% change the |\if@fleqn| flag and the |\@mathmargin| value: +% \begin{macrocode} +\newenvironment*{fleqn}[1][\z@]{\@fleqntrue + \setlength\@mathmargin{#1}\ignorespaces +}{% + \ignorespacesafterend +} +\newenvironment{ceqn}{\@fleqnfalse + \@mathmargin\@centering \ignorespaces +}{% + \ignorespacesafterend +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\eq} +% The implementation of the NCC-\LaTeX's |\eq| command +% is quite simple: +% \begin{macrocode} +\newcommand{\eq}{\@ifstar{\NCC@eqx}{\NCC@eq}} +\def\NCC@eqx#1{\begin{equation*}#1\end{equation*}} +\def\NCC@eq#1{\begin{equation}#1\end{equation}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\eqalign} +% The |\eqalign| command is based on the |equation| +% and |darray| environments: +% \begin{macrocode} +\newcommand{\eqalign}{% + \@ifstar{\let\@tempa\NCC@eqx \NCC@eqa}% + {\let\@tempa\NCC@eq \NCC@eqa}% +} +\newcommand*{\NCC@eqa}[2][rcl]{% + \@tempa{\begin{darray}{#1}#2\end{darray}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\eqs} +% \begin{macro}{eqnarray} +% The difference between the |\eqs| command and the |eqnarray| +% environment consists in optional length parameters allowed +% in |\eqs|. All these commands are based on |\NCC@beqs| and +% |\NCC@eeqs| macros. +% \begin{macrocode} +\newcommand{\eqs}{\@ifstar{\st@rredtrue\NCC@eqs}{\st@rredfalse \NCC@eqs}} +\newcommand*{\NCC@eqs}[2][]{% + \begingroup\NCC@beqs{#1}#2\NCC@eeqs\endgroup\ignorespaces +} +\renewenvironment{eqnarray}{\st@rredfalse\NCC@beqs{}} + {\NCC@eeqs\ignorespacesafterend} +\renewenvironment{eqnarray*}{\st@rredtrue\NCC@beqs{}} + {\NCC@eeqs\ignorespacesafterend} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@beqs} +% The |\NCC@beqs|\marg{skip} starts eqnarray-like equations. +% The \meta{skip} parameter specifies a skip inserted +% between columns. If it is empty, the default value of this skip +% is used. It equals to the thick skip appearing in relations. +% The implementation of this macro uses hooks from the +% |amsmath| package. +% \begin{macrocode} +\def\NCC@beqs#1{% + \NCC@ignorepar$$ + \inalign@true \intertext@ \displ@y@ \Let@ + \chardef\dspbrk@context\z@ + \let\math@cr@@@\NCC@eqcr \let\tag\tag@in@align + \let\label\label@in@display \let\split\insplit@ + \ifst@rred\else \global\@eqnswtrue \fi + \tabskip\@mathmargin + \@ifempty{#1}{\settowidth\alignsep@{$\m@th\mskip\thickmuskip$}}% + {\setlength\alignsep@{#1}}% + \halign to \displaywidth\bgroup + \strut@ \global\column@\z@ \hfil$\displaystyle{##}$\tabskip\z@skip + &\column@plus \hskip\alignsep@ \hfil$\displaystyle{##}$\hfil + &\column@plus \hskip\alignsep@ $\displaystyle{##{}}$\hfil + \tabskip\@centering + &\column@plus \llap{##}\tabskip\z@skip\cr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@eqcr} +% The |\NCC@eqcr| hook is called at the end of line of the +% |eqnarray|. It is originated on \LaTeX's |\@eqncr| command, but +% uses commands from |amsmath| to prepare a tag in the \AmS\ style. +% \begin{macrocode} +\def\NCC@eqcr{% + \let\@tempa\relax + \ifcase\column@ \def\@tempa{&&&}\or \def\@tempa{&&}\or\def\@tempa{&}% + \else + \let\@tempa\@empty + \@latex@error{Too many columns in eqnarray environment}\@ehc + \fi + \@tempa + \ifst@rred\nonumber\fi + \if@eqnsw \global\tag@true \fi + \iftag@ \@lign\strut@ + \iftagsleft@ \rlap{\hskip -\displaywidth\make@display@tag}% + \else \make@display@tag \fi + \fi + \ifst@rred\else\global\@eqnswtrue\fi + \cr +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@eeqs} +% This macro finishes eqnarray-like equations. +% \begin{macrocode} +\def\NCC@eeqs{\math@cr\egroup$$} +% \end{macrocode} +% \end{macro} +% +% \subsection{Math with medium fractions and operators} +% +% Finally, we process the |mediummath| option. It is recognized by +% the |\NCC@op| command to be specified. +% \begin{macrocode} +\@ifundefined{NCC@op}{\endinput}{} +% \end{macrocode} +% +% Redifine fractions and binoms. +% \begin{macrocode} +\DeclareRobustCommand\frac{\NCC@op@select\mfrac{\genfrac{}{}{}{}}} +\DeclareRobustCommand\binom{\NCC@op@select\mbinom{\genfrac()\z@{}}} +\def\NCC@op@select#1#2#3#4{% + \mathchoice{#1{#3}{#4}}{#1{#3}{#4}}% + {\scriptstyle#2{#3}{#4}}{\scriptscriptstyle#2{#3}{#4}}% +} +% \end{macrocode} +% +% Redefine all math operators except integrals: +% \begin{macrocode} +\def\@tempa#1#2{% + \ifx#2\@undefined \let#2#1\fi + \def#1{\DOTSB\medop{#2}}% +} +\@tempa \coprod \coprod@ +\@tempa \bigvee \bigvee@ +\@tempa \bigwedge \bigwedge@ +\@tempa \biguplus \biguplus@ +\@tempa \bigcap \bigcap@ +\@tempa \bigcup \bigcup@ +\@tempa \prod \prod@ +\@tempa \sum \sum@ +\@tempa \bigotimes \bigotimes@ +\@tempa \bigoplus \bigoplus@ +\@tempa \bigodot \bigodot@ +\@tempa \bigsqcup \bigsqcup@ +% \end{macrocode} +% +% Redefine integrals: +% \begin{macrocode} +\def\@tempa#1#2#3{\let#3#2% + \DeclareRobustCommand#2{\mathop{\medmath{#3}}}% + \def#1{\DOTSI\NCC@op@prepare{#2}}% +} +\@tempa\int \intop \NCC@op@int +\@tempa\oint \ointop \NCC@op@oint +\let\@tempa\relax +% \end{macrocode} +% +% Redefine multiple integrals: +% \begin{macrocode} +\renewcommand*{\MultiIntegral}[1]{% + \edef\NCC@op{\noexpand\intop + \ifnum#1=\z@\noexpand\intdots@\else\noexpand\intkern@\fi + \ifnum#1>\tw@\noexpand\intop\noexpand\intkern@\fi + \ifnum#1>\thr@@\noexpand\intop\noexpand\intkern@\fi + \noexpand\intop + }% + \let\NCC@op@print\NCC@op@printm + \NCC@op@prepare@ +} +\def\intkern@{\kern-\NCC@op@kern} +\def\intdots@{\setlength\@tempdima{\NCC@op@kern}% + \kern-.4\@tempdima{\cdotp}\mkern1.5mu{\cdotp}% + \mkern1.5mu{\cdotp}\kern-.4\@tempdima} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccparskip.dtx b/macros/latex/contrib/ncctools/source/nccparskip.dtx new file mode 100644 index 0000000000..dc340ce731 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccparskip.dtx @@ -0,0 +1,85 @@ +% \iffalse +%% +%% File: nccparskip.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccparskip} +% [2004/12/08 v1.1 Parskip Control Package (NCC)] +% +% \changes{v1.01}{2002/01/09}{This version is uploaded to CTAN} +% \changes{v1.02}{2002/02/07}{The package is renamed to nccparskip} +% \changes{v1.1}{2004/12/08}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccparskip} +\SetParskip{6pt plus 1pt minus .4pt} +\GetFileInfo{nccparskip.sty} +\begin{document} +\title{The \textsf{nccparskip} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccparskip.dtx} +\end{document} +% +% \fi +% +% \DescribeMacro{\SetParskip} +% The package provides identical distance between all paragraphs except +% section markups. It redefines control list commands and suppress +% |\topskip|, |\partopskip|, and |\itemsep| in lists. As a result, the distance +% between ordinary paragraphs and paragraphs prepared by lists is the same. +% The command |\SetParskip|\marg{distance} controls this distance. +% The default distance is +% \begin{quote} +% |\SetParskip{4pt plus 1pt minus .2pt}| +% \end{quote} +% In this document, we use |\SetParskip{6pt plus 1pt minus .4pt}|. +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\SetParskip} +% Define the command and set list skips to zero length. +% \begin{macrocode} +%<*package> +\newcommand*{\SetParskip}[1]{\setlength{\parskip}{#1}\parsep\parskip} +\partopsep\z@ +\topsep\z@ +\itemsep\z@ +% \end{macrocode} +% \end{macro} +% +% We suppose that list definitions were done in the similar way as +% in standard \LaTeX\ classes. Redefine list control commands: +% \begin{macrocode} +\def\@listi{\leftmargin\leftmargini} +\let\@listI\@listi +\def\@listii{\leftmargin\leftmarginii + \labelwidth\leftmarginii \advance\labelwidth-\labelsep} +\def\@listiii{\leftmargin\leftmarginiii + \labelwidth\leftmarginiii \advance\labelwidth-\labelsep} +% \end{macrocode} +% +% Redefine the |\normalsize|, |\small|, and |\footnotesize| +% commands to avoid the |\@listi| redefinition in them. +% \begin{macrocode} +\let\NCC@normalsize\normalsize +\def\normalsize{\let\NCC@temp\@listi\NCC@normalsize\let\@listi\NCC@temp} +\let\NCC@small\small +\def\small{\let\NCC@temp\@listi\NCC@small\let\@listi\NCC@temp} +\let\NCC@footnotesize\footnotesize +\def\footnotesize{\let\NCC@temp\@listi\NCC@footnotesize\let\@listi\NCC@temp} +% \end{macrocode} +% +% Finally we set defaults: +% \begin{macrocode} +\normalsize +\SetParskip{4pt plus 1pt minus .2pt} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccpic.dtx b/macros/latex/contrib/ncctools/source/nccpic.dtx new file mode 100644 index 0000000000..0fd12072fc --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccpic.dtx @@ -0,0 +1,254 @@ +% \iffalse +%% +%% File: nccpic.dtx Copyright (C) 2002--2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e}[1995/12/01] +%\ProvidesPackage{nccpic} +% [2005/03/06 v1.2 NCC Extention of Graphicx (NCC)] +% +% \changes{v1.01}{2002/01/23}{This version is uploaded to CTAN} +% \changes{v1.02}{2002/02/17}{All options are passed to graphicx} +% \changes{v1.03}{2002/03/20}{|\draftgraphics| and |\finalgraphics| introduced} +% \changes{v1.04}{2004/09/04}{Patch for bounding box calculation} +% \changes{v1.1}{2004/12/09}{Documentation was prepared} +% \changes{v1.2}{2005/03/06}{Correct extension lists} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccpic,desclist} +\GetFileInfo{nccpic.sty} +\begin{document} +\title{The \textsf{nccpic} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccpic.dtx} +\end{document} +% +% \fi +% +% \section{User Interface} +% +% The package is considered as an extension of the |graphicx| package. +% It passes all options to the |graphicx| and customizes graphics +% extensions list for most popular drivers, namely |dvips| and |dvidpf|. +% +% This allows us omit an extension of a graphics file in the +% |\includegraphics| command. When a file without extension is searched, +% this command sequentially tries extensions from the list of extensions +% until an appropriate file will be found. +% +% Using this feature, you can support multiple output from a \LaTeX\ +% document with minimum changes in |.tex| sources. The only required +% thing is to prepare a number of versions for all graphics files +% used in the document. For example, the |dvips| program and YAP previewer +% like |.eps| and |.bmp| files, and the |pdftex| likes |.png| files. To +% satisfy their needs, you can prepare the |.eps| or |.bmp| version +% of all pictures for use with dvips and the |.png| version for use with +% |pdftex|. Then, when you translate your source file with the |latex| +% command, the |.eps| or |.bmp| versions of graphics files are used. +% But when you translate your source file with the |pdflatex| command, +% the |.png| versions of graphics files are used. +% +% The next aim of this package is the regulation of +% placement of graphics files in the file system. It is the bad idea +% to place graphics together with \LaTeX\ sources, especially when +% your prepare a book containing many pictures. It will be much better +% if graphics will be stored in a subdirectory relative to the +% base directory of your \LaTeX\ sources. +% We propose to store graphics files in the +% |graphics| subdirectory of the source directory. To support +% the search in this storage, the graphics path is customized in +% this package. +% +% \DescribeMacro\ipic +% The graphics in \LaTeX\ can be prepared at least in two ways: +% as an external graphics file included with the |\includegraphics| +% command or its analogue; as a \LaTeX\ |picture| environment +% or its analogues provided with special graphics packages. +% In the last case, the placing a picture inside a \LaTeX\ source +% file is inconvenient. It will be better to put a \LaTeX\ picture +% in a separate file and include it using the |\input| command. +% The next step is to place such pictures together with other +% graphics material into the |graphics| subdirectory and load them using +% the |\ipic|\marg{filename} command. This command appends +% the \meta{filename} with the |.pic| extension and tries to load +% the `\meta{filename}|.pic|' file at first from the base directory +% of your document and then from the |graphics| subdirectory. +% +% \DescribeMacro\draftgraphics +% \DescribeMacro\finalgraphics +% The |\draftgraphics| and |\finalgraphics| commands respectively +% set the draft and final modes for graphics inclusion with the +% |\includegraphics| command. They are analogues for the |draft| +% and |final| options of the |graphics| package. But the commands +% allow more flexible control of graphics mode especially for +% document classes including this package by default (the |ncc| +% class from NCC-\LaTeX\ does this). +% A graphics file included in the draft +% mode is shown as a rectangle containing the name of graphics file. +% This is quite useful on the stage of editing a document. +% +% \DescribeMacro\putimage +% The following command includes a graphics file using the +% |\includegraphics| command. It is provided for compatibility with +% old NCC-\LaTeX: +% \begin{quote} +% |\putimage(|$x$|,|$y$|)[|$x_{\rm real}$|,|$y_{\rm real}$|](|$x_{\rm shift}$|,|$y_{\rm shift}$|)|\marg{filename} +% \end{quote} +% Here: +% \begin{desclist}{}{\hfill}[\tt($x_{\rm shift}$,$y_{\rm shift}$)] +% \item[\meta{filename}] is a name of graphics file; +% +% \item[\tt($x$,$y$)] are dimensions (in |\unitlength|) of the prepared image box; +% +% \item[\tt{[$x_{\rm real}$,$y_{\rm real}$]}] are dimensions (in |\unitlength|) +% of graphics file that are passed to the |\includegraphics| command; +% +% \item[\tt($x_{\rm shift}$,$y_{\rm shift}$)] are shifts (in |\unitlength|) +% of the graphics image with respect to the image box. +% \end{desclist} +% The |(|$x$|,|$y$|)| and \meta{filename} parameters are required. Others +% are optional. If the |[|$x_{\rm real}$|,|$y_{\rm real}$|]| parameter is +% omitted, $x_{\rm real}:=x$ and $y_{\rm real}:=y$. If the +% |(|$x_{\rm shift}$|,|$y_{\rm shift}$|)| parameter is omitted, the shift values +% are set to zero. +% +% The |\putimage| command vertically aligns the image box in the different +% way than the |\includegraphics|. The first one lowers the box in such a way +% to align its top edge with the top edge of letter `A' of the current font. +% But the last one aligns the bottom edge of graphics on the baseline. +% +% Other distinction between these commands consists in their work in the +% draft mode. The |\putimage| command does not test a required graphics +% file on existence and puts the filename at the center of bounding +% rectangle. But the |\includegraphics| searches the graphics file +% and puts the filename at the left top corner of bounding rectangle. +% +% In version 1.04 of this package, we add a patch to the |graphics| package. +% The reason of this patch is the following. +% In latest versions of the MiKTeX, graphics rules +% are specified for many graphics formats. As a result, if a bounding +% box is not specified in parameters of the |\includegraphics| command, +% a file with |.bb| extension is tested on the ps-like bounding box +% specification. If such file does not exist, the |\includegraphics| command +% fails even if its parameters exactly specify the graphics width and height. +% We have changed the unconditional testing of the bounding box +% to the conditional one: testing is applied if the required file exists, +% otherwise, this operation is ignored. +% \StopEventually{} +% +% \section{The Implementation} +% +% Load required packages. We use some features of the |nccboxes| package +% in the |\putimage| command: the |\Strut| and |\jvbox| commands. +% \begin{macrocode} +%<*package> +\RequirePackageWithOptions{graphicx}[1999/02/16] +\RequirePackage{nccboxes}[2002/01/09] +% \end{macrocode} +% +% Customize extension lists for |dvips| and |dvipdf|% drivers. +% \begin{macrocode} +\def\@tempa{dvips.def} +\ifx\Gin@driver\@tempa + \DeclareGraphicsExtensions{.eps,.ps,.eps.gz,.ps.gz,.eps.Z,% + .bmp,.msp,.pcx,.pict,.pntg} +\else + \def\@tempa{dvipdf.def} + \ifx\Gin@driver\@tempa + \DeclareGraphicsExtensions{.eps,.ps,.eps.gz,.ps.gz,.eps.Z,% + .bmp,.msp,.jpg} + \fi +\fi +% \end{macrocode} +% +% Set the path list for search graphics files. It is not necessary to +% set the base directory in the list, because it is always searched +% first and the search in the graphics path list is applied only if +% the search in the base directory fails. +% \begin{macrocode} +\graphicspath{{graphics/}} +% \end{macrocode} +% +% \begin{macro}{\draftgraphics} +% \begin{macro}{\finalgraphics} +% Specify graphics mode control commands: +% \begin{macrocode} +\newcommand\draftgraphics{\Gin@drafttrue} +\newcommand\finalgraphics{\Gin@draftfalse} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\ipic} +% The |\ipic|\marg{filename} command is equivalent to +% |\input{|\meta{filename}|.pic}| command with search in +% the directory list specified by the |\graphicspath|. +% The file is opened within a group and the beginning and +% final spaces are removed in it. +% \begin{macrocode} +\newcommand*{\ipic}[1]{% + \begingroup \let\input@path\Ginput@path + \ignorespaces\input{#1.pic}\unskip + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\putimage} +% Introduce the |\putimage| command. Using the empty definition +% we ensure the command was undefined before. +% \begin{macrocode} +\newcommand{\putimage}{} +\def\putimage(#1,#2){% + \@ifnextchar[{\NCC@Gim(#1,#2)}{\NCC@Gim(#1,#2)[#1,#2]}% +} +\def\NCC@Gim(#1,#2)[#3,#4]{% + \ifGin@draft + \def\NCC@temp(##1,##2)##3{% + \edef\@tempa{##3}% + \put(0,0){% + \framebox(#1,#2){\ttfamily\expandafter\strip@prefix\meaning\@tempa}% + }% + }% + \else + \def\NCC@temp(##1,##2)##3{% + \put(##1,##2){% + \includegraphics[width=#3\unitlength,height=#4\unitlength]{##3}% + }% + }% + \fi + \@ifnextchar({\NCC@Gim@(#1,#2)}{\NCC@Gim@(#1,#2)(0,0)}% +} +\def\NCC@Gim@(#1,#2)(#3,#4)#5{% + \jvbox{\Strut}[t]{% + \begin{picture}(#1,#2)\NCC@temp(#3,#4){#5}\end{picture}% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\Gin@setfile} +% The patch to the |\Gin@setfile| command slightly +% changes its behaviour: if bounding box calculations are +% required and the corresponding graphics rule contains an extension +% of file for reading the bounding box info, we skip the reading +% of given file if it does not exist. +% \begin{macrocode} +\let\NCC@Ginsetfile\Gin@setfile +\def\Gin@setfile#1#2{% + \ifGin@bbox\else + \ifx\\#2\\\else + \IfFileExists{\Gin@base#2}{}{\Gread@false}% + \fi + \fi + \NCC@Ginsetfile{#1}{#2}% +} +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccrules.dtx b/macros/latex/contrib/ncctools/source/nccrules.dtx new file mode 100644 index 0000000000..0542215c43 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccrules.dtx @@ -0,0 +1,400 @@ +% \iffalse +%% +%% File: nccrules.dtx Copyright (C) 2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccrules} +% [2005/05/13 v1.0 More rules (NCC)] +% +% \changes{v1.0}{2005/05/13}{This version was uploaded to CTAN} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccrules} +\newfootnoterule{starred}{\mboxfill[1.5\width][s]{$*$}} +\newfootnoterule{dotted}{\mboxfill[2\width][s]{.}} +\newfootnotedashrule{double}{}{.4 1 .4} +\newfootnotedashrule{dashed}{3 3}{.4} +\newfootnotedashrule{dotdashed}{4 2 1 2 4 -4}{.6} +\newfootnotedashrule{ddotdashed}{6 2 1 2 1 2 6 -6}{.6} +\GetFileInfo{nccrules.sty} +\begin{document} +\title{The \textsf{nccrules} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccrules.dtx} +\end{document} +% +% \fi +% This package implements +% |\dashrule| and |\dashrulefill| commands, +% that simplify composing of dashed +% lines and dashed multilines. Two kinds of footnote rule generation +% commands are also introduced: |\newfootnoterule| creates a footnote +% rule with an arbitrary contents and |\newfootnotedashrule| creates +% a footnote rule based on dash rule. +% +% \tableofcontents +% +% \section{User Interface} +% +% \subsection{Dash Rules} +% +% \DescribeMacro\dashrule +% The command +% \begin{quote} +% |\dashrule|\oarg{raise}\marg{h-pattern}\marg{v-pattern} +% \end{quote} +% prepares a dash rule. Its syntax is quite similar to the |\rule| command +% except that \meta{h-pattern} and \meta{v-pattern} can contain a list of +% sizes delimited with spaces. List sizes are interpreted as follows: +% size, space, size, space, etc. In other words, every odd size is a +% size of rule part and every even size is a space between neighbour parts. +% If the last size in the list is even +% (means a space), its space value is divided by two and +% is added before the first rule part and after the last rule part. +% Units in sizes can be omitted. In this case, pt-units are supposed. +% Examples: +% \begin{center} +% \begin{tabular}{@{}l@{\qquad\qquad}l@{}} +% x\dashrule[.5ex]{10mm}{1pt}x & +% |x\dashrule[.5ex]{10mm}{1pt}x| \\ +% x\dashrule{5mm 3 3 3 5mm}{.4}x & +% |x\dashrule{5mm 3 3 3 5mm}{.4}x| \\ +% x\dashrule{1}{3 2 3}x& +% |x\dashrule{1}{3 2 3}x|\\ +% x\dashrule{2 2}{2 2}x & +% |x\dashrule{2 2}{2 2}x|\\ +% x\dashrule{5 3 1 3 5 10}{1 1 0.4 1 1}x & +% |x\dashrule{5 3 1 3 5 10}{1 1 0.4 1 1}x| +% \end{tabular} +% \end{center} +% +% \DescribeMacro\dashrulefill +% The command +% \begin{quote} +% |\dashrulefill|\oarg{raise}\oarg{leader-type}\marg{h-pattern}\marg{v-pattern} +% \end{quote} +% fills a free space with a dash rule. The rule is composed from the 1st, +% 3rd, and 4th arguments of the command and is repeated as more times as +% necessary to fill a free horizontal space. The rest of space after filling is +% stored depending on \meta{leader-type} used. Default leader type +% is ``aligned leaders'': every rule is aligned to the multiple of its width +% counted from the left boundary of filled box. Other cases are: |c| means +% centered leaders (all extra spaces are collected at both ends of fill +% area), |x| means distributed leaders (extra spaces are uniformly +% distributed between every dash rule), and |s| means stretched leaders +% (the space in h-pattern going after the last rule size is considered as +% stretchable space and rules are stretched to the whole width of the +% fill area). +% +% Example: +% \begin{flushleft} +% |\noindent x\dashrulefill{2 2}{2}\mbox{}\\|\\ +% |xxxxx\dashrulefill[.4ex]{2 2}{2}\mbox{}\\|\\ +% |\mbox{}\dashrulefill[.4ex]{4 4}{2}\mbox{}\\|\\ +% |\mbox{}\dashrulefill[.4ex][c]{4 4}{2}\mbox{}\\|\\ +% |\mbox{}\dashrulefill[.4ex][x]{4 4}{2}\mbox{}\\|\\ +% |\mbox{}\dashrulefill[.4ex][s]{4 4}{2}\mbox{}\\|\\ +% |\mbox{}\dashrulefill[.4ex][s]{4 2 1 2 4 -4}{1}\mbox{}\\[1ex]|\\ +% |\mbox{}\dashrulefill[0mm][c]{2 3}{2 3 2 3 2}\mbox{}\\|\\ +% |\mbox{}\dashrulefill{5 3 1 3 5}{1 1 0.4 1 1}\mbox{}\\|\\ +% |\mbox{}\dashrulefill[0mm][c]{5 3 1 3 5}{1 1 0.4 1 1}\mbox{}\\[-2ex]|\\ +% |\mbox{}\hrulefill| +% \end{flushleft} +% +% It produces the following: +% +% \noindent x\dashrulefill{2 2}{2}\mbox{}\\ +% xxxxx\dashrulefill[.4ex]{2 2}{2}\mbox{}\\ +% \mbox{}\dashrulefill[.4ex]{4 4}{2}\mbox{}\\ +% \mbox{}\dashrulefill[.4ex][c]{4 4}{2}\mbox{}\\ +% \mbox{}\dashrulefill[.4ex][x]{4 4}{2}\mbox{}\\ +% \mbox{}\dashrulefill[.4ex][s]{4 4}{2}\mbox{}\\ +% \mbox{}\dashrulefill[.4ex][s]{4 2 1 2 4 -4}{1}\mbox{}\\[1ex] +% \mbox{}\dashrulefill[0mm][c]{2 3}{2 3 2 3 2}\mbox{}\\ +% \mbox{}\dashrulefill{5 3 1 3 5}{1 1 0.4 1 1}\mbox{}\\ +% \mbox{}\dashrulefill[0mm][c]{5 3 1 3 5}{1 1 0.4 1 1}\mbox{}\\[-2ex] +% \mbox{}\hrulefill +% +% \subsection{Custom Footnote Rules} +% +% In |manyfoot| package, you can separate footnote levels +% with custom footnote rules. In this package we provide two ways for +% creation such rules. All footnote rules should follow the following +% contract: they must be prepared as |\hrule| or |\hbox|; the total height +% of rule or box must be compensated with kerns. Usually a negative +% kern is inserted before a footnote rule and a nonnegative kern is +% inserted after the rule. The sum of both kerns and of total height of +% rule must be equal to zero. We follow this contract in footnote rules +% created with this package. +% +% In |manyfoot| package, every footnote rule must have a name +% |\|\meta{prefix}|footnoterule|. So, we need to specify the prefix only +% when a new footnote rule is constructed. Next that we need to specify is +% a rule width. If width is omitted, the default width of |0.4\columnwidth| +% is used. The footnote rule generation commands described below +% are used in the preamble only. +% +% \DescribeMacro\newfootnoterule +% The command +% \begin{quote} +% |\newfootnoterule|\marg{prefix}\oarg{width}\marg{rule code} +% \end{quote} +% produces a custom user-defined rule. +% The \meta{rule code} must be stretchable to the given width. +% The |\mboxfill| command from the |mboxfill| package is useful in it. +% Examples: +% \begin{quote} +% |\newfootnoterule{starred}{\mboxfill[1.5\width][s]{$*$}}|\\ +% |\newfootnoterule{dotted}{\mboxfill[2\width][s]{.}}| +% \end{quote} +% The |\starredfootnoterule| and |\dottedfootnoterule| commands +% are created here. They produce the following rules: +% +% \vspace{3mm} +% \starredfootnoterule +% \dottedfootnoterule +% +% \DescribeMacro\newfootnotedashrule +% The command +% \begin{quote} +% |\newfootnotedashrule|\marg{prefix}\oarg{width}\marg{h-pattern}\marg{v-pattern} +% \end{quote} +% produces a dash footnote rule. The special case, when \meta{h-pattern} +% is empty means the solid rule. Examples: +% \begin{quote} +% |\newfootnotedashrule{double}{}{.4 1 .4}|\\ +% |\newfootnotedashrule{dashed}{3 3}{.4}|\\ +% |\newfootnotedashrule{dotdashed}{4 2 1 2 4 -4}{.6}|\\ +% |\newfootnotedashrule{ddotdashed}{6 2 1 2 1 2 6 -6}{.6}| +% \end{quote} +% The following rules are created here: +% |\doublefootnoterule|, |\dashedfootnoterule|, +% |\dotdashedfootnoterule|, and |\ddotdashedfootnoterule|. +% They produce the following rules: +% +% \vspace{2mm}% +% \doublefootnoterule +% \dashedfootnoterule +% \dotdashedfootnoterule +% \ddotdashedfootnoterule +% +% \StopEventually{} +% +% \section{The Implementation} +% +% The |mboxfill| package is required here: +% \begin{macrocode} +%<*package> +\RequirePackage{mboxfill} +% \end{macrocode} +% +% \begin{macro}{\dashrule} +% |\dashrule|\oarg{raise}\marg{h-pattern}\marg{v-pattern} +% \begin{macrocode} +\newcommand\dashrule{} +\DeclareRobustCommand*\dashrule[3][\z@]{% + \setbox\@tempboxa\vbox{}% + \NCC@composedash{\NCC@vdash{#2}}{#3}% + \setlength\@tempdima{#1}\leavevmode + \raise\@tempdima\hbox{% + \vbox to\@tempdimc{\vss\unvbox\@tempboxa\vss}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\dashrulefill} +% |\dashrulefill|\oarg{raise}\oarg{leader-type}\marg{h-pattern}\marg{v-pattern}\\ +% This command is a composition of the |\mboxfill| and +% |\dashrule| commands. A trick is applied here: +% we decrease dash rule width on the value of last space +% in it and then apply |\mboxfill|. +% \begin{macrocode} +\newcommand*\dashrulefill[1][\z@]{% + \@ifnextchar[{\NCC@dashfill{#1}}{\NCC@dashfill{#1}[]}% +} +\def\NCC@dashfill#1[#2]#3#4{% + \NCC@composedash{}{#3}% + \advance\@tempdimb-\@tempdimc + \setbox\@tempboxa\hb@xt@-\@tempdimb + {\hss\dashrule[#1]{#3}{#4}\hss}% + \mboxfill[\@tempdimc][#2]{\box\@tempboxa}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@composedash} +% |\NCC@composedash|\marg{action}\marg{pattern} parses the pattern +% and calls the action when a rule size is parsed. At this point, +% the |\@tempdima| contains a size parsed and |\@tempdimb| contains +% the previous space. In |\@tempdimc|, the whole rule size is calculated. +% \begin{macrocode} +\def\NCC@composedash#1#2{% + \@tempdimb\z@ % Last space + \@tempdimc\z@ % Accumulator + \@tempswatrue % True value means producing an entry + \NCC@parsedash#2 ! !\@nil{% + \advance\@tempdimc\@tempdima + \if@tempswa #1\@tempswafalse \else + \@tempdimb\@tempdima \@tempswatrue + \fi + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@parsedash} +% Pattern parser: +% \begin{macrocode} +\def\NCC@parsedash#1 #2\@nil#3{% + \if/#1/\else % Empty arg. ignored + \ifx#1!\else % Exclamation mark ends the list + \@defaultunits\@tempdima#1pt\relax\@nnil + #3\NCC@parsedash#2\@nil{#3}% + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@vdash} +% |\NCC@vdash|\marg{h-pattern} is +% applied when a vertical dash is composed. +% |\@tempdimb| contains the required skip, +% |\@tempdima| contains the rule height. +% \begin{macrocode} +\def\NCC@vdash#1{% + \setbox\@tempboxa\vbox{% + \unvbox\@tempboxa \vskip\@tempdimb + \setbox\@tempboxa\hbox{}% + \@tempskipa\@tempdima % Save rule height in \@tempskipa + \NCC@composedash{\NCC@hdash}{#1}% + \hb@xt@\@tempdimc{\hss\unhbox\@tempboxa\hss}% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@hdash} +% This action is applied when a horizontal dash is composed. +% |\@tempdimb| contains the required skip, +% |\@tempdima| contains the rule width, +% |\@tempskipa| contains the rule height. +% \begin{macrocode} +\def\NCC@hdash{% + \setbox\@tempboxa\hbox{% + \unhbox\@tempboxa \kern\@tempdimb + \vrule \@width\@tempdima \@height\@tempskipa + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fnoterule} +% |\NCC@fnoterule|\marg{width}\marg{rule code}\\ +% This is the footnote rule producing command. +% As usual, two kerns must be inserted surround the rule: a negative +% kern before the rule and a nonnegative kern after the rule. +% The sum of kern values and of the total rule height must +% vanish. Kerns are calculated in such a way to vertically center +% the rule relative to 2.8pt distance top to the current position. +% If the total height of rule is greater than 5.6pt, the rule is moved +% up on the total rule height (the kern after the rule is zero in this case). +% \begin{macrocode} +\def\NCC@fnoterule#1#2{% + \setlength\@tempdima{#1}% + \setbox\@tempboxa\hb@xt@\@tempdima{#2}% + \@tempdima\ht\@tempboxa \advance\@tempdima\dp\@tempboxa + \@tempdimb 2.8\p@ \@tempdimc .5\@tempdima + \ifdim\@tempdimc>\@tempdimb \@tempdimb\@tempdimc \fi + \advance\@tempdimb\@tempdimc + \kern-\@tempdimb + \box\@tempboxa + \advance\@tempdimb -\@tempdima + \kern\@tempdimb +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fnotedashrule} +% |\NCC@fnotedashrule|\marg{width}\marg{h-pattern}\marg{v-pattern}\\ +% Produces the rule based on |\dashrulefill|. A special case of empty +% \meta{h-pattern} means the solid (maybe multi-line) rule. +% \begin{macrocode} +\def\NCC@fnotedashrule#1#2#3{% + \NCC@fnoterule{#1}{\def\@tempa{#2}% + \ifx\@tempa\@empty + \@tempskipb\@tempdima \dashrule{\@tempskipb}{#3}% + \else + \dashrulefill[\z@][s]{#2}{#3}% + \fi + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fnotecreate} +% |\NCC@fnotecreate|\marg{prefix}\marg{body}\\ +% Creates a footnote rule whose name is composed from the +% given \meta{prefix} and |footnoterule|. For example if the prefix +% is |dashed|, the |\dashedfootnoterule| command will be created. +% \begin{macrocode} +\def\NCC@fnotecreate#1{% + \edef\@tempa{\noexpand\newcommand*% + \expandafter\noexpand\csname #1footnoterule\endcsname}% + \@tempa +} +\@onlypreamble\NCC@fnotecreate +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@fnoteprepare} +% |\NCC@fnoteprepare|\marg{driver}\marg{prefix}\oarg{width}\\ +% Prepares a footnote rule command. The \meta{driver} is a command +% that will be called for collecting rule code (it gets more arguments +% from the input). When a driver prepares the code, it calls the +% |\NCC@fnotecreate| command. If \meta{width} is omitted, the standard +% width of |0.4\columnwidth| is used. +% \begin{macrocode} +\def\NCC@fnoteprepare#1#2{% + \@ifnextchar[{#1{#2}}{#1{#2}[.4\columnwidth]}% +} +\@onlypreamble\NCC@fnoteprepare +% \end{macrocode} +% \end{macro} +% +% Footnote rule creation driver has the following syntax: +% \begin{quote} +% |\|\meta{driver}\marg{prefix}\oarg{width}\meta{more arguments} +% \end{quote} +% +% \begin{macro}{\newfootnoterule} +% |\newfootnoterule|\marg{prefix}\oarg{width}\marg{rule code} +% \begin{macrocode} +\newcommand\newfootnoterule{\NCC@fnoteprepare\NCC@fnotedriver} +\def\NCC@fnotedriver#1[#2]#3{% + \NCC@fnotecreate{#1}{\NCC@fnoterule{#2}{#3}}% +} +\@onlypreamble\newfootnoterule +\@onlypreamble\NCC@fnotedriver +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\newfootnotedashrule} +% |\newfootnotedashrule|\marg{prefix}\oarg{width}\marg{h-pattern}\marg{v-pattern} +% \begin{macrocode} +\newcommand\newfootnotedashrule{\NCC@fnoteprepare\NCC@fnotedashdriver} +\def\NCC@fnotedashdriver#1[#2]#3#4{% + \NCC@fnotecreate{#1}{\NCC@fnotedashrule{#2}{#3}{#4}}% +} +\@onlypreamble\newfootnotedashrule +\@onlypreamble\NCC@fnotedashdriver +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccsect.dtx b/macros/latex/contrib/ncctools/source/nccsect.dtx new file mode 100644 index 0000000000..f1521679e7 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccsect.dtx @@ -0,0 +1,3036 @@ +% \iffalse +%% +%% File: nccsect.dtx Copyright (C) 2002--2006 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccsect} +% [2006/01/20 v1.6 Extended Section, Caption, and TOC Handling (NCC)] +% +% \changes{v1.00}{2002/02/01}{This version is uploaded to CTAN} +% \changes{v1.01}{2002/02/08}{\NCC@thetocchapter hook added} +% \changes{v1.02}{2002/02/13}{Bug in using the \nosectiontag fixed} +% \changes{v1.02}{2002/03/19}{Test for caption with empty text added} +% \changes{v1.03}{2002/05/19}{Vskips in captions after style changes now} +% \changes{v1.04}{2002/05/22}{Centering in captions now works} +% \changes{v1.1}{2004/12/12}{Introduce |\NCC@sec@reset@controls|} +% \changes{v1.1}{2004/12/12}{Simplify making sections. The |\NCC@makesection| now +% incompatible with previous version!!!} +% \changes{v1.1}{2004/12/12}{Revised version: many internal changes} +% \changes{v1.1}{2004/12/12}{Documentation was prepared} +% \changes{v1.2}{2005/04/15}{Emulate |\@makecaption| for compatibility} +% \changes{v1.2}{2005/04/15}{Compatibility with the supertabular package added} +% \changes{v1.2}{2005/04/15}{Compatibility with the longtable package added} +% \changes{v1.2}{2005/05/20}{Introduce |\beforechapter| hook} +% \changes{v1.2}{2005/05/20}{Add |\StartFromTextArea| and |\StartFromHeaderArea|} +% \changes{v1.2}{2005/05/21}{Add |\epigraph| and |\epigraphparameters|} +% \changes{v1.2}{2005/05/22}{Add |\captionstyle| and related staff} +% \changes{v1.2}{2005/05/22}{Add |\TOCMarginDrift|} +% \changes{v1.2}{2005/05/22}{Add |\applystyle| command to TOC Entry style} +% \changes{v1.2}{2005/06/08}{Set |\@twocolumnfalse| in before-chapter hook} +% \changes{v1.2}{2005/06/08}{Allow sectioning in |\beforechapter| hook} +% \changes{v1.3}{2005/06/15}{Fixed bug with using |\applystyle| command} +% \changes{v1.4}{2005/12/26}{Conditionally define |\StartFromTextArea| and |\StartFromHeaderArea|} +% \changes{v1.4}{2005/12/28}{|\sectionstyle| now has a |type| parameter} +% \changes{v1.4}{2005/12/28}{New section styles: hangparindent, hangparindent*} +% \changes{v1.4}{2005/12/28}{|\NCC@makechapfinal| hook introduced} +% \changes{v1.4}{2005/12/28}{|\NCC@makeparttitle|, |\NCC@makechaptitle| hooks} +% \changes{v1.4}{2005/12/28}{The scope of declarations in |\@svsec| is localized} +% \changes{v1.4}{2005/12/28}{|\aftersectionvspace| introduced} +% \changes{v1.4}{2005/12/29}{Add |\DeclarePart| and |\DeclareTOCPart| commands} +% \changes{v1.4}{2005/12/30}{Make the package completely independent on standard commands} +% \changes{v1.4}{2005/12/31}{Add more hooks and fix |\MakeUppercase| related bugs} +% \changes{v1.4}{2006/01/01}{Introduce |\RunningSectionSuffux| command} +% \changes{v1.4}{2006/01/01}{Introduce |\NCC@preparesectag| hook} +% \changes{v1.4}{2006/01/01}{Remove |\NCC@defaultsectag| hook} +% \changes{v1.4}{2006/01/01}{|\NCC@nexttocnum|, |\NCC@preparetocnum| hooks} +% \changes{v1.4}{2006/01/03}{The |\norunningsuffix| modifier introduced} +% \changes{v1.5}{2006/01/06}{Introduce |\SetTOCStyle| and |\ChapterPrefixStyle|} +% \changes{v1.5}{2006/01/17}{Replace addtopackage to afterpackage} +% \changes{v1.5}{2006/01/17}{Remove \protect before \numberline, because it is robust now} +% \changes{v1.5}{2006/01/19}{Allow caption width be greater than a line width} +% \changes{v1.5}{2006/01/19}{Compatibility with the xtab package added} +% \changes{v1.5}{2006/01/19}{Add |\newplainsectionstyle|, |\newhangsectionstyle|} +% \changes{v1.5}{2006/01/19}{Add |\adjustsectionmargins|} +% \changes{v1.5}{2006/01/19}{Introduce |centerlast| section style} +% \changes{v1.5}{2006/01/19}{Introduce |\sectiontagsuffix| command} +% \changes{v1.5}{2006/01/19}{Introduce |\captiontagsuffix| command} +% \changes{v1.6}{2006/01/20}{Improve |\NCC@secflush| to work in |rightlast| style} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccsect,nccboxes,desclist} +\GetFileInfo{nccsect.sty} +\newhangsectionstyle{margin}{2in}[r]{-2in}{0pt plus 1fil} +\newhangsectionstyle{list}{1in}{0pt}{1in plus 1fil} +\newplainsectionstyle{flushright}{0pt}[r]{1in plus 1fil}{0pt} +\begin{document} +\title{The \textsf{nccsect} package\thanks{This file + has version number \fileversion, last + revised \filedate.}\ \thanks{Great thanks to Denis G. Samsonenko + \texttt{} who proposed many significant + improvements to the package.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccsect.dtx} +\end{document} +% +% \fi +% +% \tableofcontents +% +% \section{The Scope and Objectives} +% +% The package provides a new implementation of sections, captions, +% and toc-entries independent on the \LaTeX\ kernel. The reasons for this +% are concerned with the following disadvantages of the +% standard \LaTeX\ implementation: +% +% \paragraph{1} Standard \LaTeX\ sectioning commands can prepare +% display sections in the single style: justified paragraph +% with hang indented number. To change this style to another +% one (centered, par-indented, or else), you need +% to re-implement the internal |\@sect| command. It is no +% control for this style on user's level. +% +% \paragraph{2} If you want to customize the presentation a number in +% a section (for example, put a paragraph mark \S\ before a number +% or put a point after a number), you at least need to +% re-implement the |\@sect| command. +% +% \paragraph{3} The sectioning commands provide no straightforward +% control for running headings. The marking commands +% like the |\sectionmark| solve this problem partially. +% Using them within parameter of sectioning command, +% you can change the mark properly, but this solution does not work in +% complicated documents which use first and last marks +% appearing on a page. The safe solution consists in direct +% replacement a mark prepared within the |\@sect| command +% to a custom mark. +% +% \paragraph{4} Special efforts are required to pass a section +% without number to the header and to the toc-list. There is no simple +% solution providing this action. +% +% \paragraph{5} Captions for tables and figures are prepared in +% just the same way, although, they are usually used in different +% places of floating environments: table captions start +% \textit{before\/} a table, but figure captions go \textit{after\/} +% a figure. So, the vertical skip inserted before a caption is +% unnecessary for table captions. The right solution is to design +% captions for different float types in different ways. +% +% \paragraph{6} The star-form of captions is absent. It is useful +% when a document contains an alone figure or table. Moreover, +% in fiction books, unnumbered captions useful. +% +% \paragraph{7} The design of toc-entries is hard for modifications. +% It is much better to calculate the skips in toc-entries on the +% base of prototyping technique instead of hard-coding them +% with absolute values. Moreover, the skips for nested sections +% must depend on higher level skips. For example, if we +% change skips for a section entry, the skips for subsection entries +% should be adjusted automatically. +% +% \bigskip +% The package eliminates above-mention disadvantages of the standard +% \LaTeX\ implementation. The commands implemented in it are divided +% into two levels: user level and design level. The user-level commands +% are intended for use within a document and the design-level commands +% are directed to class and package writers. +% +% \section{User Interface} +% +% The table below shows sectioning commands provided with standard +% \LaTeX\ classes. Every section has a \textit{level\/} (an integer +% number). Sections can be printed in one of two modes: +% \textit{display\/} or \textit{running\/} mode. Display section is +% prepared as a separate justified paragraph having a hang indent if a +% section has a number. Running section starts a paragraph. +% \begin{center}\catcode`|=12 +% \small\tabcolsep=10pt +% \renewcommand\cboxstyle{\footnotesize} +% \begin{tabular}{|l|c|c|}\hline +% \hfill\cbox{Command}\hfill\mbox{} & +% \hfill\cbox{Level}\hfill\mbox{} & +% \hfill\cbox{Mode}\hfill\mbox{}\\\hline +% \Strut/.8/ +% \cs{part} & $-$1 or 0\footnotemark & display \\ +% \cs{chapter} & 0\footnotemark & display \\ +% \cs{section} & 1 & display \\ +% \cs{subsection} & 2 & display \\ +% \cs{subsubsection} & 3 & display \\ +% \cs{paragraph} & 4 & running \\ +% \cs{subparagraph} & 5 & running \\ +% \hline +% \end{tabular}\footnotetext[1]{The \cs{part} command has zero level +% in article-like classes and has the negative level in book-like +% classes. In book-like classes a part is prepared on +% a separate page.}\footnotetext{The \cs{chapter} command is defined +% in book-like classes only.} +% \end{center} +% +% \DescribeMacro\startsection +% The package redefines all standard sectioning commands. Along with the +% commands shown in the table above, you can use the following +% uniform notations: +% \begin{quote} +% |\startsection|\marg{level}\oarg{toc-entry}\marg{title}\quad or\\ +% |\startsection|\marg{level}|*|\marg{title} +% \end{quote} +% The \meta{level} is a level of section. A negative level produces +% a part. The first command +% produces a numbered section (if~the numbering depth allows this) +% and the last one produces a section without number. +% As for the standard \LaTeX\ sectioning, the first variant of +% the |\startsection| command additionally passes their arguments +% to the section mark command (if the mark command exists) +% and to the aux-file. +% The last variant does no additional actions. +% +% \bigskip +% \textbf{NOTE}: The package allows declaring additional section +% levels. They, of course, have no predefined alias names as +% standard section levels. +% +% \bigskip +% \DescribeMacro\sectionstyle +% The |\sectionstyle|\oarg{type}\marg{style} command allows change +% a style of subsequent display sections of the given \meta{type}: +% \begin{desclist}{\tt}{\quad}[subsubsection]\itemsep=0mm +% \item[main] the section of zero level (|\part| or |\chapter|); +% \item[section] the |\section|; +% \item[subsection] the |\subsection|; +% \item[subsubsection] the |\subsubsection|; +% \item[paragraph] the |\paragraph|; +% \item[subparagraph] the |\subparagraph|; +% \item[section@vi] the section of 6th level, and so on. +% \end{desclist} +% If the \meta{type} parameter is omitted, the command acts on +% all subsequent display sections expect those having a specialized style. +% The following styles are predefined: +% \begin{desclist}{\tt}{\quad}[hangparindent*]\itemsep=0mm +% \item[hangindent] standard LaTeX style (default); +% \item[hangindent*] the same as |hangindent|, but ragged right; +% \item[parindent] title indented on |\parindent|; +% \item[parindent*] the same as |parindent|, but ragged right; +% \item[hangparindent] |\parindent| indented with hang number; +% \item[hangparindent*] the same as |hangparindent|, but ragged right; +% \item[center] centered title; +% \item[centerlast] justified title without indent whose last line is centered. +% \end{desclist} +% You can apply the |\sectionstyle| so many times in the document +% as you want. This command complies with standard \LaTeX\ scoping +% rules. +% +% \bigskip +% \textbf{NOTE}: The section style acts on display sections that were +% prepared with the dynamic alignment (see Section~\ref{s:decl}). By default, +% the sections of levels from 0 to 3 have the dynamic alignment. The +% section of zero level has no hang indentation. +% +% \bigskip +% \DescribeMacro\sectiontagsuffix +% The |\sectiontagsuffix|\oarg{type}\marg{style} command allows change +% a suffix inserted after number tag for sections of the given \meta{type}. +% If the \meta{type} parameter is omitted, the command acts on +% all subsequent sections expect those having a specialized tag suffix. +% +% \DescribeMacro\indentaftersection +% \DescribeMacro\noindentaftersection +% The paragraph indentation after a display section is controlled with +% the |\indentaftersection| and |\noindentaftersection| commands. +% The first one allows and the last one suppresses +% indentation after section. The commands act on the subsequent +% display sections in the scope of their use. +% +% \DescribeMacro\aftersectionvspace +% If a document contains two subsequent sectioning commands (for example, +% |\section| and |\subsection|) the distance between their titles is +% equal to the skip after the first sectioning command. Sometimes +% it is necessary to insert another vertical space here. To override +% the space inserted between sections, use the command +% \begin{quote} +% |\aftersectionvspace|\marg{distance} +% \end{quote} +% This command replaces the space inserted by a previous sectioning +% command with the |\vspace|\marg{distance}. It works in the only case when +% goes right after a command producing a display section. Otherwise, the +% specified \meta{distance} +% is ignored. The following example shows how to customize the +% |\subsection| command in such a way that the distance between it and +% a previous |\section| will be |3ex plus .5ex minus .2ex|: +% \begin{quote} +% |\renewcommand\subsection{%|\\ +% | \aftersectionvspace{3ex plus .5ex minus .2ex}%|\\ +% | \startsection{2}}| +% \end{quote} +% +% \DescribeMacro\adjustsectionmargins +% Margins of a display section can be adjusted using the command +% \begin{quote} +% |\adjustsectionmargins|\marg{left skip}\marg{right skip} +% \end{quote} +% The \meta{left skip} and \meta{right skip} are added to the left and +% right margins of the subsequent section if it is a display section. +% Otherwise, this command is ignored. +% +% \bigskip +% \textbf{Modifiers.} The customization of a number tag and running head of a particular +% section is provided with so-call \textit{modifiers}. A modifier +% is a command acting on the nearest sectioning command going after it. +% Usually, the modifiers are placed just before a sectioning command. +% All modifiers act on non-starred versions of sections. +% If the next sectioning command is starred, modifiers are ignored. +% +% \DescribeMacro\norunninghead +% The |\norunninghead| modifier suppresses generation of running head for the +% next non-starred section, i.e.\ it skips the call of section mark command +% in the next section. +% +% \DescribeMacro\runninghead +% The |\runninghead|\marg{running-title} modifier overrides a text going to the +% running head when a new non-starred section starts and an appropriate\linebreak +% |\pagestyle| is in use. This command has higher priority +% than the |\norunninghead|. +% +% \DescribeMacro\noheadingtag +% The |\noheadingtag| modifier suppresses a number tag in the next section, +% but all other attendant actions are executed (writing to the aux-file and +% updating the running head). +% +% \DescribeMacro\headingtag +% The |\headingtag|\marg{tag} modifier overrides a number tag in the next +% section. It has the higher priority than |\noheadingtag|. Overridden +% section tag can be referred with the |\label| command. +% All fragile commands in the overridden tag should be protected. +% +% \DescribeMacro{\headingtag*} +% The |\headingtag*|\marg{tag} modifier prepares a number tag as is, ignoring +% the tag style, prefix, and suffix. The aux-file and running head are not +% updated in this case. +% +% \DescribeMacro\skipwritingtoaux +% The |\skipwritingtoaux| suppresses writing to aux-file for the next section +% command. +% +% \bigskip +% \textbf{NOTE}: All modifiers use global settings. +% +% \bigskip +% \DescribeMacro\caption +% \DescribeMacro{\caption*} +% The captions are implemented in this package using the same technique as +% the sectioning commands. There are two versions of caption command +% allowed within floating environments: +% \begin{quote} +% |\caption|\oarg{toc-entry}\marg{title}\quad and\\ +% |\caption*|\marg{title} +% \end{quote} +% The first one works in the same manner as the standard \LaTeX\ |\caption| +% command. Its starred version prepares a caption without number and preceding +% words `Figure' or `Table'. +% +% You can use line breaking commands in captions. But in this case, +% you need to set the optional \meta{toc-entry} parameter to avoid +% translation errors. +% +% Caption appearance can be customized. You can customize ether all caption +% types or only selected caption type. The following commands do this: +% \begin{quote} +% |\captionstyle|\oarg{type}\marg{style}\\ +% |\captiontagstyle|\oarg{type}\marg{style}\\ +% |\captiontagsuffix|\oarg{type}\marg{suffix}\\ +% |\captionwidth|\oarg{type}\marg{length} +% \end{quote} +% If \meta{type} is omitted and these commands appear out of float +% environments, they are applied to all types. +% A command without \meta{type} applied within a float environment +% is considered as a command having the type of this environment. Typed +% version of a command has a precedence before a non-typed one. +% +% \medskip\noindent +% \DescribeMacro\captionstyle +% specifies a style +% the caption text will be formatted: +% \begin{desclist}{\tt}{\quad}[centerlast]\itemsep=0mm +% \item[default] standard \LaTeX's style, +% \item[para] simple paragraph without paragraph indent, +% \item[left] all lines are flushed left, +% \item[center] all lines are centered, +% \item[right] all lines are flushed right, or +% \item[centerlast] as |para|, but the last line is centered. +% \end{desclist} +% +% \medskip\noindent +% \DescribeMacro\captiontagstyle +% specifies a position of caption tag: +% \begin{desclist}{\tt}{\quad}[centerlast]\itemsep=0mm +% \item[para] tag is formatted together with text, +% \item[left] tag is adjusted to the left in a separate line, +% \item[center] tag is centered in a separate line, or +% \item[right] tag is adjusted to the right in a separate line. +% \end{desclist} +% +% \medskip\noindent +% \DescribeMacro\captiontagsuffix +% specifies a suffix after caption tag. +% +% \medskip\noindent +% \DescribeMacro\captionwidth +% specifies a width of caption. +% +% \medskip\noindent +% Defaults: +% \begin{quote} +% |\captionstyle{default}|\\ +% |\captiontagstyle{para}|\\ +% |\captiontagsuffix{:\hspace{0.7em plus 0.2em minus 0.1em}}|\\ +% |\captionwidth{\linewidth}| +% \end{quote} +% +% \textbf{NOTE}: The above-described section modifiers can be used with non-starred +% captions. Although, the |\runninghead| and |\norunninghead| commands +% have no sense with captions, but you can do them working if define +% a |\figuremark{}| or |\tablemark{}| command. +% +% \bigskip +% \DescribeMacro\SetTOCStyle +% The |\SetTOCStyle|\marg{declarations} command allows customize +% the table of contents and other content lists. For example, the declaration +% \begin{quote} +% |\SetTOCStyle{\small}| +% \end{quote} +% specifies that content lists will be prepared with the |\small| font. +% This command is allowed in the preamble only. +% +% \DescribeMacro\ChapterPrefixStyle +% The appearance of Chapter/Appendix prefix in a table of contents and +% in a running head can be customized using the command +% \begin{quote} +% |\ChapterPrefixStyle|\marg{appearance list} +% \end{quote} +% The \meta{appearance list} can contain up to two words, namely +% |header| and/or |toc|, delimited with a comma. Using them, you can +% set a prefix-style for the header and/or the table of contents, respectively. +% By default, the prefix-style is specified for the header only. This command +% is allowed for book-like classes in which the |\chapter| command is +% defined. It can be used in the preamble only. +% +% \section{Create New Section Styles} +% +% Along with 8 predefined section styles, you can easy create more styles. +% +% \DescribeMacro\newplainsectionstyle +% The command +% \begin{quote} +% |\newplainsectionstyle|\marg{name}\marg{indent}\oarg{pos}\\ +% | |\marg{left skip}\marg{right skip} +% \end{quote} +% creates a new paragraph-like section style with the given \meta{name}. +% It has the \meta{indent} paragraph indent +% and margins specified with \meta{left skip} and \meta{right skip} lengths. +% To prepare a centered style, the optional \meta{pos} parameter +% should be equal to |[c]|. In this case, left and right margins must +% have an additional |1fil| glue. If optional parameter is |[r]|, the +% left margin must have an additional |1fil| glue. +% +% Four of predefined section styles are created using this command as follows: +% \begin{quote} +% |\newplainsectionstyle{parindent}{0pt}{\parindent}{0pt}|\\ +% |\newplainsectionstyle{parindent*}{0pt}{\parindent}{0pt plus 1fil}|\\ +% |\newplainsectionstyle{center}{0pt}[c]{0pt plus 1fil}{0pt plus 1fil}|\\ +% |\newplainsectionstyle{centerlast}{0pt}[c]{0pt plus 1fil}{0pt plus -1fil}| +% \end{quote} +% Analogously to the |centerlast| style, the |rightlast| style (last line is adjusted +% to the right) can be easy created: +% \begin{quote} +% |\newplainsectionstyle{rightlast}{0pt}[r]{0pt plus 1fil}{0pt plus -1fil}| +% \end{quote} +% +% \DescribeMacro\newhangsectionstyle +% The command +% \begin{quote} +% |\newhangsectionstyle|\marg{name}\marg{min tag width}\oarg{pos}\\ +% | |\marg{left skip}\marg{right skip} +% \end{quote} +% creates a new hang-indented section style with the given \meta{name}. +% The \meta{min tag width} length specifies a minimum width of the section +% tag. If a width of section tag is less than this parameter value, +% a white space will be inserted surround the tag to have the required +% width. The method of inserting a white space is the same as in the +% |\makebox| command. It is controlled with the optional \meta{pos} +% parameter (|l|, |c|, or |r|; |l| default). Other parameters have +% the same meaning as in the previous command. +% +% Four of predefined section styles are created using this command as follows: +% \begin{quote} +% |\newhangsectionstyle{hangindent}{0pt}{0pt}{0pt}|\\ +% |\newhangsectionstyle{hangindent*}{0pt}{0pt}{0pt plus 1fil}|\\ +% |\newhangsectionstyle{hangparindent}{0pt}{\parindent}{0pt}|\\ +% |\newhangsectionstyle{hangparindent*}{0pt}{\parindent}{0pt plus 1fil}| +% \end{quote} +% +% The following examples shows possibilities of these commands: +% +% \skipwritingtoaux +% \sectionstyle[subsection]{margin} +% \subsection{This subsection was prepared in the margin style} +% +% The definition of the |margin| style is the following: +% \begin{quote} +% |\newhangsectionstyle{margin}{2in}[r]{-2in}{0pt plus 1fil}| +% \end{quote} +% +% \skipwritingtoaux +% \sectionstyle[subsection]{list} +% \subsection{This subsection was prepared in the list style} +% +% The definition of the |list| style is the following: +% \begin{quote} +% |\newhangsectionstyle{list}{1in}{0pt}{1in plus 1fil}| +% \end{quote} +% +% \skipwritingtoaux +% \sectionstyle[subsection]{flushright} +% \subsection{This subsection was prepared in the flushright style} +% +% The definition of the |flushright| style is the following: +% \begin{quote} +% |\newplainsectionstyle{flushright}{0pt}[r]{1in plus 1fil}{0pt}| +% \end{quote} +% \sectionstyle[subsection]{hangindent} +% +% \section{Declare Sections and Captions\label{s:decl}} +% +% \DescribeMacro\DeclareSection +% To define or redefine a section or caption command, you can use +% in the preamble of your document the +% following command: +% \begin{quote} +% |\DeclareSection|\marg{level}\marg{type}\oarg{indent}\marg{prefix}\marg{beforeskip}\\ +% | |\marg{afterskip}\marg{style} +% \end{quote} +% \begin{desclist}{}{}[\meta{beforeskip}] +% \item[\meta{level}] a section level number. Zero and negative values +% are interpreted as follows: +% 0 means declaring the |\chapter| or |\part| command depending on a +% class used; a negative value means declaring a caption. +% +% \item[\meta{type}] a section type. For zero level, this +% parameter is ignored. For negative level, it defines a float type +% (i.e., |figure| or |table|). For positive level, it defines +% a counter name. The name of marking command is composed from +% the type as |\|\meta{type}|mark|. +% +% \item[\meta{indent}] indentation of heading from the left margin +% (zero is default). Ignored for negative levels. +% +% \item[\meta{prefix}] a prefix inserted before a section-number tag +% (usually empty). In chapter, part, or caption declaration commands, +% it is inserted right before the tag name, e.g., before the |\@chapapp|, +% |\partname|, |\figurename|, or |\tablename| command. +% +% \item[\meta{beforeskip}] the skip to leave above the heading. +% +% \item[\meta{afterskip}] if positive, then the skip to leave below +% the heading, else negative of skip to leave to right of running +% heading. The negative value is allowed for positive section levels +% only. +% +% \item[\meta{style}] commands to set a style. The last command in +% this argument may be a command such as |\MakeUppercase| that +% takes an argument. The section heading will be supplied as the +% argument to this command. So setting it to, say, +% |\bfseries\MakeUppercase| would produce bold, uppercase headings. +% \end{desclist} +% Sections having nonnegative \meta{level} and positive \meta{afterskip} +% are display sections. They are declared with the |hangindent| style +% and do not obey the |\sectionstyle| command. +% +% \DescribeMacro{\DeclareSection*} +% To declare a display section having dynamic alignment controlled with the +% |\sectionstyle| command, use the star-version of the previous command: +% \begin{quote} +% |\DeclareSection*|\marg{level}\marg{type}\marg{prefix}\marg{beforeskip}\\ +% | |\marg{afterskip}\marg{style} +% \end{quote} +% A negative \meta{afterskip} has no meaning in this case. +% +% \DescribeMacro\bff +% To prepare bold section headings, +% you can use the |\bff| command in the \meta{style} parameter. +% It tries to set everything bold. Its definition is the following: +% \begin{quote} +% |\newcommand{\bff}{\normalfont\bfseries\mathversion{bold}}| +% \end{quote} +% +% Examples of section and caption declarations: +% \begin{quote} +% |\DeclareSection{-2}{table}{}{0pt}{10pt}{}|\\ +% |\DeclareSection{-1}{figure}{}{10pt}{0pt}{}|\\ +% |\DeclareSection*{1}{section}{}%|\\ +% | {3.5ex plus 1ex minus .2ex}%|\\ +% | {2.3ex plus .2ex}{\Large\bff}| +% \end{quote} +% Here we declare the table caption command with zero skip +% before it and |10pt| skip after it. On contrary, the +% figure caption command produces |10pt| skip before it +% and zero skip after it. The |\section| command is declared with +% dynamic horizontal alignment. It is prepared in the |\Large| +% font with everything bold. +% +% \DescribeMacro\SectionTagSuffix +% The |\SectionTagSuffix|\marg{suffix} command specifies a default suffix +% inserted after a section number tag. For example, the command +% \begin{quote} +% |\SectionTagSuffix{.\quad}| +% \end{quote} +% sets the decimal point after every section number tag. +% Sections of 0th level ignore this suffix. The default tag is |\quad|. +% The command can be used in the preamble only. +% +% \DescribeMacro\RunningSectionSuffix +% The |\RunningSectionSuffix|\marg{suffix} command specifies a suffix +% inserted after a running section title right before the skip after +% section. It can be used in the preamble only. +% The default value is an empty suffix. +% +% \DescribeMacro\norunningsuffix +% To remove the suffix after a running section, put the +% |\norunningsuffix| modifier in the parameter of running section. +% +% \DescribeMacro\CaptionTagSuffix +% The |\CaptionTagSuffix|\marg{suffix} command specifies a default suffix +% inserted after a caption number tag. It can be used in the preamble only. +% The default caption tag is: +% \begin{quote} +% |\CaptionTagSuffix{:\hspace{0.7em plus 0.2em minus 0.1em}}| +% \end{quote} +% +% \section{Declare TOC-Entries} +% +% \DescribeMacro\DeclareTOCEntry +% To declare an entry of table of contents or other lists +% (list of figures or list of tables), use the following command +% (in the preamble only): +% \begin{quote} +% |\DeclareTOCEntry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\ +% | |\marg{style}\oarg{next} +% \end{quote} +% \begin{desclist}{}{\hfill}[\meta{prototype}] +% \item[\meta{level}] a section level number. +% For zero and negative level the following commands are created: +% 0 means |\l@chapter| or |\l@part| depending on class used; +% $-1$ means |\l@figure|; $-2$ means |\l@table|. If level +% is greater than 5, the name of toc-entry command is +% generated as |\l@section@|\meta{level-in-roman}, +% i.e., the toc-entry of 6th level is |\l@section@vi|. +% +% \item[\meta{action}] commands applied before entry is produced (usually empty). +% +% \item[\meta{prefix}] text inserted before the section number (usually empty). +% +% \item[\meta{prototype}] prototype of number for alignment the toc-entry body. +% The hang indent of this toc-entry will be equal to the width of +% \begin{quote} +% \meta{style}|{|\meta{prefix}\meta{prototype}\meta{numberline-suffix}|}| +% \end{quote} +% +% \item[\meta{style}] commands to set a style. The last command in this argument +% may be a command such as |\MakeUppercase| that takes an +% argument. The produced entry will be supplied as the +% argument to this command. So setting it to, say, +% |\bfseries\MakeUppercase| would produce bold, +% uppercase entry. This style is applied to the number also and to the +% page number. +% To apply different styles to the text of entry and to its page +% number, use in this parameter the command +% \begin{quote} +% |\applystyle|\marg{text-style}\marg{number-style} +% \end{quote} +% +% \item[\meta{next}] prototype for left margin adjustment for an entry of the +% next level. Default is the hang indent of the current toc-entry. +% \end{desclist} +% A toc-entry is produced within a group. +% +% \DescribeMacro\NumberlineSuffix +% The |\NumberlineSuffix|\marg{calc-suffix}\marg{actual-suffix} +% command allows customize a skip inserted after +% numbers in TOC-like entries. The \meta{calc-suffix} parameter +% is used in calculations of hang indent of toc-entries and the +% \meta{actual-suffix} is really inserted at the end of number. +% The \marg{calc-suffix} is usually wider than the \meta{actual-suffix}. +% The default is |\NumberlineSuffix{\quad}{\enskip}|. +% This command is available in the preamble only. +% +% \DescribeMacro\PnumPrototype +% The |\PnumPrototype|\marg{prototype} command is used for adjustment +% the right margin of the text of toc-entries in toc-lists. +% Default is |\PnumPrototype{99}|. +% If your document has more than 99 pages, use +% |\PnumPrototype{999}|. +% This command is available in the preamble only. +% +% \DescribeMacro\TOCMarginDrift +% The |\TOCMarginDrift|\marg{increment} command specifies a value of +% right-margin drift in TOCs. The increment is applied after the |\@plus| +% token in definition of right margin. Empty argument means no drift. +% Examples: +% \begin{quote} +% |\TOCMarginDrift{2em}|\\ +% |\TOCMarginDrift{1fil}| +% \end{quote} +% The command can be use anywhere in the document. +% +% \DescribeMacro\runinsectionskip +% This command is useful in the \meta{action} parameter of the +% toc-entry declaration to produce the skip before a toc-entry +% equal to the skip before run-in sections. +% +% The following example shows how toc-entries are declared in books: +% \begin{quote} +% |\DeclareTOCEntry{-2}{}{}{9.9}{}% table|\\ +% |\DeclareTOCEntry{-1}{}{}{9.9}{}% figure|\\ +% |\DeclareTOCEntry{0}{\runinsectionskip\def\@dotsep{1000}%|\\ +% | \aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff}% chapter|\\ +% |\DeclareTOCEntry{1}{}{}{9.9}{}[9.9]% section|\\ +% |\DeclareTOCEntry{2}{}{}{9.9.9}{}[9.9.9]% subsection|\\ +% |\DeclareTOCEntry{3}{}{}{}{}[\qquad]% subsubsection| +% \end{quote} +% The number prototype for figures and tables is `9.9' here. +% The |\l@chapter| entry applies the run-in section skip before it and +% redefines the |\@dotsep| command to remove dot leaders. +% Using the |\aftergroup| command, it inserts the |\@highpenalty| +% after this toc-entry to avoid a page break at this point. +% The left margin adjustment after section and nested toc-entries +% is calculated here using the prototype of widest section number. +% This produces the following nesting: +% \begin{flushleft} +% {\bf 1\quad Chapter}\\ +% \jhbox{{\bf 1\quad}}{}1.1\quad Section\\ +% \jhbox{{\bf 1\quad}1.1}{}1.1.1\quad Subsection\\ +% \jhbox{{\bf 1\quad}1.11.1.1}{}Subsubsection +% \end{flushleft} +% +% \section{Declare New Float Types} +% +% The standard \LaTeX\ classes provide two types of floating environments: +% figures and tables. If you have prepared a new floating +% environment in some way (i.e., using the |float| package by Anselm +% Lingnau), you can declare a caption for the new float +% with the commands described in previous sections. +% +% \DescribeMacro\RegisterFloatType +% In books, when a new chapter starts, the |\chapter| command +% puts a special vertical skip to the contents of list of figures and +% of list of tables. This behaviour can be easy extended to new float types +% if you register them within this package. The registration is +% provided with the following command: +% \begin{quote} +% |\RegisterFloatType|\marg{float-type} +% \end{quote} +% After the float type is registered, you can declare a toc-entry +% for it using the negation of its registration number in the +% \meta{level} parameter. The +% first new float type is registered third (after the figure and table). +% So, you must +% use \meta{level} = $-3$ for it, $-4$ for the next registered float +% type and so on. +% +% In the following example, we define a new float type, |program|, +% and prepare the caption and toc-entry commands for it. +% The caption of programs +% is supposed to be used at the beginning of program. +% So, we make it in the same manner as the table caption. +% \begin{quote} +% |\documentclass{book}|\\ +% |\usepackage{float,nccsect}|\\ +% |\newfloat{program}{tp}{lop}[chapter]|\\ +% |\floatname{program}{Program}|\\ +% |\RegisterFloatType{program}|\\ +% |\DeclareSection{-3}{program}{}{0pt}{10pt}{}|\\ +% |\DeclareTOCEntry{-3}{}{}{9.9}{}| +% \end{quote} +% +% To produce a list of programs, you can then use the |\listof| +% command from the |float| package as follows: +% \begin{quote} +% |\listof{program}{List of Programs}| +% \end{quote} +% \StopEventually{} +% +% \section{Epigraphs and Related Staff} +% +% \DescribeMacro\beforechapter +% \DescribeMacro\epigraph +% To put epigraph before any chapter, you can use two methods: +% low-level |\beforechapter|\marg{anything} hook or +% user-level command +% \begin{quote} +% |\epigraph|\oarg{width}\marg{text}\marg{author} +% \end{quote} +% The last one applies a special formatting to epigraph and +% calls the first one. The |\beforechapter| hook inserts its +% contents at the beginning of page just before a chapter +% instead of spacing specified in the chapter declaration. +% +% \DescribeMacro\epigraphparameters +% Formatting of user-level epigraph is provided with the +% following command +% \begin{quote} +% |\epigraphparameters|\marg{style}\marg{width}\marg{height}\marg{author-style}\\ +% | |\marg{after-action} +% \end{quote} +% Here \meta{style} is a style applied to the whole epigraph +% (font selection, spacing and positioning, etc.), the \meta{width} +% is the default epigraph width (can be changed in an epigraph), +% the \meta{author-style} is the style applied to the author's +% signature, and the \meta{after-action} is an action applied after +% the epigraph (usually a vertical spacing). All styles and actions +% are applied in the vertical mode. An \meta{author-style} can finish with +% one-argument macro getting the author of epigraph and formatting it. +% +% \DescribeMacro\epigraphwidth +% In |\epigraphparameters|, you can use the |\epigraphwidth| macro +% which contains a selected epigraph width. +% +% The default style is: +% \begin{quote} +% |\epigraphparameters{\StartFromHeaderArea\small\raggedleft}|\\ +% | {.45\linewidth}{5\baselineskip}|\\ +% | {\raggedleft\itshape}{\vspace{2ex}}| +% \end{quote} +% +% \DescribeMacro\StartFromTextArea +% The |\vspace*| command applied at the beginning of page has one serious +% disadvantage: it skips more space that specified in its parameter. +% To remove this disadvantage, we introduce the |\StartFromTextArea| +% command that +% inserts a zero-height strut and allows use the |\vspace| command after it +% without troubles. +% +% \DescribeMacro\StartFromHeaderArea +% You can also extend the text area on the header if apply the +% |\StartFromHeaderArea| command at the beginning of page. +% Such action is useful in epigraphs: the first chapter's page usually +% has an empty header and positioning an epigraph from the header +% is the good practice.{\sloppy\par} +% +% \section{Declare Part} +% +% The |\part| command in book-like classes is the only sectioning command +% that cannot be prepared with the |\DeclareSection| command. So, we add +% special declarations to provide parts in books with features of other +% sectioning commands. +% +% \DescribeMacro\DeclarePart +% To redefine the |\part| in books, use the following declaration: +% \begin{quote} +% |\DeclarePart|\marg{before}\marg{after}\marg{prefix}\marg{style} +% \end{quote} +% \begin{desclist}{}{}[\meta{before}] +% \item[\meta{before}] an action applied before a part at the beginning of +% page. It usually specifies a vertical skip |\vfil| and a +% paragraph style to be applied to the part number tag and title. +% \item[\meta{after}] an action applied after the part. It usually contains +% |\vfil| and page finishing commands. +% \item[\meta{prefix}] a prefix inserted before a part tag. It contains +% style commands to be applied to the tag and the |\vspace| command +% specifying a distance between the part tag and title. +% The |\partname| command goes right after the prefix. +% \item[\meta{style}] a style to be applied to the part title. It can end +% with |\MakeUppercase|. +% \end{desclist} +% +% The default declaration of the |\part| is the following: +% \begin{quote} +% |\DeclarePart{\StartFromTextArea\vfil\centering}%|\\ +% | {\vfil\newpage \if@twoside\if@openright|\\ +% | \mbox{}\thispagestyle{empty}\newpage\fi\fi}%|\\ +% | {\vspace{4ex}\huge\bff}{\Huge\bff}| +% \end{quote} +% The |\StartFromTextArea| command prevents ignoring a vertical space +% at the beginning of page. All paragraphs of part title are centered +% horizontally using the |\centering| declaration, and the title +% is centered vertically using |\vfil| commands +% before and after it. A page after the part is made empty in two-side +% mode if it is even. The space after the part tag is set to |4ex|. +% +% In Russian typesetting tradition, the part can be prepared in the +% same manner as a chapter, i.e.\ a text going after a part is prepared +% on the same page with the part title. It is easy to re-declare +% the part in such style. +% Let us start a part from the header and delimit it from the text +% with a decorative line. The following declaration does this: +% \begin{quote} +% |\DeclarePart{\StartFromHeaderArea\centering}|\\ +% | {\vspace{2mm}\noindent\hrulefill\par|\\ +% | \addvspace{5mm}}|\\ +% | {\vspace{.5em}\LARGE\bff}{\Huge\bff}| +% \end{quote} +% But when a chapter goes right after a part, we need to place the part and +% chapter titles together +% on the same page. This can be applied using the |\beforechapter| hook: +% \begin{quote} +% |\beforechapter{\part|\marg{part title}|}|\\ +% |\chapter|\marg{chapter title} +% \end{quote} +% Modifiers stored in the parameter of |\beforechapter| hook will act on +% the |\part| command. Modifiers outside of |\beforechapter| will act on +% the |\chapter| command. +% +% \DescribeMacro\DeclareTOCPart +% To produce a toc-entry command for a part, the following declaration is +% specified for book-like classes: +% \begin{quote} +% |\DeclareTOCPart|\marg{action}\oarg{afterskip}\marg{prefix}\marg{prototype}\marg{style} +% \end{quote}% +% \begin{desclist}{}{}[\meta{afterskip}] +% \item[\meta{action}] an action applied before the part toc-entry. It usually +% a skip before part. It is recommended to prepare it with |\NCC@secskip| +% command. +% \item[\meta{afterskip}] a skip after this entry. If it is omitted, +% the default |\NCC@runskip| value is applied after this entry. +% \item[\meta{prefix}] a prefix inserted before a part tag (usually empty). +% \item[\meta{prototype}] a prototype of part tag used for calculation the +% hang indent in this entry. +% \item[\meta{style}] a style applied to the whole text of entry and to +% the page number. The |\MakeUppercase| is allowed to finish this +% parameter. The |\applystyle| command can be used inside it to +% apply different styles to the toc-entry and the page number. +% \end{desclist} +% +% The default declaration of the part toc-entry is the following: +% \begin{quote} +% |\DeclareTOCPart{\NCC@secskip{4ex \@plus .2ex}%|\\ +% | \def\@dotsep{1000}}%|\\ +% | {}{\partname\ II}{\large\bff}|\\ +% \end{quote} +% +% \section{The Implementation} +% +% The \textbf{afterpackage} package is used to add compatibility +% commands. +% \begin{macrocode} +%<*package> +\RequirePackage{afterpackage} +% \end{macrocode} +% +% \begin{macro}{\NCC@secskip} +% \begin{macro}{\NCC@runskip} +% The package shares the following commands with the +% |nccthm| package: +% \begin{quote} +% |\NCC@secskip|\marg{skip} adds the \meta{skip} before a section,\\ +% |\NCC@runskip| is a skip inserted before run-in sections. +% \end{quote} +% We protect the definitions of these commands with testing +% the |nccthm| package to be already loaded. +% \begin{macrocode} +\@ifpackageloaded{nccthm}{}{% + \def\NCC@secskip#1{% + \if@noskipsec \leavevmode \fi \par + \if@nobreak \everypar{}\else + \addpenalty\@secpenalty + \addvspace{#1}% + \fi + } + \def\NCC@runskip{2.75ex \@plus 1ex \@minus .2ex} +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\runinsectionskip} +% This command is useful in toc-entries: +% \begin{macrocode} +\newcommand{\runinsectionskip}{\NCC@secskip{\NCC@runskip}} +% \end{macrocode} +% \end{macro} +% +% \subsection{The Kernel} +% +% We start with declaring the section controls (modifiers): +% \begin{desclist}{\tt}{\hfill}[NCC@secstartag]\raggedright +% \item[NCC@nosectag] is true if |\noheadingtag| is applied; +% \item[NCC@secstartag] is true if |\headingtag*|\marg{tag} is applied; +% \item[\cs{NCC@sectag}] saves a value of the |\headingtag| parameter; +% \item[NCC@nosecmark] is true if |\norunninghead| is applied; +% \item[\cs{NCC@secmark}\rm\marg{mark-command}] executes the \meta{mark-command} +% with the parameter of |\runninghead| command; +% \item[NCC@noaux] is true if |\skipwritingtoaux| is applied. +% \end{desclist} +% \begin{macrocode} +\newif\ifNCC@nosectag +\newif\ifNCC@secstartag +\newif\ifNCC@nosecmark +\newif\ifNCC@noaux +% \end{macrocode} +% +% \begin{macro}{\NCC@global} +% We reset all controls globally, but in the |\beforechapter| +% hook we need to reset them locally. So, we reset all controls +% using the |\NCC@global| modifier which value is |\global| by default. +% \begin{macrocode} +\let\NCC@global\global +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@sec@reset@controls} +% This command resets all controls to default values. +% It must be applied at the end of every section command. +% \begin{macrocode} +\def\NCC@sec@reset@controls{% + \NCC@global\NCC@nosectagfalse + \NCC@global\NCC@secstartagfalse + \NCC@global\let\NCC@sectag\relax + \NCC@global\NCC@nosecmarkfalse + \NCC@global\let\NCC@secmark\relax + \NCC@global\NCC@noauxfalse +} +\NCC@sec@reset@controls +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\norunninghead} +% \begin{macro}{\runninghead} +% \begin{macro}{\noheadingtag} +% \begin{macro}{\headingtag} +% \begin{macro}{\headingtag*} +% \begin{macro}{\skipwritingtoaux} +% User interface to section controls: +% \begin{macrocode} +\newcommand{\norunninghead}{\NCC@global\NCC@nosecmarktrue} +\newcommand*{\runninghead}[1]{\NCC@global\def\NCC@secmark##1{##1{#1}}} +\newcommand{\noheadingtag}{\NCC@global\NCC@nosectagtrue} +\newcommand{\headingtag}{% + \@ifstar{\NCC@global\NCC@secstartagtrue\NCC@setsectag}{\NCC@setsectag}% +} +\def\NCC@setsectag#1{\NCC@global\def\NCC@sectag{#1}} +\newcommand{\skipwritingtoaux}{\NCC@global\NCC@noauxtrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@makesection} +% The |\NCC@makesection|\marg{type}\marg{level}\marg{toc-entry}\marg{toc-action} +% produces a section or caption. It analyzes the modifiers and customizes +% sections or captions. The \meta{toc-action} parameter contains an +% attendant action that must be applied at the end of macro. +% It writes a toc-entry to aux-file. +% +% The command uses the following hooks that must be prepared +% before its call: +% \begin{desclist}{}{}[\cs{NCC@make}\marg{action}] +% \item[\cs{NCC@makesectag}\marg{value}] produces a tag in |\@svsec| +% using the given value; +% +% \item[\cs{NCC@make}\marg{action}] makes a section or caption heading +% and applies the \meta{action} after heading. Before the call +% of this command, the |\@svsec| macro is prepared (it contains a +% prepared tag). +% \end{desclist} +% We start from the case when the |\headingtag*|\marg{tag} modifier was +% applied and the section tag was saved in the |\NCC@sectag| macro. +% We apply the |\NCC@make| procedure with the given section tag. +% Attendant actions are ignored for this case. +% \begin{macrocode} +\def\NCC@makesection#1#2#3#4{% + \ifNCC@secstartag + \let\@svsec\NCC@sectag + \NCC@make{}% + \else +% \end{macrocode} +% Prepare a tag creation command in the |\the|\meta{type} macro. +% We can do some temporary changes here that will be restored +% at the end of macro. The restore hook is prepared in the +% |\NCC@restsec| command. +% \begin{macrocode} + \ifx\NCC@sectag\relax +% \end{macrocode} +% The |\noheadingtag| case: we temporary set the |secnumdepth| +% counter to very low negative value. This prevents numbering +% this section: +% \begin{macrocode} + \ifNCC@nosectag + \edef\NCC@restsec{% + \noexpand\c@secnumdepth \the\c@secnumdepth\relax + }% + \c@secnumdepth -1000 +% \end{macrocode} +% The ordinary case: No restore actions is necessary here. +% \begin{macrocode} + \else + \let\NCC@restsec\relax + \ifnum#2>\c@secnumdepth \else\refstepcounter{#1}\fi + \fi +% \end{macrocode} +% The |\headingtag|\marg{tag} case: we temporary let the +% |\the|\meta{type} macro to be equal to the |\NCC@sectag| +% command produced by the |\headingtag|, +% save the original value in the |\NCC@thesec| command, +% and prepare the |\NCC@restsec| macro. +% \begin{macrocode} + \else + \expandafter\let\expandafter\NCC@thesec\csname the#1\endcsname + \def\NCC@restsec{% + \expandafter\let\csname the#1\endcsname\NCC@thesec + }% + \expandafter\let\csname the#1\endcsname\NCC@sectag + \protected@edef\@currentlabel{\NCC@sectag}% + \fi +% \end{macrocode} +% +% Prepare section tag in the |\@svsec| command: +% \begin{macrocode} + \ifnum #2>\c@secnumdepth + \let\@svsec\@empty + \else + \protected@edef\@svsec{% + \protect\NCC@makesectag{\csname the#1\endcsname}% + }% + \fi +% \end{macrocode} +% +% We cannot do the marking right now because the producing of section +% can be suspended to the beginning of the nearest paragraph +% (in run-in sections). So, we need to prepare a mark action +% in a command that will save its state as long as necessary. +% This command is |\NCC@makemark|. +% \begin{macrocode} + \let\NCC@makemark\@empty + \@ifundefined{#1mark}{}{% + \ifx\NCC@secmark\relax +% \end{macrocode} +% Ordinary case: prepare the section mark with the +% \meta{toc-entry} parameter. +% \begin{macrocode} + \ifNCC@nosecmark \else + \def\NCC@makemark{\csname #1mark\endcsname{#3}}% + \fi +% \end{macrocode} +% The |\runninghead|\marg{heading} case: +% pass the mark command in the parameter of |\NCC@secmark|. +% We need to save the |\NCC@secmark| value in some command +% and pass this command within |\NCC@makemark| because +% the |\NCC@secmark| could be removed before the use. +% \begin{macrocode} + \else + \let\NCC@savesecmark\NCC@secmark + \def\NCC@makemark{% + \NCC@savesecmark{\csname #1mark\endcsname}% + \let\NCC@savesecmark\relax + }% + \fi + }% +% \end{macrocode} +% +% Make the section. We must apply the restore action at +% the end action of |\NCC@make| command by the same reason that +% the section making may be suspended: +% \begin{macrocode} + \ifNCC@noaux + \NCC@make{\NCC@makemark \NCC@restsec}% + \else + \NCC@make{\NCC@makemark #4\NCC@restsec}% + \fi +% \end{macrocode} +% +% Reset modifiers: +% \begin{macrocode} + \fi + \NCC@sec@reset@controls +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Section Making Commands} +% +% \begin{macro}{\indentaftersection} +% \begin{macro}{\noindentaftersection} +% Introduce macros controlling indentation after display sections: +% \begin{macrocode} +\newcommand{\indentaftersection}{\@afterindenttrue} +\newcommand{\noindentaftersection}{\@afterindentfalse} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\SectionTagSuffix} +% The |\SectionTagSuffix|\marg{suffix} sets a default suffix after +% a section tag. +% \begin{macrocode} +\newcommand*{\SectionTagSuffix}[1]{\def\NCC@asecnum{#1}} +\@onlypreamble\SectionTagSuffix +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\sectiontagsuffix} +% |\sectiontagsuffix|\oarg{type}\marg{suffix} changes a suffix after section +% tag that will be used for sections of the given +% \meta{type}. If \meta{type} is omitted, the specified suffix will be used +% in text flow for all sections having no special suffix. +% \begin{macrocode} +\newcommand*\sectiontagsuffix[2][]{% + \expandafter\def\csname NCC@asecnum@#1\endcsname{\def\NCC@asecnum{#2}}% +} +\let\NCC@asecnum@\@empty +\def\NCC@setsectionsuffix#1{% + \edef\@tempa{NCC@asecnum@\NCC@secname{#1}}% + \@ifundefined{\@tempa}{% + \let\NCC@asecnumset\NCC@asecnum@ + }{% + \expandafter\let\expandafter\NCC@asecnumset\csname\@tempa\endcsname + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\RunningSectionSuffix} +% The |\RunningSectionSuffix|\marg{suffix} sets a suffix after a title +% of a running section: +% \begin{macrocode} +\newcommand*{\RunningSectionSuffix}[1]{\def\NCC@asectitle{\unskip#1}} +\@onlypreamble\RunningSectionSuffix +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@preparesectag} +% The |\NCC@preparesectag|\marg{style}\marg{before} hook prepares the +% |\NCC@makesectag| command: +% \begin{macrocode} +\def\NCC@preparesectag#1#2{\def\NCC@makesectag##1{#1#2##1\NCC@asecnum}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@secname} +% The |\NCC@secname|\marg{level} command generates section name +% (|main|, |section|, |subsection|, \ldots, +% or |section@vi|, |section@vii|, \ldots\ for new section levels). +% This name is used as the second parameter of the |\addcontentsline| +% command, in the declarations of toc-entries, and in the style +% selection command. +% \begin{macrocode} +\def\NCC@secname#1{% + \ifcase#1main\or section\or subsection\or subsubsection\or + paragraph\or subparagraph\else section@\romannumeral#1\fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@startsection} +% The |\NCC@startsection| command +% has the same syntax as its non-NCC prototype: +% \begin{quote} +% |\NCC@startsection|\marg{type}\marg{level}\marg{indent}\marg{beforeskip}\\ +% | |\marg{afterskip}\marg{style} +% \end{quote} +% but works in a bit different way: it ignores the sign of +% \meta{beforeskip}. In the original version the testing +% was applied to set an appropriate |afterindent| mode. +% But we change this mode using |\indentaftersection| and +% |\noindentaftersection| macros. +% \begin{macrocode} +\def\NCC@startsection#1#2#3#4#5#6{% + \@tempskipa #4\relax + \ifdim \@tempskipa <\z@ \@temskipa -\@tempskipa \fi + \NCC@secskip \@tempskipa + \secdef{\NCC@sect{#1}{#2}{#3}{#4}{#5}{#6}}{\NCC@ssect{#3}{#4}{#5}{#6}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makesec} +% The interface of |\NCC@ssect| and |\NCC@sect| commands is similar to their +% \LaTeX's prototypes. They are based on the following +% command: +% \begin{quote} +% |\NCC@makesec|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action} +% \end{quote} +% In fact, there are two versions of this command: +% the traditional version, |\NCC@makesect|, and the +% version with dynamic control of section style,\linebreak |\NCC@makesecx|. +% One of them should be selected before applying the |\NCC@ssect| and |\NCC@sect| +% commands. +% \end{macro} +% +% \begin{macro}{\NCC@ssect} +% The starred form of section: +% \begin{quote} +% |\NCC@ssect|\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{heading} +% \end{quote} +% \begin{macrocode} +\def\NCC@ssect#1#2#3#4#5{% + \let\@svsec\@empty + \NCC@makesec{#1}{#4}{#5}{#3}{}% + \NCC@sec@reset@controls +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@sect} +% The base form of section: +% \begin{quote} +% |\NCC@sect|\marg{type}\marg{level}\marg{indent}\marg{beforeskip}\marg{afterskip}\marg{style}\\ +% | |\oarg{toc-entry}\marg{heading} +% \end{quote} +% \begin{macrocode} +\def\NCC@sect#1#2#3#4#5#6[#7]#8{% + \def\NCC@make{\NCC@makesec{#3}{#6}{#8}{#5}}% + \NCC@makesection{#1}{#2}{#7}{% + \addcontentsline{toc}{\NCC@secname{#2}}{% + \ifnum #2>\c@secnumdepth \else + \numberline{\csname the#1\endcsname}% + \fi + #7% + }% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makesect} +% The traditional section making command: +% \begin{quote} +% |\NCC@makesect|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action} +% \end{quote} +% \begin{macrocode} +\def\NCC@makesect#1#2#3#4#5{% + \@tempskipa #4\relax + \ifdim \@tempskipa>\z@ + \begingroup \normalfont + \NCC@asecnumset +% \end{macrocode} +% The |\NCC@secttitle|\marg{style}\marg{tag}\marg{title} hook prepares +% traditional display section: +% \begin{macrocode} + \NCC@secttitle{#2}{\NCC@hangfrom{\hskip #1\relax\@svsec}}% + {\interlinepenalty \@M\ignorespaces #3\@@par} + \endgroup + #5% + \else +% \end{macrocode} +% The |\NCC@secptitle|\marg{style}\marg{tag}\marg{title} hook prepares +% running section. The |\norunningsuffix| modifier applied in the +% parameter of running section removes a suffix after section title. +% \begin{macrocode} + \def\@svsechd{{\normalfont + \NCC@asecnumset + \def\norunningsuffix{\protect\NCC@nosecsuffix}% + \NCC@secptitle{#2}{\hskip #1\relax{\@svsec}}% + {\ignorespaces #3\NCC@asectitle}#5}}% + \fi + \@xsect{#4}% +} +\def\NCC@secttitle#1#2#3{#1{#2#3}} +\def\NCC@secptitle#1#2#3{#1{#2#3}} +\newcommand*\norunningsuffix{} +\def\NCC@nosecsuffix{\let\NCC@asectitle\@empty} +% \end{macrocode} +% \end{macro} +% +% \subsection{Create Section Styles} +% +% \begin{macro}{\NCC@hangfrom} +% |\NCC@hangfrom|\marg{section tag} works as +% the \LaTeX's |\@hangfrom| command, but its margins can be adjusted +% with the |\adjustsectionmargins| command. +% \begin{macrocode} +\def\NCC@hangfrom{% + \NCC@setsecmargins{\z@skip}{\z@skip}\NCC@hangsecstyle{\z@}{}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@setsecmargins} +% |\NCC@setsecmargins|\marg{left skip}\marg{right skip} sets +% section margins and applies the hook that can be defined by the +% |\adjustsectionmargins| command. +% \begin{macrocode} +\def\NCC@setsecmargins#1#2{% + \leftskip\z@skip \rightskip\z@skip + \parfillskip\@flushglue + \let\\\@normalcr + \NCC@adjsecmargins{#1}{#2}% + \NCC@secmarginshook +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@adjsecmargins} +% |\NCC@adjsecmargins|\marg{left skip}\marg{right skip} adjusts +% section margins. The |\parfillskip| value is also adjusted to +% a difference between stretchabilities of the \meta{left skip} +% and the \meta{right skip}. Using this trick, we can easy specify +% the |centerlast| style just setting the stretchability of the +% \meta{right skip} as a negation of the \meta{left skip} stretchability. +% To extract a stretchability from a skip, we simply add it multiplied +% by |-1| (while multiplication the stretchability is removed!). +% \begin{macrocode} +\def\NCC@adjsecmargins#1#2{% + \setlength\@tempskipa{#1}\advance\leftskip\@tempskipa + \setlength\@tempskipb{#2}\advance\rightskip\@tempskipb + \advance\@tempskipa -1\@tempskipa \advance\@tempskipb -1\@tempskipb + \advance\@tempskipa -\@tempskipb \advance\parfillskip\@tempskipa +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@hangsecstyle} +% |\NCC@hangsecstyle|\marg{min tag width}\marg{pos}\marg{section tag} +% starts a hang paragraph and prints its tag. The \meta{min tag width} +% specifies a minimum width of hang indent and \meta{pos} specifies +% an alignment of \meta{section tag} (|l|, |c|, |r|) if its width +% is less than the minimum width. +% \begin{macrocode} +\def\NCC@hangsecstyle#1#2#3{% + \setlength\@tempdima{#1}% + \setbox\@tempboxa\hbox{#3}% + \ifdim \wd\@tempboxa > \@tempdima + \hangindent\wd\@tempboxa \noindent \box\@tempboxa + \else + \hangindent\@tempdima + \noindent \makebox[\@tempdima][#2]{\unhbox\@tempboxa}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\adjustsectionmargins} +% |\adjustsectionmargins|\marg{left skip}\marg{right skip} +% defines the |\NCC@secmarginshook| macro to be applied after +% margins are set. To be sure this hook will be applied only once, +% we release it in the |\NCC@sec@reset@controls| hook. +% \begin{macrocode} +\newcommand*\adjustsectionmargins[2]{% + \NCC@global\def\NCC@secmarginshook{\NCC@adjsecmargins{#1}{#2}} +} +\g@addto@macro\NCC@sec@reset@controls{% + \NCC@global\let\NCC@secmarginshook\@empty +} +\let\NCC@secmarginshook\@empty +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@sec} +% A style of sections having dynamic control is defined by the +% |\NCC@sec|\marg{tag} hook. This hook is applied inside a group +% preparing a heading. All section style commands redefine this hook. +% \end{macro} +% +% \begin{macro}{\newplainsectionstyle} +% |\newplainsectionstyle|\marg{name}\marg{indent}\oarg{pos}\marg{left skip}\marg{right skip} +% \begin{macrocode} +\newcommand*\newplainsectionstyle[2]{% + \@ifnextchar[{\NCC@newplainsec{#1}{#2}}{\NCC@newplainsec{#1}{#2}[l]}% +} +\def\NCC@newplainsec#1#2[#3]#4#5{% + \def\@tempa{#3}\def\@tempb{c}% + \ifx\@tempa\@tempb + \expandafter\newcommand\csname NCC@sec@#1\endcsname + {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}% + \let\\\@centercr \advance\parfillskip -\@flushglue + \setlength\parindent{#2}}}% + \else + \def\@tempb{r}% + \ifx\@tempa\@tempb + \expandafter\newcommand\csname NCC@sec@#1\endcsname + {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}% + \let\\\@centercr \advance\parfillskip -\@flushglue + \advance\parfillskip -\@flushglue + \setlength\parindent{#2}}}% + \else + \expandafter\newcommand\csname NCC@sec@#1\endcsname + {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}\setlength\parindent{#2}}}% + \fi + \fi +} +\@onlypreamble\newplainsectionstyle +\@onlypreamble\NCC@newplainsec +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\newhangsectionstyle} +% |\newhangsectionstyle|\marg{name}\marg{min tag width}\oarg{pos}\marg{left skip}\marg{right skip} +% \begin{macrocode} +\newcommand*\newhangsectionstyle[2]{% + \@ifnextchar[{\NCC@newhangsec{#1}{#2}}{\NCC@newhangsec{#1}{#2}[l]}% +} +\def\NCC@newhangsec#1#2[#3]#4#5{% + \expandafter\newcommand\csname NCC@sec@#1\endcsname + {\def\NCC@sec{\NCC@setsecmargins{#4}{#5}\NCC@hangsecstyle{#2}{#3}}}% +} +\@onlypreamble\newhangsectionstyle +\@onlypreamble\NCC@newhangsec +% \end{macrocode} +% \end{macro} +% +% Specify predefined section styles. The |\@flushglue| is equal to |0pt plus 1fil|. +% \begin{macrocode} +\newhangsectionstyle{hangindent}{\z@}{\z@skip}{\z@skip} +\newhangsectionstyle{hangindent*}{\z@}{\z@skip}{\@flushglue} +\newhangsectionstyle{hangparindent}{\z@}{\parindent}{\z@skip} +\newhangsectionstyle{hangparindent*}{\z@}{\parindent}{\@flushglue} +\newplainsectionstyle{parindent}{\z@}{\parindent}{\z@skip} +\newplainsectionstyle{parindent*}{\z@}{\parindent}{\@flushglue} +\newplainsectionstyle{center}{\z@}[c]{\@flushglue}{\@flushglue} +\newplainsectionstyle{centerlast}{\z@}[c]{\@flushglue}{-\@flushglue} +% \end{macrocode} +% +% \subsection{Make Sections with Dynamic Control} +% +% \begin{macro}{\sectionstyle} +% The |\sectionstyle|\oarg{type}\marg{style} changes a style +% for display sections of the given \meta{type}. +% \begin{macrocode} +\newcommand*{\sectionstyle}[2][]{% + \@ifundefined{NCC@sec@#2}{% + \PackageError{nccsect}{Unknown section style `#2'}{}% + }{% + \expandafter\def\csname NCC@secstyle@#1\endcsname{% + \csname NCC@sec@#2\endcsname + }% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@setsectionstyle} +% The |\NCC@setsectionstyle|\marg{level} set a style for the +% given section level. If a style for the given level is +% undefined, the default style is selected. +% \begin{macrocode} +\def\NCC@setsectionstyle#1{% + \edef\@tempa{NCC@secstyle@\NCC@secname{#1}}% + \@ifundefined{\@tempa}{\NCC@secstyle@}{\csname\@tempa\endcsname}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makesecx} +% The dynamic section making command: +% \begin{quote} +% |\NCC@makesecx|\marg{indent}\marg{style}\marg{heading}\marg{afterskip}\marg{action} +% \end{quote} +% It prepares only display sections and ignores the \meta{indent} parameter. +% \begin{macrocode} +\def\NCC@makesecx#1#2#3#4#5{% + \begingroup\normalfont + \NCC@asecnumset +% \end{macrocode} +% The |\NCC@secxtitle|\marg{style}\marg{tag}\marg{title} hook prepares +% display section with dynamic control. The |\NCC@sec| macro is protected +% to prevent its expansion by |\MakeUppercase|. +% \begin{macrocode} + \NCC@secxtitle{#2}{\protect\NCC@sec{\@svsec}} + {\interlinepenalty \@M\ignorespaces #3\@@par}% + \endgroup #5% + \par \nobreak \vskip #4\relax \@afterheading \ignorespaces +} +\def\NCC@secxtitle#1#2#3{#1{#2#3}} +% \end{macrocode} +% \end{macro} +% +% \subsection{Make the Main Section} +% +% \begin{macro}{\partmark} +% Define the |\partmark| if it is undefined yet. +% \begin{macrocode} +\providecommand*\partmark[1]{\markboth{}{}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@startmainsec} +% The main section is a section of zero level. +% It is prepared with the following command: +% \begin{quote} +% |\NCC@startmainsec|\marg{alignment}\marg{prefix}\marg{beforeskip}\\ +% | |\marg{afterskip}\marg{style} +% \end{quote} +% It starts either a new chapter or a new part depending on the class +% loaded. To decide what version should be prepared, we test the +% |\chapter| command on existence. +% \begin{macrocode} +\@ifundefined{chapter}{% +% \end{macrocode} +% +% The case of an article-like class. Zero-level section is the |\part|. +% \begin{macrocode} + \def\NCC@startmainsec#1#2#3#4#5{% + \NCC@preparesectag{\leavevmode#2}{\partname\nobreakspace}% + \NCC@secskip{#3}% + \secdef{\NCC@part{#1}{#4}{#5}}{\NCC@spart{#1}{#4}{#5}}% + } +% \end{macrocode} +% +% \begin{macro}{\NCC@spart} +% Prepare the starred version of part: +% \begin{quote} +% |\NCC@spart|\marg{alignment}\marg{afterskip}\marg{style}\marg{heading} +% \end{quote} +% \begin{macrocode} + \def\NCC@spart#1#2#3#4{% + \let\@svsec\@empty + \NCC@makepart{#1}{#3}{#4}{#2}{}% + \NCC@sec@reset@controls + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@part} +% Prepare the non-starred version of part: +% \begin{quote} +% |\NCC@part|\marg{alignment}\marg{afterskip}\marg{style}\oarg{toc-entry}\marg{heading} +% \end{quote} +% \begin{macrocode} + \def\NCC@part#1#2#3[#4]#5{% + \def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}% + \NCC@makesection{part}{\z@}{#4}{% + \addcontentsline{toc}{part}{% + \ifnum \c@secnumdepth>\m@ne \numberline{\thepart}\fi + #4% + }% + }% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makepart} +% This command makes a part. +% \begin{quote} +% |\NCC@makepart|\marg{alignment}\marg{style}\marg{heading}\marg{afterskip}\marg{action} +% \end{quote} +% The |\@svsec| is either |\@empty| or contains a part tag. +% \begin{macrocode} + \def\NCC@makepart#1#2#3#4#5{% + \begingroup \normalfont + \NCC@asecnumset + \NCC@makeparttitle{#1}{#2}{#3}% + \endgroup + #5% + \par\nobreak \vskip #4\relax \@afterheading \ignorespaces + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makeparttitle} +% This command makes a part title itself. The |\NCC@secmain| hook contains +% the dynamic alignment style or nothing. +% \begin{quote} +% |\NCC@makeparttitle|\marg{alignment}\marg{style}\marg{heading} +% \end{quote} +% \begin{macrocode} + \def\NCC@makeparttitle#1#2#3{% + \ifx\@svsec\@empty \else + \NCC@secmain#1{\let\NCC@asecnum\@empty\@svsec\@@par}\nobreak + \fi + \interlinepenalty \@M \NCC@secmain#1{#2{#3\@@par}}% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@partsection} +% Define the |\NCC@partsection| to be equal to the |\NCC@mainsection| command +% which will be specified later when a main section will be declared. +% \begin{macrocode} + \def\NCC@partsection{\NCC@mainsection} +}{ +% \end{macrocode} +% \end{macro} +% +% The case of a book-like class. Zero-level section is the |\chapter|. +% \begin{macrocode} + \def\NCC@startmainsec#1#2#3#4#5{% + \NCC@startchap + \NCC@preparesectag{\leavevmode#2}{\@chapapp\nobreakspace}% + \secdef{\NCC@chapter{#1}{#3}{#4}{#5}}{\NCC@schapter{#1}{#3}{#4}{#5}}% + } +% \end{macrocode} +% +% \begin{macro}{\NCC@startchap} +% The start chapter hook: +% \begin{macrocode} + \def\NCC@startchap{% + \if@openright\cleardoublepage\else\clearpage\fi + \thispagestyle{plain}\global\@topnum\z@ + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@schapter} +% Prepare the starred version of chapter: +% \begin{quote} +% |\NCC@schapter|\marg{alignment}\marg{beforeskip}\marg{afterskip}\marg{style}\marg{heading} +% \end{quote} +% \begin{macrocode} + \def\NCC@schapter#1#2#3#4#5{% + \let\@svsec\@empty + \NCC@makechapter{#1}{#2}{#4}{#5}{#3}{}% + \NCC@sec@reset@controls + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@chapter} +% Prepare the non-starred version of chapter: +% \begin{quote} +% |\NCC@chapter|\marg{alignment}\marg{beforeskip}\marg{afterskip}\marg{style}\\ +% | |\oarg{toc-entry}\marg{heading} +% \end{quote} +% It uses the |\NCC@infloats|\marg{action} hook that applies the specified +% action for all registered float types. +% \begin{macrocode} + \def\NCC@chapter#1#2#3#4[#5]#6{% + \@ifundefined{if@mainmatter}{}{\if@mainmatter\else\noheadingtag\fi}% + \def\NCC@make{\NCC@makechapter{#1}{#2}{#4}{#6}{#3}}% + \NCC@makesection{chapter}{\z@}{#5}{% + \typeout{\@chapapp\space\thechapter.}% + \addcontentsline{toc}{chapter}{% + \ifnum \c@secnumdepth>\m@ne + \numberline{\NCC@thetocchapter}\fi + #5% + }% + \NCC@infloats{\addtocontents{\@nameuse{ext@\@captype}}% + {\protect\runinsectionskip}}% + }% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\beforechapter} +% The |\beforechapter|\marg{something} hook is applied to the nearest +% chapter. An empty value of its parameter means no hook. +% \begin{macrocode} + \newcommand\beforechapter[1]{\gdef\NCC@beforechapter{#1}} + \beforechapter{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@thetocchapter} +% The following hook allows redefine the appearance of chapter name +% in the TOC: +% \begin{macrocode} + \def\NCC@thetocchapter{\thechapter} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makechapter} +% This command makes a chapter: +% \begin{quote} +% |\NCC@makechapter|\marg{alignment}\marg{beforeskip}\marg{style}\marg{heading}\\ +% | |\marg{afterskip}\marg{action} +% \end{quote} +% The |\@svsec| is either |\@empty| or contains a chapter tag. +% \begin{macrocode} + \def\NCC@makechapter#1#2#3#4#5#6{% + \if@twocolumn + \@topnewpage[\NCC@makechaphead{#1}{#2}{#3}{#4}{#5}]% + \else + \NCC@makechaphead{#1}{#2}{#3}{#4}{#5}% + \fi + \NCC@makechapfinal{#6}% + \@afterheading + \ignorespaces + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makechapfinal} +% \begin{macro}{\NCC@makechapfinalgobble} +% The |\NCC@makechapfinal| hook applies a final action which can contain the +% |\chaptermark| command. Its default value is to put the parameter as is. +% If you let this command to be equal to the |\NCC@makechapfinalgobble|, the +% chapter mark will contain no chapter name. +% \begin{macrocode} + \let\NCC@makechapfinal\@firstofone + \def\NCC@makechapfinalgobble#1{% + \let\NCC@makechapmark\NCC@makemark + \def\NCC@makemark{% + \let\NCC@temp\@chapapp + \let\@chapapp\@gobble + \NCC@makechapmark + \let\@chapapp\NCC@temp + }% + #1% + } + \@onlypreamble\NCC@makechapfinalgobble +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@makechaphead} +% This command makes a chapter head: +% \begin{quote} +% |\NCC@makechaphead|\marg{alignment}\marg{beforeskip}\marg{style}\marg{heading}\\ +% | |\marg{afterskip} +% \end{quote} +% \begin{macrocode} + \def\NCC@makechaphead#1#2#3#4#5{% + \ifx\NCC@beforechapter\@empty + \StartFromTextArea \vskip #2% + \else + \begingroup + \@twocolumnfalse + \let\NCC@global\@empty + \NCC@sec@reset@controls + \normalfont \NCC@beforechapter \par + \endgroup + \beforechapter{}% + \fi + \begingroup \normalfont + \NCC@asecnumset + \NCC@makechaptitle{#1}{#3}{#4}% + \endgroup + \par\nobreak \vskip #5\relax + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makechaptitle} +% This command makes a chapter title itself: +% \begin{quote} +% |\NCC@makechaptitle|\marg{alignment}\marg{style}\marg{heading} +% \end{quote} +% The |\NCC@secmain| hook contains the dynamic alignment style +% or nothing. +% \begin{macrocode} + \def\NCC@makechaptitle#1#2#3{% + \ifx\@svsec\@empty \else + \NCC@secmain#1{\let\NCC@asecnum\@empty\@svsec\@@par}% + \fi + \interlinepenalty \@M \NCC@secmain#1{#2{#3\@@par}}% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\epigraph} +% \begin{macro}{\epigraphparameters} +% \begin{quote} +% |\epigraph|\oarg{width}\marg{text}\marg{author}\\ +% |\epigraphparameters|\marg{style}\marg{width}\marg{height}\marg{author-style}\\ +% | |\marg{after-action} +% \end{quote} +% \begin{macrocode} + \newcommand*\epigraph[1][\NCC@epigraphwidth]{\NCC@epigraph{#1}} + \newcommand*\epigraphparameters[5]{% + \def\NCC@epigraphwidth{#2}% + \long\def\NCC@epigraph##1##2##3{ + \beforechapter{\def\epigraphwidth{##1}% + #1\par + \NCC@makeepigraph{#3}{##2}{#4{##3}}\par + #5% + }% + }% + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@makeepigraph} +% \begin{quote} +% |\NCC@makeepigraph|\marg{height}\marg{text}\marg{author} +% \end{quote} +% \begin{macrocode} + \long\def\NCC@makeepigraph#1#2#3{% + \@begin@tempboxa\vtop{\setlength{\hsize}{\epigraphwidth}% + \@parboxrestore{#2\@@par}#3\@@par + }% + \setlength\@tempdima{#1}\advance\@tempdima -\totalheight + \ifdim\@tempdima>\z@ + \advance\@tempdima\depth + \dp\@tempboxa\@tempdima + \fi + \leavevmode\box\@tempboxa + \@end@tempboxa + } +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Make Part in Book-like Classes} +% +% \begin{macro}{\NCC@startpart} +% The start-part hook: +% \begin{macrocode} + \def\NCC@startpart{% + \if@openright\cleardoublepage\else\clearpage\fi + \thispagestyle{plain}% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@spart} +% Prepare the starred version of part: +% \begin{quote} +% |\NCC@spart|\marg{before}\marg{after}\marg{style}\marg{heading} +% \end{quote} +% \begin{macrocode} + \def\NCC@spart#1#2#3#4{% + \let\@svsec\@empty + \NCC@makepart{#1}{#3}{#4}{#2}{}% + \NCC@sec@reset@controls + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@part} +% Prepare the non-starred version of part: +% \begin{quote} +% |\NCC@part|\marg{before}\marg{after}\marg{style}\oarg{toc-entry}\marg{heading} +% \end{quote} +% \begin{macrocode} + \def\NCC@part#1#2#3[#4]#5{% + \def\NCC@make{\NCC@makepart{#1}{#3}{#5}{#2}}% + \NCC@makesection{part}{\m@ne}{#4}{% + \addcontentsline{toc}{part}{% + \ifnum \c@secnumdepth>-2 + \numberline{\NCC@thetocpart}\fi + #4% + }% + }% + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@thetocpart} +% The following hook allows redefine the appearance of part name +% in the TOC: +% \begin{macrocode} + \def\NCC@thetocpart{\thepart} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makepart} +% This command makes a part: +% \begin{quote} +% |\NCC@makepart|\marg{before}\marg{style}\marg{heading}\marg{after}\marg{action} +% \end{quote} +% The |\@svsec| is either |\@empty| or contains a part tag. +% \begin{macrocode} + \def\NCC@makepart#1#2#3#4#5{% + \if@twocolumn \onecolumn \@tempswatrue \else \@tempswafalse \fi + \begingroup\normalfont + \NCC@asecnum@ + \NCC@makeparttitle{#1}{#2}{#3}% + \endgroup + \NCC@makepartfinal{#5}#4% + \if@tempswa \twocolumn \fi + } +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makepartfinal} +% \begin{macro}{\NCC@makepartfinalgobble} +% The |\NCC@makepartfinal| hook applies a final action which can contain the +% |\partmark| command. Its default value is to put the parameter as is. +% If you let this command to be equal to the |\NCC@makepartfinalgobble|, the +% chapter mark will contain no chapter name. +% \begin{macrocode} + \let\NCC@makepartfinal\@firstofone + \def\NCC@makepartfinalgobble#1{% + \let\NCC@makepartmark\NCC@makemark + \def\NCC@makemark{% + \let\NCC@temp\partname + \let\partname\@gobble + \NCC@makepartmark + \let\partname\NCC@temp + }% + #1% + } + \@onlypreamble\NCC@makepartfinalgobble +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@makeparttitle} +% This command makes a part title itself: +% \begin{quote} +% |\NCC@makeparttitle|\marg{before}\marg{style}\marg{heading} +% \end{quote} +% \begin{macrocode} + \def\NCC@makeparttitle#1#2#3{#1% + \ifx\@svsec\@empty \else + {\let\NCC@asecnum\@empty\@svsec\@@par}\nobreak \fi + \interlinepenalty \@M #2{#3\@@par} + } +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Make Captions} +% +% \begin{macro}{\CaptionTagSuffix} +% |\CaptionTagSuffix|\marg{suffix} sets a default suffix after caption tag: +% \begin{macrocode} +\newcommand*{\CaptionTagSuffix}[1]{\def\NCC@acapnum{#1}} +\@onlypreamble\CaptionTagSuffix +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\captiontagsuffix} +% |\captiontagsuffix|\oarg{type}\marg{suffix} changes a suffix after caption +% tag. +% \begin{macrocode} +\newcommand*\captiontagsuffix[2][]{% + \NCC@prepare@capkey{suffix}{#1}{\def\NCC@acapnum{#2}}% +} +\let\NCC@capsuffix@\@empty +% \end{macrocode} +% \end{macro} + +% +% \begin{macro}{\captionstyle} +% |\captionstyle|\oarg{type}\marg{style} selects a style to be applied +% to the caption text. Three styles are available now: |default|, |center|, +% and |centerlast|. +% \begin{macrocode} +\newcommand*\captionstyle[1][]{% + \NCC@set@capkey{style}{style}{#1}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\captiontagstyle} +% |\captiontagstyle|\oarg{type}\marg{style} selects a style of caption tag: +% |right| or |para|. +% \begin{macrocode} +\newcommand*\captiontagstyle[1][]{% + \NCC@set@capkey{tag}{tag style}{#1}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\captionwidth} +% The |\captionwidth|\oarg{type}\marg{length} specifies a caption width +% in |\@tempdima|. Default width is |\linewidth|. +% \begin{macrocode} +\newcommand*\captionwidth[2][]{% + \NCC@prepare@capkey{width}{#1}{\setlength{\@tempdima}{#2}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@set@capkey} +% |\NCC@set@capkey|\marg{key}\marg{description}\marg{type}\marg{value} +% \begin{macrocode} +\def\NCC@set@capkey#1#2#3#4{% + \@ifundefined{NCC@makecap#1@#4} + {\PackageError{nccsect}{Unknown caption #2 `#4'}{}% + }{% + \edef\@tempa{\noexpand\NCC@prepare@capkey{#1}{#3}{% + \expandafter\noexpand\csname NCC@makecap#1@#4\endcsname + }% + }% + \@tempa + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@prepare@capkey} +% |\NCC@prepare@capkey|\marg{key}\marg{type}\marg{definition} +% \begin{macrocode} +\def\NCC@prepare@capkey#1#2{% + \def\@tempa{#2}% + \ifx\@tempa\@empty + \ifx\@captype\@undefined \else \let\@tempa\@captype \fi + \fi + \expandafter\def\csname NCC@cap#1@\@tempa\endcsname +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@apply@cap} +% |\NCC@apply@cap|\marg{key} +% \begin{macrocode} +\def\NCC@apply@cap#1{% + \@ifundefined{NCC@cap#1@\@captype}% + {\let\@tempa\@empty}{\let\@tempa\@captype}% + \csname NCC@cap#1@\@tempa\endcsname +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@startcaption} +% This command starts a caption: +% \begin{quote} +% |\NCC@startcaption|\marg{beforeskip}\marg{afterskip}\marg{style} +% \end{quote} +% \begin{macrocode} +\def\NCC@startcaption#1#2#3{% + \secdef{\NCC@caption{#1}{#2}{#3}}{\NCC@scaption{#1}{#2}{#3}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@scaption} +% Starred version of caption: +% \begin{quote} +% |\NCC@scaption|\marg{beforeskip}\marg{afterskip}\marg{style}\marg{text} +% \end{quote} +% \begin{macrocode} +\long\def\NCC@scaption#1#2#3#4{% + \let\@svsec\@empty + \NCC@makecaption{#3}{#1}{#4}{#2}{}% + \NCC@sec@reset@controls +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@caption} +% Non-starred version of caption: +% \begin{quote} +% |\NCC@caption|\marg{beforeskip}\marg{afterskip}\marg{style}\oarg{toc-entry}\marg{text} +% \end{quote} +% \begin{macrocode} +\long\def\NCC@caption#1#2#3[#4]#5{% + \def\NCC@make{\NCC@makecaption{#3}{#1}{#5}{#2}}% + \NCC@makesection{\@captype}{\z@}{#4}{% + \begingroup + \let\centering\@empty + \addcontentsline{\@nameuse{ext@\@captype}}{\@captype}{% + \ifnum \c@secnumdepth>\m@ne + \numberline{\@nameuse{the\@captype}}\fi + #4% + }% + \endgroup + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecaption} +% This command makes a caption: +% \begin{quote} +% |\NCC@makecaption|\marg{style}\marg{beforeskip}\marg{text}\marg{afterskip}\marg{action} +% \end{quote} +% The |\@svsec| is either |\@empty| or contains a caption tag. +% \begin{macrocode} +\long\def\NCC@makecaption#1#2#3#4#5{% + \begingroup\par\normalfont + #1{}\addvspace{#2}\noindent +% \end{macrocode} +% Calculate in |\@tempcnta| caption variants: +% 0~-- no caption, 1~-- caption tag only, 2~-- caption text only, +% 3~-- both caption tag and text are nonempty. +% \begin{macrocode} + \ifx\@svsec\@empty \@tempcnta\z@ \else \@tempcnta\@ne \fi + \def\@tempa{#3}% + \ifx\@tempa\@empty \else \advance\@tempcnta\tw@ \fi +% \end{macrocode} +% Put caption in a parbox aligned at the top line. +% \begin{macrocode} + \ifnum\@tempcnta=\z@ \else + \NCC@apply@cap{suffix}% + \NCC@apply@cap{width}% + \NCC@vtopcap{\@parboxrestore\NCC@apply@cap{tag}{#3}\@@par}\par +% \end{macrocode} +% We avoid insert zero skip after parbox to allow captions of +% side-by-side figures to be aligned at their top line. +% \begin{macrocode} + \setlength\@tempskipa{#4}% + \ifdim\@tempskipa=\z@ \else \vskip \@tempskipa\fi + \fi + \endgroup + #5% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@vtopcap} +% |\NCC@vtopcap|\marg{text} places a text in a vertical +% top-aligned box. Its width is prepared in |\@tempdima| +% before this macro. If its width is greater than the +% |\linewidth|, we allow overlap the box out of line. +% The overlapping directions are calculated from stretches of +% paragraph marginal skips. +% \begin{macrocode} +\def\NCC@vtopcap#1{% + \ifdim\@tempdima>\linewidth + \@tempskipa \leftskip \advance\@tempskipa -1\@tempskipa + \@tempskipb \rightskip \advance\@tempskipb \parfillskip + \advance\@tempskipb -1\@tempskipb + \vtop{\hb@xt@\linewidth{% + \NCC@ifzeroskip\@tempskipa{}{\hss}% + \vtop{\hsize\@tempdima#1}% + \NCC@ifzeroskip\@tempskipb{}{\hss}% + }}% + \else + \vtop{\hsize\@tempdima#1}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@ifzeroskip} +% |\NCC@ifzeroskip|\marg{register}\marg{true-clause}\marg{false-clause} +% executes the \meta{true-clause} if the value of skip register +% is exactly zero skip without stretchability. Otherwise, the +% \meta{false-clause} is executed. +% \begin{macrocode} +\def\NCC@ifzeroskip#1{% + \edef\@tempa{\the#1}\edef\@tempb{\the\z@skip}% + \ifx\@tempa\@tempb + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecaptag@para} +% The |\NCC@makecaptag@para|\marg{text} prepares run-in tag. +% \begin{macrocode} +\long\def\NCC@makecaptag@para#1{% + \ifnum\@tempcnta<\thr@@ \let\NCC@acapnum\@empty\fi + \NCC@apply@cap{style}{{\@svsec}\ignorespaces#1}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecaptag@left} +% The |\NCC@makecaptag@left|\marg{text} prepares flush-left tag. +% \begin{macrocode} +\def\NCC@makecaptag@left{\NCC@separate@captag\raggedright} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecaptag@center} +% The |\NCC@makecaptag@center|\marg{text} prepares centered tag. +% \begin{macrocode} +\def\NCC@makecaptag@center{\NCC@separate@captag\centering} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecaptag@right} +% The |\NCC@makecaptag@right|\marg{text} prepares flush-right tag. +% \begin{macrocode} +\def\NCC@makecaptag@right{\NCC@separate@captag\raggedleft} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@separate@captag} +% The |\NCC@separate@captag|\marg{style}\marg{text} prepares a +% caption tag in a separate line. +% \begin{macrocode} +\long\def\NCC@separate@captag#1#2{% + \ifodd\@tempcnta + {\let\NCC@acapnum\@empty #1\@svsec\@@par}% + \fi + \ifnum\@tempcnta>\@ne + \ifnum\@tempcnta=\thr@@ \vskip .5ex\fi + \NCC@apply@cap{style}{#2}% + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecapstyle@default} +% The |\NCC@makecapstyle@default|\marg{text} prepares caption text +% in default \LaTeX's style. +% \begin{macrocode} +\long\def\NCC@makecapstyle@default#1{% + \setbox\@tempboxa\vtop{\hsize\linewidth\@parboxrestore#1\@@par}% + \ifdim\dp\@tempboxa<\baselineskip \centering#1% + \else \box\@tempboxa \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecapstyle@para} +% The |\NCC@makecapstyle@para|\marg{text} prepares ordinary caption. +% \begin{macrocode} +\long\def\NCC@makecapstyle@para#1{#1} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecapstyle@left} +% The |\NCC@makecapstyle@left|\marg{text} prepares flush-left caption. +% \begin{macrocode} +\long\def\NCC@makecapstyle@left#1{\raggedright#1} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecapstyle@right} +% The |\NCC@makecapstyle@right|\marg{text} prepares flush-right caption. +% \begin{macrocode} +\long\def\NCC@makecapstyle@right#1{\raggedleft#1} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecapstyle@center} +% The |\NCC@makecapstyle@center|\marg{text} prepares centered caption. +% \begin{macrocode} +\long\def\NCC@makecapstyle@center#1{\centering#1} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@makecapstyle@centerlast} +% The |\NCC@makecapstyle@centerlast|\marg{text} prepares caption with +% last line centered. +% \begin{macrocode} +\long\def\NCC@makecapstyle@centerlast#1{% + \leftskip\@flushglue \rightskip -\@flushglue + \parfillskip\z@\@plus 2fil\relax#1% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\RegisterFloatType} +% The |\RegisterFloatType|\marg{type} command registers a float type: +% \begin{macrocode} +\newcommand*{\RegisterFloatType}[1]{% + \edef\NCC@floatlist{\NCC@floatlist{#1}}% +} +\let\NCC@floatlist\@empty +\@onlypreamble\RegisterFloatType +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@infloats} +% The |\NCC@infloats|\marg{action} command applies the given \meta{action} +% to all registered float types. During the cycle, +% the |\@captype| contains a name of float and +% the |\@tempcnta| is equal to its registration number +% (1~for the figure float, 2~for the table float, and so on). +% \begin{macrocode} +\def\NCC@infloats#1{% + \@tempcnta\z@ + \let\NCC@temp \@captype + \expandafter \@tfor \expandafter \@captype + \expandafter :\expandafter =\NCC@floatlist \do + {\advance\@tempcnta\@ne #1}% + \let\@captype\NCC@temp +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Declare Sections and Captions} +% +% \begin{macro}{\DeclareSection} +% Now we can implement the |\DeclareSection| command. +% It generates: +% \begin{desclist}{}{} +% \item[\cs{NCC@mainsection}] command if \meta{level} = 0; +% \item[\cs{NCC@section}\meta{level-in-roman}] command if \meta{level} $>$ 0; +% \item[\cs{NCC@cap@}\meta{float-type}] command if \meta{level} $<$ 0. +% \end{desclist} +% \begin{macrocode} +\newcommand{\DeclareSection}{\@ifstar{\NCC@dsecx}{\NCC@dsec}} +\def\NCC@dsec#1#2{% + \@ifnextchar[{\NCC@dsect{#1}{#2}}{\NCC@dsect{#1}{#2}[\z@skip]}% +} +\@onlypreamble\DeclareSection +\@onlypreamble\NCC@dsec +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@dsect} +% The non-starred version of section declaration command +% prepares display sections with traditional formatting: +% \begin{quote} +% |\NCC@dsect|\marg{level}\marg{type}\oarg{indent}\marg{prefix}\marg{beforeskip}\\ +% | |\marg{afterskip}\marg{style} +% \end{quote} +% It is also used for generation of run-in sections +% and captions. +% \begin{macrocode} +\def\NCC@dsect#1#2[#3]#4#5#6#7{% + \ifnum#1>\z@ + \expandafter\def\csname NCC@section\romannumeral#1\endcsname{% + \NCC@setsectionsuffix{#1}% + \NCC@preparesectag{#4}{}% + \let\NCC@makesec\NCC@makesect + \NCC@startsection{#2}{#1}{#3}{#5}{#6}{#7}}% + \else + \ifnum#1=\z@ + \def\NCC@mainsection{% + \NCC@setsectionsuffix\z@ + \let\NCC@secmain\@empty +% \end{macrocode} +% The empty |\NCC@secmain| means standard alignment of main section +% \begin{macrocode} + \NCC@startmainsec{% + \NCC@hangfrom{\hskip #3}\NCC@adjsecmargins{}\@flushglue + \ignorespaces}% + {#4}{#5}{#6}{#7}% + }% + \else + \NCC@dsecf{#2}{#4}{#5}{#6}{#7}% + \fi + \fi +} +\@onlypreamble\NCC@dsect +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@dsecx} +% The starred version of section declaration command +% prepares display sections with dynamic formatting: +% \begin{quote} +% |\NCC@dsecx|\marg{level}\marg{type}\marg{prefix}\marg{beforeskip}\marg{afterskip}\marg{style} +% \end{quote} +% It can also be used for generation of captions. +% \begin{macrocode} +\def\NCC@dsecx#1#2#3#4#5#6{% + \ifnum#1>\z@ + \expandafter\def\csname NCC@section\romannumeral#1\endcsname{% + \NCC@setsectionsuffix{#1}% + \NCC@setsectionstyle{#1}% + \NCC@preparesectag{#3}{}% + \let\NCC@makesec\NCC@makesecx + \NCC@startsection{#2}{#1}{\z@}{#4}{#5}{#6}}% + \else + \ifnum#1=\z@ +% \end{macrocode} +% The non-empty |\NCC@secmain| hook means the dynamic alignment. +% We also redefine the dynamic section style |\NCC@sec| in such a way that the +% right skip stretchability will be |1fil| if the section style has +% no flush glue. +% \begin{macrocode} + \def\NCC@mainsection{% + \NCC@setsectionsuffix\z@ + \NCC@setsectionstyle\z@ + \let\NCC@secsave\NCC@sec \let\NCC@sec\NCC@secflush + \def\NCC@secmain{\protect\NCC@sec{}}% + \NCC@startmainsec{}{#3}{#4}{#5}{#6}% + }% + \else + \NCC@dsecf{#2}{#3}{#4}{#5}{#6}% + \fi + \fi +} +\@onlypreamble\NCC@dsecx +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@secflush} +% |\NCC@secflush|\marg{tag} applies a section style saved in the +% |\NCC@secsave| macro and adjusts |\rightskip| and |\parfillskip| +% if the left and right margins have no stretchability in sum. +% \begin{macrocode} +\def\NCC@secflush#1{\NCC@secsave{#1}% + \@tempskipa\leftskip \advance\@tempskipa\rightskip + \advance\@tempskipa -1\@tempskipa +% \end{macrocode} +% There are three general cases in which the +% correction of right margin is required: +% \begin{center}\small\catcode`|=12 +% \begin{tabular}{|l|c|c|c|}\hline +% \tc{\cbox{Case}} & \cbox{\tt\string\leftskip} & \cbox{\tt\string\rightskip} +% & \cbox{\tt\string\parfillskip} \\\hline +% \Strut/.7/ +% Left last &\tt x &\tt y &\tt 0pt plus 1fil \\ +% Center last &\tt x plus 1fil &\tt y plus -1fil &\tt 0pt plus 2fil \\ +% Right last &\tt x plus 1fil &\tt y plus -1fil &\tt 0pt plus 1fil \\\hline +% \end{tabular} +% \end{center} +% In all these cases the correction is simple: we need to add |\parfillskip| +% to the |\rightskip| and set |\parfillskip| to zero. +% \begin{macrocode} + \NCC@ifzeroskip\@tempskipa{% + \advance\rightskip \parfillskip \parfillskip \z@skip + }{}% + \ignorespaces +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@dsecf} +% This command declares captions of floats: +% \begin{quote} +% |\NCC@dsecf|\marg{type}\marg{prefix}\marg{beforeskip}\marg{afterskip}\marg{style} +% \end{quote} +% \begin{macrocode} +\def\NCC@dsecf#1#2#3#4#5{% + \expandafter\def\csname NCC@cap@#1\endcsname{% + \def\NCC@makesectag####1{#2{\csname #1name\endcsname}% + \nobreakspace####1\NCC@acapnum}% + \NCC@startcaption{#3}{#4}{#5}% + }% +} +\@onlypreamble\NCC@dsectf +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DeclarePart} +% In book-like classes, a part is declared in a special way: +% \begin{quote} +% |\DeclarePart|\marg{before}\marg{after}\marg{prefix}\marg{style} +% \end{quote} +% Long parameters are allowed in this declaration. +% \begin{macrocode} +\@ifundefined{chapter}{}{% + \newcommand\DeclarePart[4]{% + \def\NCC@partsection{% + \NCC@startpart + \NCC@preparesectag{\leavevmode#3}{\partname\nobreakspace}% + \secdef{\NCC@part{#1}{#2}{#4}}{\NCC@spart{#1}{#2}{#4}}% + }% + } + \@onlypreamble\DeclarePart +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Caption Patches} +% +% \begin{macro}{\@makecaption} +% We emulate here the |\@makecaption{\fnum@|\meta{type}|}|\marg{caption} +% command to provide the compatibility with packages using it. +% It calls the |\NCC@cap@|\meta{type} command using the type specified +% in |\@captype| command. The counter is already stepped +% before this command and all necessary things are written +% to aux. Therefore, we turn off writing to aux and decrease a value of +% the float counter by |-1| because it will be stepped within again. +% \begin{macrocode} +\long\def\@makecaption#1#2{% + \begingroup + \skipwritingtoaux + \addtocounter\@captype\m@ne + \csname NCC@cap@\@captype\endcsname[]{#2}% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% Add patch to the \textbf{supertabular} package: +% \begin{macrocode} +\AfterPackage{supertabular}{% + \long\def\ST@caption#1[#2]#3{\par% + \addcontentsline{\csname ext@#1\endcsname}{#1}% + {\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% + \begingroup\centering + \def\@captype{#1}% + \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par + \endgroup + } +} +% \end{macrocode} +% +% Add patch to the \textbf{xtab} package: +% \begin{macrocode} +\AfterPackage{xtab}{% + \long\def\ST@caption#1[#2]#3{\par% + \@initisotab + \addcontentsline{\csname ext@#1\endcsname}{#1}% + {\numberline{\csname the#1\endcsname}{\ignorespaces #2}}% + \begingroup\centering + \def\@captype{#1}% + \@makecaption{\csname fnum@#1\endcsname}{\ignorespaces #3}\par + \endgroup + \global\advance\ST@pageleft -\PWSTcapht + \ST@trace\tw@{Added caption. Space left for xtabular: \the\ST@pageleft}% + } +} +% \end{macrocode} +% +% Add patch to the \textbf{longtable} package: +% \begin{macrocode} +\AfterPackage{longtable}{% + \def\LT@makecaption#1#2#3{% + \LT@mcol\LT@cols c{\hbox to\z@{\hss + \parbox[t]\LTcapwidth{\centering\def\@captype{table}% + \ifx#1\@gobble \NCC@cap@table*{#3}% + \else \@makecaption{\fnum@table}{#3}% + \fi + }% + \hss + }}% + } +} +% \end{macrocode} +% +% \subsection{Declare TOC-Entries} +% +% \begin{macro}{\DeclareTOCEntry} +% The toc-entries declaration command: +% \begin{quote} +% |\DeclareTOCEntry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\ +% | |\marg{style}\oarg{next} +% \end{quote} +% \begin{macrocode} +\newcommand*{\DeclareTOCEntry}[5]{% + \@ifnextchar[{\NCC@dtoc{#1}{#2}{#3}{#4}{#5}}% + {\NCC@dtoc{#1}{#2}{#3}{#4}{#5}[\NCC@nexttocnum{#3}{#4}]}% +} +\def\NCC@dtoc#1#2#3#4#5[#6]{% +% \end{macrocode} +% Declare a toc-entry command for a registered float. +% We scan the registration list and find the necessary +% float type comparing its registration number with the negation +% of level. The generated command is |\l@|\meta{float-type}: +% \begin{macrocode} + \ifnum#1<\z@ + \@tempswatrue + \NCC@infloats{% + \ifnum#1=-\@tempcnta + \expandafter\def\csname l@\@captype\endcsname + {\NCC@tocentry\z@{#2}{#3}{#4}{#5}}% + \@tempswafalse + \@break@tfor + \fi + }% +% \end{macrocode} +% Incorrect level number. Generate an error. +% \begin{macrocode} + \if@tempswa + \@tempcnta#1\relax + \@tempcnta -\@tempcnta + \PackageError{nccsect}% + {Float type registration number \the\@tempcnta\space + is out of range}{}% + \fi + \else +% \end{macrocode} +% Prepare in |\@tempa| a command name: |\l@section| or |\l@subsection| +% or \ldots\ or |\l@subparagraph| or |\l@section@vi| or \ldots: +% \begin{macrocode} + \ifnum#1>\z@ + \edef\@tempa{\noexpand\def\expandafter\noexpand + \csname l@\NCC@secname{#1}\endcsname}% +% \end{macrocode} +% or |\l@part| or |\l@chapter|: +% \begin{macrocode} + \else + \@ifundefined{chapter}{\def\@tempa{\def\l@part}}% + {\def\@tempa{\def\l@chapter}}% + \fi +% \end{macrocode} +% Declare the toc-entry: +% \begin{macrocode} + \@tempa{\NCC@tocentry{#1}{#2}{#3}{#4}{#5}}% +% \end{macrocode} +% Prepare in the |\l@tocskip@|\meta{next-level-in-roman} command +% the left margin adjustment command. The +% |\NCC@tocnumprototype|\marg{style}\marg{prototype} hook +% applies a style to the prototype of toc-entry number. +% \begin{macrocode} + \@tempcnta #1\relax \advance\@tempcnta\@ne + \expandafter\def\csname l@tocskip@\romannumeral\@tempcnta + \endcsname{\NCC@tocadj{\NCC@tocnumprototype{#5}{#6}}}% + \fi +} +\@onlypreamble\DeclareTOCEntry +\@onlypreamble\NCC@dtoc +\def\NCC@nexttocnum#1#2{#1#2\NCC@atocnum} +\def\NCC@tocnumprototype#1#2{\let\applystyle\@firstoftwo#1{#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@tocadj} +% The command increases |\@tempdimb| on the width of the argument: +% \begin{macrocode} +\def\NCC@tocadj#1{% + \settowidth\@tempdima{\let\NCC@atocdo\@firstoftwo#1}% + \advance\@tempdimb\@tempdima +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\DeclareTOCPart} +% Part toc-entry declaration in book-like classes. If optional +% \meta{afterskip} is omitted, the default |\NCC@runskip| value +% is applied after this entry. +% \begin{quote} +% |\DeclareTOCPart|\marg{action}\oarg{afterskip}\marg{prefix}\marg{prototype}\marg{style} +% \end{quote} +% \begin{macrocode} +\@ifundefined{chapter}{}{% + \newcommand*\DeclareTOCPart[1]{% + \@ifnextchar[{\NCC@dtocpart{#1}}{\NCC@dtocpart{#1}[\NCC@runskip]}% + } + \def\NCC@dtocpart#1[#2]#3#4#5{% + \def\l@part##1##2{% + \NCC@tocentry{-1}{% +% \end{macrocode} +% We temporary add |1fil| to the toc right margin to prepare +% a ragged right toc-entry. +% \begin{macrocode} + \TOCMarginDrift{1fil}% +% \end{macrocode} +% Breaks before part are preferred. +% \begin{macrocode} + \addpenalty{-\@highpenalty}#1% + }{#3}{#4}{#5}{##1}{\hss##2}% + \nobreak \vskip #2\relax + \@nobreaktrue + \everypar{\@nobreakfalse\everypar{}}% + }% + } + \@onlypreamble\DeclareTOCPart + \@onlypreamble\NCC@dtocpart +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@tocentry} +% This command makes a toc-entry: +% \begin{quote} +% |\NCC@tocentry|\marg{level}\marg{action}\marg{prefix}\marg{prototype}\\ +% | |\marg{style}\marg{entry}\marg{page-number} +% \end{quote} +% \begin{macrocode} +\def\NCC@tocentry#1#2#3#4#5#6#7{% + \ifnum #1>\c@tocdepth \else + \par\begingroup\normalfont #2% + \let\applystyle\@firstoftwo +% \end{macrocode} +% Calculate the left margin in the |\@tempdimb| register +% applying the |\l@tocskip@i|, \ldots, |\l@tocskip@|\meta{level-in-roman} +% commands: +% \begin{macrocode} + \@tempdimb\z@ \@tempcnta #1\relax + \@whilenum \@tempcnta >\z@\do + {\@nameuse{l@tocskip@\romannumeral \@tempcnta}% + \advance\@tempcnta\m@ne}% +% \end{macrocode} +% The |\NCC@preparetocnum|\marg{style}\marg{prefix} hook prepares +% the |\NCC@maketocnum|\marg{tag} command creating +% a number-line tag: +% \begin{macrocode} + \NCC@preparetocnum{#5}{#3}% +% \end{macrocode} +% Calculate the hang indent value in |\@tempdima|: +% \begin{macrocode} + \settowidth\@tempdima{\let\NCC@atocdo\@firstoftwo\NCC@maketocnum{#4}}% +% \end{macrocode} +% Produce the toc-entry. The |\NCC@tocentrytitle|\marg{style}\marg{title} +% hook applies the style to the toc-entry title. +% \begin{macrocode} + \@dottedtocline{#1}{\@tempdimb}{\@tempdima}% + {\let\NCC@atocdo\@secondoftwo\NCC@tocentrytitle{#5}{#6\unskip}}% + {\let\applystyle\@secondoftwo#5{#7}}% +% \end{macrocode} +% Allow break after toc-entry: +% \begin{macrocode} + \@nobreakfalse + \endgroup + \fi +} +\def\NCC@preparetocnum#1#2{% + \def\NCC@maketocnum##1{\NCC@atocdo{#1}{}{#2##1\NCC@atocnum}}% +} +\def\NCC@tocentrytitle#1#2{#1{\ignorespaces#2}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\numberline} +% Redefine the |\numberline|\marg{tag} command to work correct +% if the width of tag is greater than |\@tempdima|. The +% tag is prepared with the |\NCC@maketocnum|\marg{tag} command. +% \begin{macrocode} +\DeclareRobustCommand*\numberline[1]{% + \setbox\@tempboxa\hbox{\NCC@maketocnum{#1}}% + \ifdim \wd\@tempboxa > \@tempdima + \box\@tempboxa + \else + \hb@xt@\@tempdima{\unhbox\@tempboxa\hfil}% + \fi + \ignorespaces +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@maketocnum} +% The default implementation of the |\NCC@maketocnum|\marg{tag} command. +% We must define it because the |\numberline| command must +% work out of scope of toc-entries. +% \begin{macrocode} +\def\NCC@maketocnum#1{#1\NCC@atocnum} +\let\NCC@atocdo\@secondoftwo +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NumberlineSuffix} +% The |\NumberlineSuffix|\marg{calc-suffix}\marg{actual-suffix} +% command saves suffices inserted after number tag in the |\numberline| +% command. It saves it in the |\NCC@atocnum| hook as parameters of +% |\NCC@atocdo| command. Letting the last one to |\@firstoftwo| or +% |\@secondoftwo|, we select the \meta{calc-suffix} or \meta{actual-suffix} +% respectively. +% \begin{macrocode} +\newcommand*{\NumberlineSuffix}[2]{\def\NCC@atocnum{\NCC@atocdo{#1}{#2}}} +\@onlypreamble\NumberlineSuffix +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\TOCMarginDrift} +% The |\TOCMarginDrift|\marg{drift} specifies allowed drift of right margin +% in TOC. +% \begin{macrocode} +\newcommand*\TOCMarginDrift[1]{% + \def\@tempa{#1}% + \ifx\@tempa\@empty \let\NCC@tocdrift\@empty + \else \def\NCC@tocdrift{\@plus #1\relax}\fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\PnumPrototype} +% The |\PnumPrototype|\marg{prototype} command saves the page number +% prototype in the |\NCC@pnum| hook and applies the |\NCC@setpnum| +% command. +% \begin{macrocode} +\newcommand*{\PnumPrototype}[1]{\def\NCC@pnum{#1}\NCC@setpnum} +\@onlypreamble\PnumPrototype +\def\NCC@setpnum{% + \settowidth\@tempdima{\NCC@pnum}% + \edef\@pnumwidth{\the\@tempdima}% + \advance\@tempdima 1em + \edef\@tocrmarg{\the\@tempdima \noexpand\NCC@tocdrift}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\SetTOCStyle} +% The toc-style hook is embedded into the |\@starttoc| command. +% We also recalculate the page number prototype and update +% margins when a toc starts. +% \begin{macrocode} +\newcommand*{\SetTOCStyle}[1]{\def\NCC@tocstyle{#1}} +\@onlypreamble\SetTOCStyle +\let\NCC@latexstarttoc\@starttoc +\def\@starttoc#1{% + \begingroup + \normalfont \NCC@tocstyle \NCC@setpnum + \NCC@latexstarttoc{#1}% + \endgroup +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Service and Defaults} +% +% \begin{macro}{\StartFromTextArea} +% \begin{macro}{\StartFromHeaderArea} +% These commands are applied at the beginning of page +% to set current position exactly at the first line +% of text area or at the header line, respectively. +% Both these commands are defined in two packages: in this one and in +% the \textbf{textarea}. To be sure that the commands are specified +% in these packages only, we mutually test packages to be loaded. +% \begin{macrocode} +\@ifpackageloaded{textarea}{}{% + \newcommand\StartFromTextArea{\par + {\parskip\z@ \strut\par}\vskip -\baselineskip + } + \newcommand\StartFromHeaderArea{% + \StartFromTextArea + \vskip -\headsep \vskip -\ht\strutbox + } +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\bff} +% The |\bff| command tries to set everything bold. +% \begin{macrocode} +\newcommand{\bff}{\normalfont\bfseries\mathversion{bold}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\aftersectionvspace} +% This command eliminates a vertical space inserted after a previous +% section and inserts a vertical space specified. +% \begin{macrocode} +\newcommand*\aftersectionvspace[1]{% + \ifvmode \if@nobreak + \vskip -\lastskip \vskip #1\relax + \fi \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\startsection} +% Define the |\startsection| command. In article-class, +% both zero and negative levels refer to the same part section. +% \begin{macrocode} +\newcommand*{\startsection}[1]{% + \ifnum#1>\z@ + \def\@tempa{\csname NCC@section\romannumeral#1\endcsname}% + \else + \ifnum#1=\z@ + \def\@tempa{\NCC@mainsection}% + \else + \def\@tempa{\NCC@partsection}% + \fi + \fi + \@tempa +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\part} +% \begin{macro}{\section} +% \begin{macro}{\subsection} +% \begin{macro}{\subsubsection} +% \begin{macro}{\paragraph} +% \begin{macro}{\subparagraph} +% Set aliases for almost all section levels, except chapter. +% The part is called here as a section of a negative level. +% \begin{macrocode} +\def\part{\startsection\m@ne} +\def\section{\startsection\@ne} +\def\subsection{\startsection\tw@} +\def\subsubsection{\startsection\thr@@} +\def\paragraph{\startsection4} +\def\subparagraph{\startsection5} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\caption} +% Redefine the |\caption| command. We do this at the beginning +% of document to reject possible redefinitions of captions +% in other packages such as |float|. I think this is not the +% |float|'s responsibility to decide where a caption must go on: +% before or after the float body. And what about complicated +% floats consisting of side floats and etc.? We also reset to zero +% the |\abovecaptionskip| and |\belowcaptionskip| registers if they +% are specified to provide partial compatibility with the |float| +% package. If the registers are not specified (as in |ncc| class), +% they are emulated with macros. +% \begin{macrocode} +\AtBeginDocument{% + \def\caption{% + \ifx\@captype\@undefined + \@latex@error{\noexpand\caption outside float}\@ehd + \expandafter\@gobble + \else + \expandafter\@firstofone + \fi + {\csname NCC@cap@\@captype\endcsname}% + }% + \@ifundefined{abovecaptionskip}{\def\abovecaptionskip{\z@}}% + {\abovecaptionskip\z@}% + \@ifundefined{belowcaptionskip}{\def\belowcaptionskip{\z@}}% + {\belowcaptionskip\z@}% +} +% \end{macrocode} +% \end{macro} +% +% Registration of standard floats: +% \begin{macrocode} +\RegisterFloatType{figure} +\RegisterFloatType{table} +% \end{macrocode} +% +% Declare all sections and captions except the part and chapter: +% \begin{macrocode} +\DeclareSection{-2}{table}{}{\z@}{10pt}{} +\DeclareSection{-1}{figure}{}{10pt}{\z@}{} +\DeclareSection*1{section}{}% + {3.5ex \@plus 1ex \@minus .2ex}% + {2.3ex \@plus .2ex}{\Large\bff} +\DeclareSection*2{subsection}{}% + {3.25ex \@plus 1ex \@minus .2ex}% + {1.5ex \@plus .2ex}{\large\bff} +\DeclareSection*3{subsubsection}{}% + {3ex \@plus 1ex \@minus .2ex}% + {1.5ex \@plus .2ex}{\normalsize\bff} +\DeclareSection4{paragraph}{}% + {\NCC@runskip}{-1em}{\normalsize\bff} +\DeclareSection5{subparagraph}[\parindent]{}% + {\NCC@runskip}{-1em}{\normalsize\bff} +\@ifundefined{chapter}{ +% \end{macrocode} +% +% Declare the part and toc-entries for the article-like style: +% \begin{macrocode} + \DeclareSection*0{part}{\Large\bff}% + {5ex \@plus 1ex \@minus .2ex}% + {4ex \@plus .2ex}{\huge\bff} + \DeclareTOCEntry{-2}{}{}{9}{}% table + \DeclareTOCEntry{-1}{}{}{9}{}% figure + \DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}}{}{III}{\bff}[] + \DeclareTOCEntry1{\runinsectionskip}{}{9}{} + \DeclareTOCEntry2{}{}{9.9}{} + \DeclareTOCEntry3{}{}{9.9.9}{} +}{ +% \end{macrocode} +% +% \begin{macro}{\ChapterPrefixStyle} +% Specify the appearance of chapter prefix in the toc and the header. +% \begin{macrocode} + \newcommand*{\ChapterPrefixStyle}[1]{% + \def\NCC@thetocchapter{\thechapter}% + \let\NCC@makechapfinal\NCC@makechapfinalgobble + \@for\@tempa:=#1\do{% + \@ifundefined{NCC@chapin@\@tempa}{% + \PackageError{nccsect}{Unknown style `\@tempa'\MessageBreak + Only the `toc' and `header' styles are allowed}{}% + }{\csname NCC@chapin@\@tempa\endcsname}% + }% + } + \def\NCC@chapin@toc{\def\NCC@thetocchapter{\@chapapp\ \thechapter}} + \def\NCC@chapin@header{\let\NCC@makechapfinal\@firstofone} + \@onlypreamble\ChapterPrefixStyle + \@onlypreamble\NCC@chapin@toc + \@onlypreamble\NCC@chapin@header +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\chapter} +% Declare the part, the chapter, toc-entries for the +% book-like style, and specify default epigraph parameters: +% \begin{macrocode} + \def\chapter{\startsection\z@} + \DeclarePart{\StartFromTextArea\vfil\centering}% + {\vfil\newpage \if@twoside\if@openright + \mbox{}\thispagestyle{empty}\newpage\fi\fi}% + {\vspace{4ex}\huge\bff}{\Huge\bff} + \DeclareSection*0{chapter}{\vspace{3ex}\huge\bff}{10ex}% + {8ex \@plus .2ex}{\Huge\bff} + \DeclareTOCEntry{-2}{}{}{9.9}{}% table + \DeclareTOCEntry{-1}{}{}{9.9}{}% figure + \DeclareTOCPart{\NCC@secskip{4ex \@plus .2ex}\def\@dotsep{1000}} + {}{II}{\large\bff} + \DeclareTOCEntry0{\runinsectionskip\def\@dotsep{1000}% + \aftergroup\penalty\aftergroup\@highpenalty}{}{9}{\bff} + \DeclareTOCEntry1{}{}{9.9}{}[9.9] + \DeclareTOCEntry2{}{}{9.9.9}{}[9.9.9] + \DeclareTOCEntry3{}{}{}{}[\qquad] + \epigraphparameters{\StartFromHeaderArea\small\raggedleft}% + {.45\linewidth}{5\baselineskip}% + {\raggedleft\itshape}{\vspace{2ex}} +} +% \end{macrocode} +% \end{macro} +% +% Declare other toc-entries: +% \begin{macrocode} +\DeclareTOCEntry4{}{}{}{}[\qquad] +\DeclareTOCEntry5{}{}{}{}[\qquad] +% \end{macrocode} +% +% Set defaults: +% \begin{macrocode} +\noindentaftersection +\sectionstyle{hangindent} +\SectionTagSuffix{\quad} +\RunningSectionSuffix{} +\captionwidth{\linewidth} +\captionstyle{default} +\captiontagstyle{para} +\CaptionTagSuffix{:\hskip .7em \@plus .2em \@minus .1em} +\NumberlineSuffix{\quad}{\enskip} +\PnumPrototype{99} +\TOCMarginDrift{} +\SetTOCStyle{} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccstretch.dtx b/macros/latex/contrib/ncctools/source/nccstretch.dtx new file mode 100644 index 0000000000..f4d53ea7e3 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccstretch.dtx @@ -0,0 +1,75 @@ +% \iffalse +%% +%% File: nccstretch.dtx Copyright (C) 2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccstretch} +% [2004/11/30 v1.0 Text Stretch Package (NCC)] +% +% \changes{v1.0}{2004/11/30}{This version was uploaded to CTAN} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{nccstretch} +\GetFileInfo{nccstretch.sty} +\begin{document} +\title{The \textsf{nccstretch} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccstretch.dtx} +\end{document} +% +% \fi +% \section{User Interface} +% +% \DescribeMacro{\stretchwith} +% The package implements the command +% \begin{quote} +% |\stretchwith|\marg{foo}\marg{text} +% \end{quote} +% that stretches the \meta{text} parameter inserting the +% \meta{foo} sequence between every pair of neighbour tokens of +% the \meta{text}. Spaces in the text are ignored. So, to save +% a space, you need to insert a backslash before it or enclose +% a space in braces. If you do not want to insert \meta{foo} +% between some tokens, enclose them in braces. While stretching, +% all first-level braces are removed. The examples below +% show some use cases (we delimit the results with rules to show +% exactly how the command works): +% \begin{center}\small% +% \newcommand*\ruled[1]{\rule{.4pt}{2ex}#1\rule{.4pt}{2ex}}% +% \begin{tabular}{@{}l@{\qquad}l@{}} +% \textbf{Command} & \textbf{Result}\\ +% |\stretchwith{\,}{Proof\ of\ Theorem\ 1}| & +% \ruled{\stretchwith{\,}{Proof\ of\ Theorem\ 1}}\\ +% |\stretchwith{.}{\ test{ }test{}\ \ {test}{\"e}}| & +% \ruled{\stretchwith{.}{\ test{ }test{}\ \ {test}{\"e}}}\\ +% |\makebox[1.5\width]{\stretchwith{\hfill}{test\ test}}| & +% \ruled{\makebox[1.5\width]{\stretchwith{\hfill}{test\ test}}} +% \end{tabular} +% \end{center} +% \StopEventually{} +% +% \section{The Implementation} +% \begin{macro}{\stretchwith} +% The command is implemented using |\@tfor| cycle. +% The |\@tempa| command contains a sequence to be inserted +% before the next token. It is set to |\relax| before the +% cycle and is set to \meta{foo} after every inserted token. +% This trick allows insert \meta{foo} \textbf{between} +% neighbour tokens only. +% \begin{macrocode} +%<*package> +\newcommand*\stretchwith[2]{% + \let\@tempa\relax + \def\@tempb{#1}% + \@tfor\@tempc:=#2\do {\@tempa \@tempc \let\@tempa\@tempb}% +} +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/nccthm.dtx b/macros/latex/contrib/ncctools/source/nccthm.dtx new file mode 100644 index 0000000000..deb6b6ac1b --- /dev/null +++ b/macros/latex/contrib/ncctools/source/nccthm.dtx @@ -0,0 +1,1111 @@ +% \iffalse +%% +%% File: nccthm.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{nccthm} +% [2004/12/16 v1.1 NCC Extention to Theorems (NCC)] +% +% \changes{v1.02}{2002/01/31}{This version is uploaded to CTAN} +% \changes{v1.03}{2002/02/17}{Break mode is turned off globally} +% \changes{v1.04}{2002/05/19}{An extra group added in theorem headers +% to scope font changes} +% \changes{v1.05}{2002/06/07}{Bug in referencing in APAR mode fixed} +% \changes{v1.06}{2003/01/13}{Spaces after label are ignored now} +% \changes{v1.07}{2004/04/08}{Improvements in interpreting spaces after label} +% \changes{v1.1}{2004/12/16}{In apar mode, ignore indent option if margin option used} +% \changes{v1.1}{2004/12/16}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{desclist} +\usepackage[blackqed,whiteqed]{nccthm} +\countstyle[apar]{section} +\newtheorem{theorem}{Theorem} +\newtheorem*{atheorem}{Theorem} +\TheoremBreakStyle +\newtheorem{definition}{Definition}[remark] +\TheoremNoBreakStyle +\newtheorem{lemma}[theorem]{Lemma} +\newcommand\Line{\qef\hrule height .4pt width \linewidth\nobreak + \qef} +\GetFileInfo{nccthm.sty} +\begin{document} +\title{The \textsf{nccthm} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{nccthm.dtx} +\end{document} +% +% \fi +% +% \tableofcontents +% +% \section{Overview} +% +% This is yet another extension of the \LaTeX\ theorem making +% environment. Further, we'll call the \textit{theorem} +% any mathematical statement consisting of one or more paragraphs, +% and starting with a header containing an optional number. +% A theorem is set off from the main text with an extra space. +% Its title and body are often emphasized with a font change. +% +% In comparison with the |theorem| package by Frank Mittelbach and the +% |amsthm| package by American Mathematical Society, the +% |nccthm| package is distinct in the following: +% +% \paragraph{1} All new theorem environments generated with the +% |nccthm| package use the \textit{dynamic counters} (see |dcounter| +% package from this bungle for more details). As a result, this allows +% a package writer to generate predefined theorems +% and do not think on how they will be numbered, because the +% decision is later made by a user. +% For example, if you want all theorems to have enumeration +% subordinated to sections, you need to write down the command +% \begin{quote} +% |\countstyle{section}| +% \end{quote} +% in the preamble. In this case, counters of all new theorems will be +% set to zero at the beginning of every section and their enumeration +% will be composed from the section number and the theorem counter number +% itself. You can also change a enumeration style for concrete +% counters (not only for dynamic counters) with the |\countstyle| +% command specifying the list of counters in its optional parameter. +% For example, if you prepare a book and want to subordinate +% the equation and table counters to sections (they are subordinated to +% chapters by default), write down in the preamble the following +% \begin{quote} +% |\countstyle[equation,table]{section}| +% \end{quote} +% The last example: to make a plain enumeration of sections +% and reject their dependance on any other counter, write down +% in the preamble |\countstyle[section]{}|. +% +% \paragraph{2} We have divided all theorem modification features into +% three orthogonal groups. +% +% A \textit{type} defines font shapes used in the theorem. +% Two types are predefined: \textit{theorem} and \textit{remark}. +% You can define more types or redefine existing types. +% +% A \textit{mode} defines the precedence of number in the header. +% In standard mode, a number goes after a theorem title. +% The reverse mode (number starts header), named here the +% \textit{APAR} mode, is special. All theorems using this mode +% are counted with the same |apar| counter. To generate theorems +% in the standard mode, the |\newtheorem| command is used. +% The |\newtheorem*| command is used for generation \textit{apar} +% theorems. +% +% A \textit{style} specifies the appearance of theorems. +% It consists of three modifiers: \textit{breaking}, +% \textit{indentation}, +% and \textit{marginal numbering}. The breaking modifier determines +% the separation of theorem header from theorem body (run-in header +% or line break after header). The indentation modifier has two +% values: \textit{noindent} and \textit{parindent}. It +% defines an indentation style of a theorem header. +% The marginal numbering modifier affects on apar theorems: +% in \textit{margin} style, the number of an apar theorem +% is typed on margins; in \textit{nomargin} +% style, the number starts a paragraph. +% +% The breaking modifier is controlled with special commands but other +% modifiers are specified with package options. +% +% \paragraph{3} We do not base the implementation of theorems +% on the |trivlist| environment. This allows us to use two methods +% of theorem markup: environment-like markup (|\begin{theorem}| \ldots\ +% |\end{theorem}|) or command-like markup (|\theorem| \ldots |\qef|). +% The |\qef| command is used as the end of any theorem. It resets the +% font to the normal font and produces a vertical skip. +% The command-like markup is useful in apar theorems. +% +% \paragraph{4} Service commands are introduced. Using package options +% you can select a type of Q.E.D.\ symbol: black or white. You can use +% both of them. The |\proof| command starts a proof of statement. +% We have no |proof| environment, because the proof is prepared in +% the normal font. To complete a proof, use |\qed| or |\qef| +% (the first one additionally prints the right adjusted Q.E.D. symbol). +% You can easy customize delimiters of theorem and proof headers. +% +% \section{Quod Erat Demonstrandum} +% +% The Q.E.D. symbol is usually used at the end of proof of a +% math statement. Sometimes, another symbol finishes a math +% statement itself. The package allows using two types of Q.E.D. +% symbols: black (\blackqedsymbol) and white (\whiteqedsymbol). +% +% \DescribeMacro\qedsymbol +% The default Q.E.D. symbol is white. It is printed with the +% |\qedsymbol| command. +% +% \DescribeMacro\qed +% \DescribeMacro\qef +% The |\qed| command is used to finish a proof. It prints +% right-adjusted Q.E.D. symbol and applies the |\qef| command +% (it finishes this paragraph). +% The |\qef| command finishes a paragraph, +% changes the current font to the normal font, and skips +% a |\paragraph|-like vertical space. +% \qed +% +% \DescribeMacro{\qed*} +% The star-form of |\qed| command prints the Q.E.D. symbol +% but not applies the |\qef| command. +% +% The usage of the above mentioned commands at the end of +% proof is the following: if the proof end with an ordinary +% paragraph, use the |\qed| command at its end; if the +% proof ends with a list, use the |\qed*| command at +% the end of the last list item and the |\qef| +% command after the end of list; and if the proof ends +% with a display formula, use the |\qedsymbol| command +% as its tag (|\tag*{\qedsymbol}| when use the +% |amsmath| package). +% +% \DescribeMacro{\blackqed} +% \DescribeMacro{\blackqedsymbol} +% If you load the package with the `|blackqed|' option, two +% additional commands are generated, |\blackqedsymbol| and |\blackqed|. +% The default |\qedsymbol| and |\qed| commands are let to be +% equal to their black versions. +% +% \DescribeMacro{\whiteqed} +% \DescribeMacro{\whiteqedsymbol} +% Analogously, the `|whiteqed|' option generates the +% |\whiteqedsymbol| and\linebreak |\whiteqed| commands and lets +% the default |\qedsymbol| and |\qed| commands to be +% equal to their white versions. +% +% If both these options are used, the default +% |\qedsymbol| and |\qed| commands are let to be equal +% the version loaded last. For example, the following command +% loads both versions of Q.E.D. and lets the white +% version to be the default version: +% \begin{quote} +% |\usepackage[blackqed,whiteqed]{nccthm}| +% \end{quote} +% +% \section{Other Package Options} +% +% The package loads options in the order they are written +% in the options list. Along with the `|blackqed|' and `|whiteqed|' +% options described above, the following options are available: +% \begin{desclist}{\tt}{\hfill}[nomargin] +% \item[noindent] theorems are typed without indentation; +% \item[indent] theorems are typed with paragraph indentation; +% \item[nomargin] numbers for theorems in apar mode are typed normally; +% \item[margin] numbers for theorems in apar mode are typed on margin. +% \end{desclist} +% +% The default options are |noindent| and |nomargin|. The following +% examples show how the combinations of |(no)indent| and |(no)margin| +% options interact. +% +% \liketheorem{Theorem}{1} The standard theorem in the |noindent + nomargin| style.\qef +% \likeremark*{Remark} The apar theorem in the |noindent + nomargin| style.\qef +% \makeatletter\NCC@thmindenttrue\NCC@thmmarginfalse\makeatother +% \liketheorem{Theorem}{2} The standard theorem in the |indent + nomargin| style.\qef +% \likeremark*{Remark} The apar remark in the |indent + nomargin| style.\qef +% \makeatletter\NCC@thmindentfalse\NCC@thmmargintrue\makeatother +% \liketheorem*{Theorem} The apar theorem in the |noindent + margin| style.\qef +% \makeatletter\NCC@thmindenttrue\NCC@thmmargintrue\makeatother +% \likeremark*{Remark} The apar remark in the |indent + margin| style.\qef +% \makeatletter\NCC@thmindentfalse\NCC@thmmarginfalse\makeatother +% +% As you can see, mixing of all these styles in the same document +% leads to bad results. This is the reason why these styles are +% implemented using options. +% +% As you can also see from the last example, +% the |indent| style is ignored for apar theorems typed in +% the |margin| style. +% +% \section{Structure and Types of Theorems} +% +% The structure of a theorem is the following: +% \begin{desclist}{}{\hfill}[\meta{normal-header}\quad] +% \item[\meta{theorem}] \meta{header} \meta{space-or-break} \meta{body} +% \item[\meta{header}] \meta{normal-header} \verb+|+ \meta{apar-header} +% \item[\meta{normal-header}] \meta{title} \oarg{number} \oarg{comment} \meta{after-char} +% \item[\meta{apar-header}] \meta{apar-tag} \meta{title} \oarg{comment} \meta{after-char} +% \end{desclist} +% A theorem type controls the appearance of the following elements +% of theorems: \meta{title}, \meta{comment}, and \meta{body}. +% The \meta{number} element inherits the style from \meta{title}. +% The \meta{after-char} element inherits either the style of \meta{comment} +% if it presents or the style of \meta{title} otherwise. The style of \meta{apar-tag} +% is controlled with the special way and will be described later. +% +% \DescribeMacro{\newtheoremtype} +% \DescribeMacro{\renewtheoremtype} +% The package provides the following theorem type generation commands: +% \begin{quote} +% |\newtheoremtype|\marg{type}\marg{title-style}\marg{comment-style}\marg{body-style}\\ +% |\renewtheoremtype|\marg{type}\marg{title-style}\marg{comment-style}\marg{body-style} +% \end{quote} +% The \meta{type} parameter is a type name. Other parameters +% specify fonts to be used in the corresponding parts of a +% theorem. +% Font style parameters are considered to be used after the +% |\normalfont| command. +% +% \DescribeMacro{\like...} +% When a new theorem type is generated, the |\like|\meta{type} command +% is created for it. It has two forms: normal and starred. The normal version +% prints a theorem in the standard mode and the starred version prints +% an apar theorem. The syntax: +% \begin{quote} +% |\like|\meta{type}\marg{title}\marg{number}\oarg{comment}\\ +% |\like|\meta{type}*\marg{title}\oarg{comment} +% \end{quote} +% The starred version of this command has no \meta{number} argument, because +% it is numbered using the |apar| counter. +% If the \meta{number} argument in the non-starred version of this command +% is empty, the number will be omitted in the theorem header. +% If the \meta{comment} argument presents, the comment is typed enclosed +% in round brackets. This behaviour can be changed with customization +% commands. +% +% Two theorem types, `|theorem|' and `|remark|', are predefined as follows: +% \begin{quote} +% |\newtheoremtype{theorem}{\bfseries}{}{\itshape}|\\ +% |\newtheoremtype{remark}{\itshape}{}{}| +% \end{quote} +% +% \DescribeMacro\liketheorem +% \DescribeMacro\likeremark +% Using the |\liketheorem| and |\likeremark| commands, you can +% produce a\linebreak theorem of the given type with arbitrary title without +% generation a special environment for it. It is very useful +% if a theorem with the given title appears in a document only once. +% +% \textbf{Note:} Type generation commands are available in the +% preamble only. +% +% \section{Generate New Theorems} +% +% \DescribeMacro\newtheorem +% A standard theorem environment is generated with the +% |\newtheorem| command: +% \begin{quote} +% |\newtheorem|\marg{env-name}\oarg{counter}\marg{title}\oarg{type} +% \end{quote} +% In comparison with the standard \LaTeX\ version of this command, +% the last optional +% parameter has another meaning: it specifies a theorem type. +% This is because its standard meaning (the base counter) +% useless here. If the \meta{type} parameter is omitted, +% the `|theorem|' type is used. The optional argument \meta{counter} +% is a counter this environment will be counted with. If it is +% omitted, the counter name equal to the \meta{env-name} is used. +% We do not test the \meta{counter} on existence when +% a new theorem environment is generated. The theorem counter is declared +% to be the dynamic counter. It is defined at the first use and +% inherits the style declared by the latest use of the command +% \begin{quote} +% |\countstyle|\marg{base-counter} +% \end{quote} +% Its argument contains a name of base-counter for all dynamically +% created counters. Dynamically created counter is set to zero when the +% base counter is stepped. Its |\the| command is the following: +% \begin{quote} +% |\the|\meta{base-counter}.|\arabic|\marg{dynamic-counter} +% \end{quote} +% If the \meta{base-counter} is empty, a dynamic counter will be +% numbered in the plain style. +% +% \qef +% \textbf{Note:} In contrast with the standard definition, +% the described |\newtheorem| command may be used with all +% four parameters. +% +% \qef +% \DescribeMacro{\newtheorem*} +% To generate a new apar theorem environment, the starred version of +% the |\newtheorem| command is applied: +% \begin{quote} +% |\newtheorem*|\marg{env-name}\marg{title}\oarg{type} +% \end{quote} +% All apar theorems are counted with the `|apar|' counter. +% +% \DescribeMacro{\renewtheorem} +% \DescribeMacro{\renewtheorem*} +% You can also redefine already defined theorem environments +% using the commands +% \begin{quote} +% |\renewtheorem|\marg{env-name}\oarg{counter}\marg{title}\oarg{type}\\ +% |\renewtheorem*|\marg{env-name}\marg{title}\oarg{type} +% \end{quote} +% While redefinition a theorem environment, you can change values of +% all other parameters after \meta{env-name}. +% +% \DescribeMacro\TheoremBreakStyle +% \DescribeMacro\TheoremNoBreakStyle +% When a theorem environment is defined or redefined, a decision +% what must be inserted after the theorem header (space or break) +% is made on the base of current break style. The +% |\TheoremBreakStyle| and |\TheoremNoBreakStyle| commands change +% this style to the `break' and `no-break' respectively. The default +% style is `no-break'. +% +% \textbf{Note:} Theorem generation commands are available in the preamble only. +% +% \section{Using Theorems} +% +% The syntax of using theorem environments is the following: +% \begin{quote} +% |\begin|\marg{env-name}\oarg{comment} \meta{body} +% |\end|\marg{env-name} +% \end{quote} +% You can also use the command-like syntax: +% \begin{quote} +% |\|\meta{env-name}\oarg{comment} \meta{body} |\qef| +% \end{quote} +% which is more likely for apar theorems. +% +% \DescribeMacro\breakafterheader +% \DescribeMacro\nobreakafterheader +% You can change a break style for a theorem applying +% the |\breakafterheader| and |\nobreakafterheader| commands +% just before using the theorem. +% +% Let us do the following in the preamble: +% \begin{quote} +% |\countstyle[apar]{section}|\\ +% |\newtheorem{theorem}{Theorem}|\\ +% |\newtheorem*{atheorem}{Theorem}|\\ +% |\TheoremBreakStyle|\\ +% |\newtheorem{definition}{Definition}[remark]|\\ +% |\TheoremNoBreakStyle|\\ +% |\newtheorem{lemma}[theorem]{Lemma}| +% \end{quote} +% This code generates 4 theorem environments: the `|theorem|' provides a +% standard Theorem statement; +% the `|atheorem|' provides a Theorem statement in the apar mode +% with per-section numbering; +% the `|definition|' provides a standard Definition statement +% prepared as a remark; and the `|lemma|' provides a standard +% Lemma statement counted with the |theorem| counter. Definitions +% are printed in the break style. +% +% \begin{quote} +% |\begin{theorem} A theorem. \end{theorem}|\\ +% |\begin{lemma} A lemma. \end{lemma}|\\ +% |\breakafterheader|\\ +% |\begin{theorem}[A comment] A theorem with break.\end{theorem}|\\ +% |\atheorem A theorem in apar mode. \qef|\\ +% |\begin{definition} A definition. \end{definition}| +% \end{quote} +% This code produces the following: +% \Line +% \begin{theorem} A theorem. \end{theorem} +% \begin{lemma} A lemma. \end{lemma} +% \breakafterheader +% \begin{theorem}[A comment] A theorem with break.\end{theorem} +% \atheorem A theorem in apar mode. \qef +% \begin{definition} A definition. \end{definition} +% \Line +% +% To prepare a theorem without number or having a special number, +% use the |\like|\meta{type} command. Examples: +% \begin{quote} +% |\liketheorem{Theorem}{A} Special theorem.\qef|\\ +% |\liketheorem{Proposition}{}[Comment] It has no number.\qef|\\ +% |\breakafterheader|\\ +% |\likeremark{Example}{2.3.5} An example.\qef|\\ +% |\likeremark*{Remark} An apar remark. \qef| +% \end{quote} +% This code produces the following: +% \Line +% \liketheorem{Theorem}{A} Special theorem.\qef +% \liketheorem{Proposition}{}[Comment] It has no number.\qef +% \breakafterheader +% \likeremark{Example}{2.3.5} An example.\qef +% \likeremark*{Remark} An apar remark. \qef +% \Line +% +% \DescribeMacro\proof +% The |\proof| command prints the proof of a math statement. Syntax: +% \begin{quote} +% |\proof|\oarg{of-theorem} \meta{body} |\qed| +% \end{quote} +% The optional parameter \meta{of-theorem} contains a +% text appended to the title of proof. The break-style change +% commands can be applied to this command. Examples: +% \begin{quote} +% |\proof An ordinary proof.\qed|\\ +% |\proof[of Theorem A] A special proof.\qed|\\ +% |\breakafterheader|\\ +% |\proof[of the Pythagor Theorem] A proof.\qed| +% \end{quote} +% This code produces the following: +% \Line +% \proof An ordinary proof.\qed +% \proof[of Theorem A] A special proof.\qed +% \breakafterheader +% \proof[of the Pythagor Theorem] A proof.\qed +% \Line +% +% \section{Apar Sections} +% +% Header of an apar theorem is similar to the header printed +% by the |\paragraph| or |\subparagraph| command (except +% paragraph numbering that is usually omitted). +% Moreover, from the logical point of view, the apar +% theorems are specially designed enumerated paragraphs. +% Therefore, it is a good idea to use apar markup +% as some kind of special sectioning. +% +% \DescribeMacro\apar +% The following command supports sectioning in the apar mode: +% \begin{quote} +% |\apar|\oarg{title} +% \end{quote} +% It produces a new paragraph starting with the \meta{apar-tag} +% element and having the optional title. The indentation style and +% marginal style of apar section is the same as for apar theorems. +% The vertical skip before +% the apar section is just the same as before theorems. +% If the |nccsect| package is loaded, the apar skip is equal +% to the skip produced with the |\paragraph| and |\subparagraph| +% commands. +% +% These properties of apar sections are useful in design of +% articles having short sections. For example, if an article +% consists of many short sections prepared with the |\subsection| +% command, it looks very loose, because subsections are produced +% in the display style. It will be better to allow subsections +% run-in paragraph. Using the |\apar| command, you can do this +% very easy: add the following command to the preamble +% \begin{quote} +% |\countstyle[apar]{section}| +% \end{quote} +% and prepare subsections with the |\apar| command. Example: +% \begin{quote} +% |\apar[Subsection title] Subsection body ...|\\ +% |\apar[Next title:] The body ...|\\ +% |\atheorem In fact, this is a special apar section ...|\\ +% |\apar Subsection without title ...|\\ +% |\breakafterheader|\\ +% |\apar[One more title] Break before its body| +% \end{quote} +% This code produces the following: +% \Line +% \apar[Subsection title] Subsection body ... +% \apar[Next title:] The body ... +% \atheorem In fact, this is a special apar section ... +% \apar Subsection without title ... +% \breakafterheader +% \apar[One more title] Break before its body +% \Line +% +% \section{Customization Commands} +% +% \DescribeMacro{\NCC@runskip} +% The vertical skips before and after theorems are identic. They are +% produced with the |\qef| command. The length of the skip is coded +% in the inner command |\NCC@runskip|. This command is also used in +% the |nccsect| package as a skip inserted before the |\paragraph| +% and |\subparagraph| commands. Its default value +% \begin{quote} +% |2.75ex plus 1ex minus 0.2ex| +% \end{quote} +% +% \DescribeMacro{\TheoremCommentDelimiters} +% The |\TheoremCommentDelimiters|\marg{left}\marg{right} command +% specifies delimiters inserted before and after a theorem comment. +% The default setting is: +% \begin{quote} +% |\TheoremCommentDelimiters{(}{)}| +% \end{quote} +% +% \DescribeMacro{\AfterTheoremHeaderChar} +% The |\AfterTheoremHeaderChar|\marg{after-char} command +% specifies an \meta{after-char} element that ends +% header of theorem and header of proof. The default setting is +% an empty element. +% +% \DescribeMacro{\AfterTheoremHeaderSkip} +% The |\AfterTheoremHeaderSkip|\marg{skip-command} command +% specifies a command inserted between theorem header and body. +% In break style, this command is ignored. +% The default setting is: +% \begin{quote} +% |\AfterTheoremHeaderSkip{\hskip 1em plus 0.2em minus 0.2em}| +% \end{quote} +% +% \DescribeMacro\ProofStyleParameters +% The |\ProofStyleParameters|\marg{style}\marg{title} command +% specifies style parameters used in the |\proof| +% command: the first one is a font style and the last one +% is a proof title. The default setting is: +% \begin{quote} +% |\ProofStyleParameters{\bfseries}{Proof}| +% \end{quote} +% +% \DescribeMacro\AparStyleParameters +% The |\AparStyleParameters|\marg{style}\marg{prefix}\marg{suffix} +% command specifies the style of apar sections: the \meta{style} +% is a style of apar section title; the tag of apar theorems +% and sections is prepared using \meta{prefix} and \meta{suffix} +% specified with this command as follows +% \meta{prefix}|\theapar|\meta{suffix}. The default setting is: +% \begin{quote} +% |\AparStyleParameters{\bfseries}{\bfseries}{\enskip}| +% \end{quote} +% +% \qef +% \textbf{Note:} All customization commands except the +% |\NCC@runskip| are allowed in the preamble only. +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\NCC@secskip} +% \begin{macro}{\NCC@runskip} +% The package shares the following commands with the +% |nccsect| package: +% \begin{quote} +% |\NCC@secskip|\marg{skip} adds the \meta{skip} before a section,\\ +% |\NCC@runskip| is a skip inserted before run-in sections. +% \end{quote} +% We protect the definitions of these commands with testing +% the |nccsect| package to be already loaded. +% \begin{macrocode} +%<*package> +\@ifpackageloaded{nccsect}{}{% + \def\NCC@secskip#1{% + \if@noskipsec \leavevmode \fi \par + \if@nobreak \everypar{}\else + \addpenalty\@secpenalty + \addvspace{#1}% + \fi + } + \def\NCC@runskip{2.75ex \@plus 1ex \@minus .2ex} +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Q.E.D. Support} +% +% \begin{macro}{\NCC@qedsymbol} +% \begin{macro}{\qedsymbol} +% The |\NCC@qedsymbol| command is the base implementation +% of white Q.E.D. symbol. +% If no Q.E.D. selection options used, the +% |\qedsymbol| is equal to the base version. +% \begin{macrocode} +\DeclareRobustCommand{\NCC@qedsymbol}{% + \mbox{\normalsize\normalfont\thinlines \@tempdima 1.5ex + \advance\@tempdima-2\@wholewidth + \edef\@tempa{\the\@tempdima}% + \kern \@wholewidth + \raisebox\@wholewidth[1.5ex]{% + \frame{\rule\z@\@tempa\rule\@tempa\z@}}% + \kern \@wholewidth + }% +} +\let\qedsymbol\NCC@qedsymbol +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\qed} +% \begin{macro}{\qed*} +% The |\qed| command produces the flush-right Q.E.D. symbol +% and applies the |\qef| command in the non-starred case. +% \begin{macrocode} +\newcommand{\qed}{\NCC@qed{\qedsymbol}} +\def\NCC@qed#1{\unskip\allowbreak% + \hspace*{1em plus 1fill minus .2em}#1\@ifstar{}{\qef}% +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\qef} +% The |\qef| finishes a paragraph, adds the |\@secpenalty|, +% and produces the vertical skip of |\NCC@runskip| size. +% If also sets the normal font and removes the no-break +% condition suppressing indentation in the next +% paragraph. +% \begin{macrocode} +\newcommand{\qef}{\NCC@secskip{\NCC@runskip}\@nobreakfalse\normalfont} +% \end{macrocode} +% \end{macro} +% +% \subsection{Package Options} +% +% \begin{macro}{\whiteqedsymbol} +% \begin{macro}{\whiteqed} +% The `|whiteqed|' option: +% \begin{macrocode} +\DeclareOption{whiteqed}{% + \let\whiteqedsymbol\NCC@qedsymbol + \newcommand{\whiteqed}{\NCC@qed{\whiteqedsymbol}} + \let\qedsymbol\whiteqedsymbol +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\blackqedsymbol} +% \begin{macro}{\blackqed} +% The `|blackqed|' option: +% \begin{macrocode} +\DeclareOption{blackqed}{% + \DeclareRobustCommand{\blackqedsymbol}{% + \begingroup\normalsize\normalfont\thinlines + \rule{1.5ex}{1.5ex}\endgroup + } + \newcommand{\blackqed}{\NCC@qed{\blackqedsymbol}} + \let\qedsymbol\blackqedsymbol +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\ifNCC@thmindent} +% \begin{macro}{\ifNCC@thmmargin} +% Theorem indentation and marginal numbering options +% are based on two if-macros: +% the |NCC@thmindent| controls the indentation of headers and +% the |NCC@thmmargin| controls the marginal numbering in +% the apar mode. +% \begin{macrocode} +\newif\ifNCC@thmindent +\newif\ifNCC@thmmargin +\DeclareOption{noindent}{\NCC@thmindentfalse} +\DeclareOption{indent}{\NCC@thmindenttrue} +\DeclareOption{nomargin}{\NCC@thmmarginfalse} +\DeclareOption{margin}{\NCC@thmmargintrue} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% Set defaults and process all options in the order +% they appear in the options list. +% \begin{macrocode} +\ExecuteOptions{noindent,nomargin} +\ProcessOptions* +% \end{macrocode} +% +% \subsection{The Kernel} +% +% We use the |\@ifempty| command from the |amsgen| package +% and dynamic counters from the |dcounter| package. +% \begin{macrocode} +\RequirePackage{amsgen} +\RequirePackage{dcounter}[1998/12/19] +% \end{macrocode} +% +% \begin{macro}{\NCC@thmbrmode} +% \begin{macro}{\ifNCC@thmbr} +% A theorem break mode is controlled with the |\NCC@thmbrmode| +% macro and the |\ifNCC@thmbr|. The |\NCC@thmbrmode| can have +% three possible values: +% \begin{desclist}{}{\hfill}[\cs{relax}\ ] +% \item[\cs{relax}] undefined mode; +% \item[\cs{z@}] break mode; +% \item[\cs{@ne}] no-break mode. +% \end{desclist} +% If the break mode is undefined, the decision is made on the +% analyzes of the |NCC@thmbr| value: true value means break, +% false value means no-break. +% \begin{macrocode} +\let\NCC@thmbrmode\relax +\newif\ifNCC@thmbr +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\breakafterheader} +% \begin{macro}{\nobreakafterheader} +% The |\breakafterheader| and |\nobreakafterheader| +% commands test the current break mode and set an +% appropriate mode if it is undefined yet. As a result, +% usage of these commands before a theorem leads to +% overriding the default break mode specified in +% theorem's macro. +% \begin{macrocode} +\newcommand\breakafterheader{% + \ifx\NCC@thmbrmode\relax \global\chardef\NCC@thmbrmode\z@\fi +} +\newcommand\nobreakafterheader{% + \ifx\NCC@thmbrmode\relax \global\chardef\NCC@thmbrmode\@ne\fi +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\TheoremBreakStyle} +% \begin{macro}{\TheoremNoBreakStyle} +% \begin{macro}{\TheoremCommentDelimiters} +% \begin{macro}{\AfterTheoremHeaderChar} +% \begin{macro}{\AfterTheoremHeaderSkip} +% Theorem customization commands: +% \begin{macrocode} +\newcommand{\TheoremBreakStyle}{\NCC@thmbrtrue} +\newcommand{\TheoremNoBreakStyle}{\NCC@thmbrfalse} +\newcommand*{\TheoremCommentDelimiters}[2]{% + \def\NCC@thmcmt@##1{#1\ignorespaces##1\unskip#2}% +} +\newcommand*{\AfterTheoremHeaderChar}[1]{\def\NCC@thmchar{#1}} +\newcommand*{\AfterTheoremHeaderSkip}[1]{\def\NCC@thmskip{#1}} +\@onlypreamble\TheoremBreakStyle +\@onlypreamble\TheoremNoBreakStyle +\@onlypreamble\TheoremCommentDelimiters +\@onlypreamble\AfterTheoremHeaderChar +\@onlypreamble\AfterTheoremHeaderSkip +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\NCC@thmhdr} +% The |\NCC@thmhdr|\marg{style}\marg{header} prints a theorem header +% in the required \meta{style} and implements the current break mode. +% At the end of macro, the break mode is reset to |\relax|. +% The header is prepared in a group. +% \begin{macrocode} +\def\NCC@thmhdr#1#2{% + \qef +% \end{macrocode} +% Insert a negative low penalty to increase a chance of +% page break before the beginning of theorem. +% \begin{macrocode} + \addpenalty{-\@lowpenalty}% + \begingroup + #1% +% \end{macrocode} +% Test the break mode. If it is undefined, we set it basing +% on the value of |\ifNCC@thmbr| switch. +% \begin{macrocode} + \ifx\NCC@thmbrmode\relax + \ifNCC@thmbr \chardef\NCC@thmbrmode\z@ + \else \chardef\NCC@thmbrmode\@ne + \fi + \fi +% \end{macrocode} +% The break case: to implement the break in the vertical +% mode, it is enough to put the header in hbox. To allow +% multi-line header, we prepare it in inner vbox. +% \begin{macrocode} + \ifnum\NCC@thmbrmode=\z@ + \@tempdima\parindent + \hbox{\vbox{\hsize\linewidth\@parboxrestore + \ifNCC@thmindent\parindent\@tempdima\fi + \leavevmode\strut#2\strut + }}\nobreak\noindent +% \end{macrocode} +% The no-break case: The |\ncc@thmskip| command +% \begin{macrocode} + \else + \ifNCC@thmindent\else\noindent\fi + \leavevmode{#2\normalfont\NCC@thmskip}\nobreak + \fi + \endgroup +% \end{macrocode} +% Reset the break mode to the initial value: +% \begin{macrocode} + \global\let\NCC@thmbrmode\relax +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@thmcmt} +% The |\NCC@thmcmt|\marg{comment-style}\marg{comment} tests +% a comment to be nonempty and produces it in corresponding style. +% \begin{macrocode} +\def\NCC@thmcmt#1#2{% + \@ifempty{#2}{}{\/\space\normalfont#1\NCC@thmcmt@{#2}}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@lthm} +% Standard mode basic command: +% \begin{quote} +% |\NCC@lthm|\marg{header-style}\marg{comment-style}\marg{body-style}\marg{title}\\ +% | |\marg{number}\oarg{comment} +% \end{quote} +% \begin{macrocode} +\def\NCC@lthm#1#2#3#4#5{% + \@ifnextchar[{\NCC@lthm@{#1}{#2}{#3}{#4}{#5}}% + {\NCC@lthm@{#1}{#2}{#3}{#4}{#5}[]}% +} +\def\NCC@lthm@#1#2#3#4#5[#6]{% +% \end{macrocode} +% Prepare theorem header. +% \begin{macrocode} + \NCC@thmhdr{}{% + #1#4\@ifempty{#5}{}{\space#5}% + \NCC@thmcmt{#2}{#6}\NCC@thmchar + }% +% \end{macrocode} +% Set the body style and do a small skip to avoid extra +% space after the |\label| command. +% \begin{macrocode} + #3\hskip 0.001\p@ \ignorespaces +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@thxhdr} +% The |\NCC@thxhdr|\marg{style}\marg{header} produces an apar theorem +% header. +% \begin{macrocode} +\def\NCC@thxhdr#1#2{% + \refstepcounter{apar}% + \NCC@thmhdr{% +% \end{macrocode} +% In margin style, the indent style is turned off for apar theorems: +% \begin{macrocode} + \ifNCC@thmmargin \NCC@thmindentfalse \fi + #1% + }{% +% \end{macrocode} +% Put the \meta{apar-tag} (prepared in the |\NCC@thmapar| command) +% before the header using |\llap| or |\hbox|. Then put the header. +% \begin{macrocode} + \ifNCC@thmmargin \llap{\NCC@thmapar}\else \hbox{\NCC@thmapar}\fi + #2% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@lthx} +% Apar mode basic command: +% \begin{quote} +% |\NCC@lthx|\marg{header-style}\marg{comment-style}\marg{body-style}\marg{title}\\ +% | |\oarg{comment} +% \end{quote} +% \begin{macrocode} +\def\NCC@lthx#1#2#3#4{% + \@ifnextchar[{\NCC@lthx@{#1}{#2}{#3}{#4}}% + {\NCC@lthx@{#1}{#2}{#3}{#4}[]}% +} +\def\NCC@lthx@#1#2#3#4[#5]{% + \NCC@thxhdr{}{% + \normalfont#1#4\NCC@thmcmt{#2}{#5}\NCC@thmchar + }% + #3\hskip 0.001\p@ \ignorespaces +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@likethm} +% The base for |\like|\meta{type} commands. It passes the control +% to |\NCC@lthm| or |\NCC@lthx| depending on the star appearing +% after the third parameter: +% \begin{quote} +% |\NCC@likethm|\marg{header-style}\marg{comment-style}\marg{body-style}\marg{title}\\ +% | |\marg{number}\oarg{comment}\\ +% |\NCC@likethm|\marg{header-style}\marg{comment-style}\marg{body-style}|*|\marg{title}\\ +% | |\oarg{comment} +% \end{quote} +% \begin{macrocode} +\def\NCC@likethm#1#2#3{% + \@ifstar{\NCC@lthx{#1}{#2}{#3}}{\NCC@lthm{#1}{#2}{#3}}% +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Apar Sections} +% +% The counter used in the apar mode is dynamic: +% \begin{macrocode} +\DeclareDynamicCounter{apar} +% \end{macrocode} +% +% \begin{macro}{\AparStyleParameters} +% Apar style parameters provider: +% \begin{macrocode} +\newcommand*{\AparStyleParameters}[3]{% + \def\NCC@thmaparstyle{#1}% + \def\NCC@thmapar{#2\theapar#3}% +} +\@onlypreamble\AparStyleParameters +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\apar} +% The |\apar|\oarg{title} command starts a new apar-numbered +% paragraph. If the \meta{title} is omitted or empty, +% we must ignore the |\NCC@thmskip|. +% \begin{macrocode} +\newcommand*{\apar}[1][]{% + \NCC@thxhdr{\NCC@thmaparstyle} + {\@ifempty{#1}{\let\NCC@thmskip\@empty}{\ignorespaces#1\unskip}}% + \hskip 0.001\p@ \ignorespaces +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Proof of Theorem} +% +% \begin{macro}{\ProofStyleParameters} +% Proof style parameters provider: +% \begin{macrocode} +\newcommand*{\ProofStyleParameters}[2]{% + \def\NCC@thmproofstyle{#1}% + \def\NCC@thmproof{#2}% +} +\@onlypreamble\ProofStyleParameters +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\proof} +% The |\proof|\oarg{of-theorem} command: +% \begin{macrocode} +\newcommand*{\proof}[1][]{% + \NCC@thmhdr{\NCC@thmproofstyle}{% + \NCC@thmproof + \@ifempty{#1}{}{\space\ignorespaces#1\unskip}% + \NCC@thmchar + }% + \hskip 0.001\p@ \ignorespaces +} +% \end{macrocode} +% \end{macro} +% +% \subsection{Generate New Theorem Types} +% +% \begin{macro}{\like...} +% New theorem type generation means definition a |\like|\meta{type} +% command preparing theorems of corresponding type. +% The syntax of a |\like|\meta{type} command is +% the following: +% \begin{quote} +% |\like|\meta{type}\marg{title}\marg{number}\oarg{comment}\\ +% |\like|\meta{type}|*|\marg{title}\oarg{comment} +% \end{quote} +% The first one produces a standard theorem and the last one produces +% an apar theorem. +% \end{macro} +% +% \begin{macro}{\newtheoremtype} +% \begin{macro}{\renewtheoremtype} +% Theorem type generation commands: +% \begin{quote} +% |\newtheoremtype|\marg{type}\marg{title-style}\marg{comment-style}\marg{body-style}\\ +% |\renewtheoremtype|\marg{type}\marg{title-style}\marg{comment-style}\marg{body-style} +% \end{quote} +% \begin{macrocode} +\newcommand*{\newtheoremtype}[1]{% + \edef\@tempa{\noexpand\newcommand*{\expandafter\noexpand + \csname like#1\endcsname}}\NCC@nthmtype +} +\newcommand*{\renewtheoremtype}[1]{% + \edef\@tempa{\noexpand\renewcommand*{\expandafter\noexpand + \csname like#1\endcsname}}\NCC@nthmtype +} +\def\NCC@nthmtype#1#2#3{\@tempa{\NCC@likethm{#1}{#2}{#3}}} +\@onlypreamble\newtheoremtype +\@onlypreamble\renewtheoremtype +\@onlypreamble\NCC@nthmtype +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \subsection{Generate New Theorems} +% +% \begin{macro}{\NCC@thmdef} +% Basic theorem generation command: +% \begin{quote} +% |\NCC@thmdef|\marg{env-name}\marg{action}\marg{parameters}\oarg{type} +% \end{quote} +% The |\@tempa| command must contain either |\noexpand\newenvironment| or +% |\noexpand\renewenvironment| before the call. +% The \meta{action} is an action applied at the beginning +% of theorem. The \meta{parameters} contains parameters passed +% to the |\like|\meta{type} command. +% \begin{macrocode} +\def\NCC@thmdef#1#2#3{% + \@ifnextchar[{\NCC@thmdef@{#1}{#2}{#3}}% + {\NCC@thmdef@{#1}{#2}{#3}[theorem]}% +} +\def\NCC@thmdef@#1#2#3[#4]{% +% \end{macrocode} +% Generate an error if the given type is unknown. +% \begin{macrocode} + \@ifundefined{like#4}{% + \PackageError{nccthm}{Unknown theorem type `#4'}{}% + }% +% \end{macrocode} +% |\@tempa := \[re]newenvironment|\marg{env-name}|{#1\like|\meta{type}|#2}| +% \begin{macrocode} + \edef\@tempa##1##2{% + \@tempa{#1}{##1\expandafter\noexpand\csname like#4\endcsname##2}% + }% +% \end{macrocode} +% Generate a theorem envirinment: +% \begin{macrocode} + \ifNCC@thmbr + \@tempa{#2\breakafterheader}{#3}{\qef\ignorespacesafterend}% + \else + \@tempa{#2\nobreakafterheader}{#3}{\qef\ignorespacesafterend}% + \fi +} +\@onlypreamble\NCC@thmdef +\@onlypreamble\NCC@thmdef@ +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\newtheorem} +% \begin{macro}{\renewtheorem} +% \begin{macro}{\newtheorem*} +% \begin{macro}{\renewtheorem*} +% Theorem generation commands: +% \begin{quote} +% |\newtheorem|\marg{env-name}\oarg{counter}\marg{title}\oarg{type}\\ +% |\renewtheorem|\marg{env-name}\oarg{counter}\marg{title}\oarg{type}\\ +% |\newtheorem*|\marg{env-name}\marg{title}\oarg{type}\\ +% |\renewtheorem*|\marg{env-name}\marg{title}\oarg{type} +% \end{quote} +% \begin{macrocode} +\renewcommand*{\newtheorem}{\def\@tempa{\noexpand\newenvironment}% + \@ifstar{\NCC@nthx}{\NCC@nthm}} +\newcommand*{\renewtheorem}{\def\@tempa{\noexpand\renewenvironment}% + \@ifstar{\NCC@nthx}{\NCC@nthm}} +\def\NCC@nthx#1#2{\NCC@thmdef{#1}{}{*{#2}}} +\def\NCC@nthm#1{\@ifnextchar[{\NCC@nthm@{#1}}{\NCC@nthm@{#1}[#1]}} +\def\NCC@nthm@#1[#2]#3{% + \DeclareDynamicCounter{#2}% + \NCC@thmdef{#1}{\refstepcounter{#2}}{{#3}{\csname the#2\endcsname}}% +} +\@onlypreamble\newtheorem +\@onlypreamble\renewtheorem +\@onlypreamble\NCC@nthx +\@onlypreamble\NCC@nthm +\@onlypreamble\NCC@nthm@ +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \subsection{Defaults} +% +% \begin{macrocode} +\newtheoremtype{theorem}{\bfseries}{}{\itshape} +\newtheoremtype{remark}{\itshape}{}{} +\TheoremNoBreakStyle +\TheoremCommentDelimiters{(}{)} +\AfterTheoremHeaderChar{} +\AfterTheoremHeaderSkip{\hskip 1em \@plus .2em \@minus .2em} +\AparStyleParameters{\bfseries}{\bfseries}{\enskip} +\ProofStyleParameters{\bfseries}{Proof} +% +% \end{macrocode} +\endinput diff --git a/macros/latex/contrib/ncctools/source/ncctools.ins b/macros/latex/contrib/ncctools/source/ncctools.ins new file mode 100644 index 0000000000..63ed2a13b0 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/ncctools.ins @@ -0,0 +1,78 @@ +%% Copyright 1998--2006 by Alexander I. Rozhenko. +%% +%% This file is part of the `ncctools' bundle. +%% +%% I am allowed to distribute this file together with all files +%% mentioned in the manifest.txt. +%% +%% You are not allowed to modify its contents. +%% + +% This file requires docstrip version 2.4 or higher available from +% ftp.dante.de tex-archive/macros/latex/unpacked/docstrip.tex + +\input docstrip + +\def\SimplePackage#1{% + \generate{\file{#1.sty}{\from{#1.dtx}{package}}}} + +\keepsilent + +%% This is the preamble that will be placed on unpacked files + +\preamble + +IMPORTANT NOTICE: + +This file is a generated file from the sources of the `ncctools' +bundle. + +You are not allowed to modify this file. + +You are allowed to distribute this file if and only if +it is distributed with the corresponding source files in +the `ncctools' bundle. + +For the copying and distribution conditions of the source files, +see the README file distributed with the ncctools bundle. +\endpreamble + +%%%%%%%%%%%%%% Generate packages + +\SimplePackage{afterpackage} +\SimplePackage{dcounter} +\SimplePackage{desclist} +\SimplePackage{extdash} +\SimplePackage{manyfoot} +\SimplePackage{mboxfill} +\SimplePackage{nccbbb} +\SimplePackage{nccboxes} +\SimplePackage{ncccomma} +\SimplePackage{ncccropbox} +\SimplePackage{ncccropmark} +\SimplePackage{nccfancyhdr} +\SimplePackage{nccfloats} +\SimplePackage{nccfoots} +\SimplePackage{nccmath} +\SimplePackage{nccparskip} +\SimplePackage{nccpic} +\SimplePackage{nccrules} +\SimplePackage{nccsect} +\SimplePackage{nccstretch} +\SimplePackage{nccthm} +\SimplePackage{textarea} +\SimplePackage{tocenter} +\SimplePackage{topsection} +\SimplePackage{watermark} + +\Msg{***********************************************************} +\Msg{*} +\Msg{* To finish the installation you have to move all the files} +\Msg{* with extension `.sty' into a directory searched by TeX.} +\Msg{*} +\Msg{* To produce the documentation run the .dtx files through LaTeX.} +\Msg{*} +\Msg{* Happy TeXing} +\Msg{***********************************************************} + +\endbatchfile diff --git a/macros/latex/contrib/ncctools/source/ncctools.tex b/macros/latex/contrib/ncctools/source/ncctools.tex new file mode 100644 index 0000000000..a72ead35a0 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/ncctools.tex @@ -0,0 +1,299 @@ +\documentclass[11pt]{article} +\usepackage[colorlinks=true,filecolor=blue]{hyperref} +\usepackage{amsmath} +\usepackage{desclist} +\usepackage{tocenter} +\reversemarginpar +\settowidth\marginparwidth{\tt afterpackage} +\ToCenter[fm]{130mm}{220mm} + +\title{NCCTOOLS} +\author{by Alexander I. Rozhenko} +\date{Release 3.5} + +\def\|{\verb|} +\newcommand*\Package[1]{% + \par\bigskip\noindent\leavevmode + \marginpar{\hfill\href{#1.pdf}{\underbar{\tt#1}}}\ignorespaces +} +\newcommand*\Pack[1]{{\tt#1}} +\begin{document} +\maketitle + +The `ncctools' collection consists of a number of packages +extracted from NCC style (developed by Alexander I.~Rozhenko in +1992--1996 under \LaTeX-2.09) while re-implementation it for +\LaTeXe. Many new packages were also added later. + +The collection now contains 25 packages providing the following: + +\Package{afterpackage} Implements \|\AfterPackage| command specifying +additional commands which should be applied to a package after +its loading. The customization commands are specified without +pre-loading packages they concerned to and are applied right +after loading the respective packages. + +\Package{dcounter} Dynamic counters. The counter declared as +dynamic is really created at the first use and receives at that +moment the count style established by the \|\countstyle| command. +The special use of \|\counstyle| command with optional parameter +allows modify the subordination of existing counter. For example, +while using the book class you can reject the subordination of the +section counter to the chapter counter and re-subordinate figures, +tables and equations to sections. The package is used in the +\Pack{nccthm} package. + +\Package{desclist} Implements the \|desclist| environment. It is +considered as an improvement of the \|description| environment. +The appearance of item markers is easy customizable on the fly. An +optional parameter allows set a marker prototype for calculation +of hang indentation skip. The \|description| environment is +redefined to use an optional parameter also. + +\Package{extdash} The package implements the commands, +\|\Hyphdash|, \|\Endash|, \|\Emdash|, and their star-forms, to +control hyphenation of compound words and ordinary words dashed by +em-dash. You can also use the shortcuts +\begin{center} +\|\-/|\quad \|\=/|\quad \|\--|\quad \|\==|\quad\|\---|\quad\|\===| +\end{center} +instead. You can also decrease the length of em-dash by the +\|cyremdash| option to satisfy the Russian typesetting rules. + +\Package{manyfoot} The package implements a command, +\|\newfootnote|, that adds footnote levels to the standard LaTeX's +footnote mechanism. Footnotes of every additional level are +automatically grouped together on a \LaTeXe\ output page and are +separated from another levels by the special vertical space and +(maybe) rule. You can customize the typesetting style of +additional footnotes choosing between ordinary footnotes and +run-in paragraph footnotes (useful for critical editions). Service +command \|\DeclareNewFootnote| simplifies creation of new footnote +levels with automatic footnote numbering. The possibility of +customization inter-level footnote rules is allowed. + +\Package{mboxfill} The package introduces \|\mboxfill| command +filling a free space with a pattern. All leader types are supported. +Width of pattern can be specified by the same manner as in +the \|\makebox| command. + +\Package{nccbbb} Implementation of poor Black Board Bold symbols. +Ported from old NCC-\LaTeX. It is useless in modern \LaTeX\ but +kept just in case. + +\Package{nccboxes} Additional boxes from NCC-\LaTeX. The \|\jhbox| +and \|\jvbox| horizontally and vertically align a body with +respect to a prototype. The \|\jparbox| vertically aligns +paragraph box with respect to a prototype. The \|\addbox| adjusts +height and depth of box. The \|\pbox| is a simple version of +one-column table. It is independent on \|\arraystretch| value. The +\|\cbox| is intended for design of fancy headers in tables. + +\Package{ncccomma} Implements the smart comma in math mode working +as an ordinary character if a decimal character goes after it. +Otherwise, the math comma works as a punctuation mark. + +\Package{ncccropbox} Implements the \|\cropbox| command preparing +a box with crop marks at its corners looking like angles. Angle +parameters are customizable. + +\Package{ncccropmark} Implements the \|\cropmark| command +producing crop box around page text area (header area, footer area +and marginal notes are optionally taken into consideration). The +\|\cropmark| command is useful as a parameter of the \|\watermark| +commands form the \Pack{watermark} package. It accurately +interprets current state of two-column, two-side, and +reverse-margin modes. + +\Package{nccfancyhdr} Absolutely new implementation of +functionality of the \Pack{fancyhdr} package. It is more +transparent, simple, and non-aggressive (redefining of standard +page styles is optional). Using the package with names of standard +page styles as options, you can easy decorate your document with +header/footer rules. For example, the command +\begin{center} +\|\usepackage[headings]{nccfancyhdr}| +\end{center} +sets the \|headings| page style and provides it with the +decorative rule at the header. Header width control is improved +with two commands, namely \|\extendedheaders| (extended upon +marginal notes) and \|\normalheaders|. The \|\thispagestyle| +command correctly works with the fancy page style (in fancyhdr, it +didn't work because of use of global definitions). A new page +style can be easy created with the help of the \|\newpagestyle| +command and fancy mark commands. + +\Package{nccfloats} Wraps \LaTeX\ floats with service commands +\|\fig|, \|\tabl|, \|\figs|, \|\tabls|, introduces the \|\minifig| +and \|\minitabl| commands preparing figure and table in a minipage +with possible use of \|\caption| within, and \|\sidefig| and +\|\sidetabl| used for placement of minifloats next to surrounding +text on the outer side of page. + +\Package{nccfoots} The package implements commands for generating +footnotes with manual marks. For example, to mark footnote by star +you can write +\begin{center} + \|\Footnote{$*$}{Footnote text}|. +\end{center} + +\Package{nccmath} Extension of the \Pack{amsmath} package. Its +main aim is to combine \AmS's typesetting of display equations and +NCC-\LaTeX's one. In \Pack{amsmath}, the \|eqnarray| environment +leaves unchanged. This package redefines \|eqnarray| to allow +using of \Pack{amsmath} tag control features and display breaks. +Inter-column distance in \|eqnarray| is reduced to the distance +typical for relation operations. All columns are prepared in the +\|\displaystyle|. A new \|darray| environment is a mix of the +\AmS's \|aligned| environment and \LaTeX's \|array| environment. +It is typed out in the same way as the \|aligned| environment but +has columns definition parameter as in \|array| environment. The +use of column specifications is restricted to the necessary +commands only: \|l|, \|c|, \|r|, \|@|, and \|*| are allowed. The +implementation has no conflicts with the packages redefining +arrays. The \|fleqn| and \|ceqn| environments allow dynamically +change the alignment of display formulas to flushed left or to +centered alignment. Some additional commands are introduced also. + +\Package{nccparskip} Useful for documents with non-zero skips +between paragraphs. In this case, the additional vertical space +inserted by lists is unlikely. The package provides identical +distance between all paragraphs except sectioning markup commands. It +redefines control list commands and suppress \|\topskip|, +\|\partopskip|, and \|\itemsep| in lists. As a result, the +distance between ordinary paragraphs and paragraphs prepared by +lists is the same. The \|\SetParskip{distance}| command controls +this distance. + +\Package{nccpic} Envelop for the \Pack{graphicx} package. It +customizes graphics extensions list for dvips driver. You need not +specify a graphics file extension when use the \|\includegraphics| +command. Depending on a dvi-driver specified, a graphics file with +an appropriate extension is searched. So, you only need to create +a number of versions of a graphics file in different formats (for +example, `.bmp' for dvips or Yap and `.png' for pdftex). After +that you can produce resulting `.ps' and `.pdf' file without any +changes in the source file. The recommended storage for graphics +files is the `graphics/' subdirectory of the directory the `.tex' +file is translated. Some additional commands are introduced also. + +\Package{nccrules} Implements two commands, \|\dashrule| and +\|\dashrulefill|, which compose dashed (multi)lines. Two footnote +rule generation commands, \|\newfootnoterule| and +\|\newfootnotedashrule|, are useful in conjunction with the +\|manyfoot| package. + +\Package{nccsect} Extension of \LaTeX's section, caption, and +toc-entries generation technique. The package contains many +improvements in comparison with the base \LaTeX's implementation. +The most interesting of them are: +\begin{itemize} +\item simple declaring of sections of any level (including +sections of 0th level and captions for floats); + +\item user-controlled typeout for display sections (user can +select one of the following typeout styles: \|hangindent|, +\|hangindent*|, \|parindent|, \|parindent*|, +\|hangparindent|, \|hangparindent*|, \|center|, and +\|centerlast|);{\sloppy\par} + +\item new section styles can be easy constructed with the help of +two style definition commands; + +\item customizing of section or caption tag by the manner similar +to \AmS\ equation tag; + +\item simple declaring of toc-entries using prototypes for +calculation of hang indentations; + +\item \|\numberline| command newer overlaps the text going after; + +\item \|\PnumPrototype| command is used for calculation of right +margin in table of contents; + +\item different captions for different float types; + +\item simple handling of new types of floats (after registration of +a new float in the package, you can declare a caption and toc-entry +for it; be sure that the \|\chapter| command will automatically +produce a vertical skip in a toc for the new float also). +\end{itemize} + +\Package{nccstretch} Implements the \|\stretchwith| command that +stretches a text inserting something between every pair of +neighbour tokens. + +\Package{nccthm} Yet another extension to the \|\newtheorem| +command. The following orthogonal properties of theorems are used: +\begin{desclist}{\it}{\/}[numbering mode] +\item[numbering mode] is standard or \textit{apar\/} (a number +before header); + +\item[theorem type] defines an appearance of a theorem (what fonts +are used for title, comment, and body). The `theorem' and +`remark' types a predefined; + +\item[indent style] margin, nomargin, indent, noindent (selected +in package options); + +\item[break style] do break after header or not? Hardcoded when a +new theorem is declared. Can be overridden on the fly for concrete +math statement. +\end{desclist} + +Easy customization of spacing and commands inserted at the end of +theorem headers. +Two types of Q.E.D. symbol (white and black). The \|\proof| +command is introduced. The \|\newtheoremtype| command allows +create new theorem types. The \|\like|\textit{type\/} command is +automatically created for every new type. It simplifies typeout +of rare math statements. Instead of creation of a new theorem +environment you can use +\begin{center} +\|\liketheorem{Title}{Number}[Comment]| +\end{center} +for it, or \|\likeremark|, etc. Every theorem environment and +theorem type can be redefined with \|\renewtheorem| and +\|\renewtheoremtype|. Counters of all theorem-like environments +are dynamic (the \Pack{dcounter} package is used). So, they are +created at the first use. This is very helpful for package writer. +A number of theorem-like environments can be created in a package +or class, and a user only selects the count style for them (in +simple case this can be done with only one \|\countstyle| command +in the document preamble). + + +\Package{textarea} Allows expand the text area of a document +on other areas: footer, header, and margin. There are two +ways for such expansion~--- temporary expansion of a current +page on the header using a special negative vertical skip, +or global change of page layout parameters with possibility +of later restoration them to the original values. +All these actions should be applied at the beginning of page. + +\Package{tocenter} Provides two commands, namely \|\ToCenter| and +\|\FromMargins|, simplifying the customization of page layout. It +is now easy to change text width and height and center the text +area on the page (the header, footer, and marginal note fields are +optionally taken into consideration). Other way is like-Word +declaring of paper layout: you set margins from the left, right, +top, and bottom edges of page. + +\Package{topsection} Implements an unnumbered top-level section +(\|\chapter| in books and reports or \|\section| in articles) in +class-independent way. Such a section is used as a title for +standard document sections such as table of contents, index, +bibliography, etc. Using this command allows simplify the +definition or redefinition of standard document environments. + +\Package{watermark} Provides watermarks on output pages. A +watermark is some text or picture printed at the background of +paper. A watermark is usually stored in the page header. This way +is inconvenient: it needs redefinition of page style commands. We +use another method that is orthogonal to page mark commands and +needs no redefinition of page marks. The left and right watermarks +are allowed. Temporary \|\thiswatermark| acts on the current page +only. Using this way it is easy to replace a page header on a +page by your own page header with the \|\thispageheading| command. + +\end{document} diff --git a/macros/latex/contrib/ncctools/source/textarea.dtx b/macros/latex/contrib/ncctools/source/textarea.dtx new file mode 100644 index 0000000000..b19e259ace --- /dev/null +++ b/macros/latex/contrib/ncctools/source/textarea.dtx @@ -0,0 +1,236 @@ +% \iffalse +%% +%% File: textarea.dtx Copyright (C) 2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{textarea} +% [2005/12/26 v1.0 Text area control (NCC)] +% +% \changes{v1.0}{2005/12/26}{Initial version} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{textarea} +\GetFileInfo{textarea.sty} +\begin{document} +\title{The \textsf{textarea} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{textarea.dtx} +\end{document} +% +% \fi +% +% The package allows expand the text area of a document on other +% areas: footer, header, and margin. There are two ways for such +% expansion --- temporary expansion of a current page on the header using +% a special negative vertical skip, or global change of page layout +% parameters with possibility of later restoration them to the original +% values. All these actions should be applied at the beginning of page. +% +% \section{User Interface} +% +% \DescribeMacro\StartFromTextArea +% Applied at the beginning of page, it allows using the non-starred +% form of the |\vspace| command after it. The introduced command provides +% exact vertical skips at the beginning of page. Unlike it, the standard +% \LaTeX's |\vspace*| command skips more space at the beginning of page +% than it is required in its parameter. So, using the +% |\StartFromTextArea| command prevents +% incorrect spacing at the beginning of page. +% +% \DescribeMacro\StartFromHeaderArea +% Applied at the beginning of page, it adjusts the beginning of text area +% to the header area by inserting a negative vertical skip. The header +% of this page should be empty. Otherwise, the consequent text will +% overprint the header. +% +% \DescribeMacro{\ExpandTextArea\oarg{hfm}} +% Expands the text area on other areas of page by changing page layout +% parameters. It can be used in one-column mode only. +% The letters in optional argument mean the following: |h| (header), +% |f| (footer), and |m| (margins). If an optional argument is omitted +% or equals to |[*]|, the temporary expansion to the header is applied +% with the |\StartFromHeaderArea| command. Anyway, you can use the +% non-starred form of the |\vspace| command after expansion of the +% text area. +% +% When a text area is expanded (non-temporary), the repeated call of +% this command is disallowed. +% +% \DescribeMacro\RestoreTextArea +% Restores page layout parameters to their previous values. After that, +% the |\ExpandTextArea| command can be applied again. +% +% \DescribeMacro\NCC@restoretextarea +% This hook can be used to provide an automatic restoration of the text +% area. In \textbf{ncc} class, we use it as follows: set it empty at +% the beginning of |titlepage| environment and call this command at +% the end of |titlepage| environment. So, if the text area will be +% expanded within the |titlepage| environment, it will be automatically +% restored at the end of it. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\StartFromTextArea} +% \begin{macro}{\StartFromHeaderArea} +% Both these commands are defined in two packages: in this and in +% \textbf{nccsect}. To be sure that the commands are specified +% in these packages only, we mutually test packages to be loaded. +% \begin{macrocode} +%<*package> +\@ifpackageloaded{nccsect}{}{% + \newcommand\StartFromTextArea{\par + {\parskip\z@ \strut\par}\vskip -\baselineskip + } + \newcommand\StartFromHeaderArea{% + \StartFromTextArea + \vskip -\headsep \vskip -\ht\strutbox + } +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\RestoreTextArea} +% This command is usually empty. But it is globally redefined +% when the layout of page is modified by the |\ExpandTextArea| +% command. +% \begin{macrocode} +\newcommand*\RestoreTextArea{} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ExpandTextArea} +% This command should be applied at the beginning of page +% in one-column mode only. +% \begin{macrocode} +\newcommand*\ExpandTextArea[1][*]{% + \if@twocolumn + \PackageError{textarea}% + {The \string\ExpandTextArea\space command\MessageBreak + cannot work in two-column mode}{}% +% \end{macrocode} +% Test for temporary expansion mode and do it. +% \begin{macrocode} + \else + \def\@tempa{*}\edef\@tempb{#1}% + \ifx\@tempa\@tempb + \StartFromHeaderArea +% \end{macrocode} +% Otherwise, apply the permanent expansion but in the only case if +% it was not already applied. +% \begin{macrocode} + \else + \ifx\RestoreTextArea\@empty +% \end{macrocode} +% |\NCC@|\meta{x} hooks will be applied right here to modify the layout and +% |\NCC@resore@|\meta{x} hooks will applied later when the original layout +% will be restored. +% \begin{macrocode} + \let\NCC@h\@empty \global\let\NCC@restore@h\@empty + \let\NCC@f\@empty \global\let\NCC@restore@f\@empty + \let\NCC@m\@empty \global\let\NCC@restore@m\@empty +% \end{macrocode} +% Analyze letters in the optional parameter and prepare the respective hooks. +% The first parameter in all adjustment commands is a sign of adjustment: +% the empty value means adjust and the minus sign means restore. +% \begin{macrocode} + \expandafter\@tfor\expandafter\@tempa\expandafter:\expandafter=#1\do{% + \if h\@tempa + \def\NCC@h{\NCC@adjusttoheader{}}% + \gdef\NCC@restore@h{\NCC@adjusttoheader-}% + \else + \if f\@tempa + \def\NCC@f{\NCC@adjusttofooter{}}% + \gdef\NCC@restore@f{\NCC@adjusttofooter-}% + \else + \if m\@tempa + \if@reversemargin \@tempcnta\@ne \else \@tempcnta\tw@ \fi + \edef\NCC@m{\noexpand\NCC@adjusttomargin{}{\the\@tempcnta}}% + \xdef\NCC@restore@m{\noexpand\NCC@adjusttomargin-{\the\@tempcnta}}% + \fi + \fi + \fi + }% +% \end{macrocode} +% Modify the layout, apply the |\StartFromTextArea| command, and prepare +% the |\RestoreTextArea| command and the auto-restoration hook. +% \begin{macrocode} + \NCC@h\NCC@f\NCC@m + \StartFromTextArea + \gdef\RestoreTextArea{% + \NCC@restore@h\NCC@restore@f\NCC@restore@m + \global\let\RestoreTextArea\@empty + }% + \def\NCC@restoretextarea{\RestoreTextArea}% + \fi + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@adjusttoheader} +% Adjust text height parameters and |\topmargin|. +% \begin{macrocode} +\def\NCC@adjusttoheader#1{% + \@tempdima #1\headheight + \advance\@tempdima #1\headsep + \global\advance\textheight\@tempdima + \global\advance\topmargin-\@tempdima + \global\@colht\textheight + \global\@colroom\textheight + \global\vsize\textheight +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@adjusttofooter} +% Adjust text height parameters. +% \begin{macrocode} +\def\NCC@adjusttofooter#1{% + \global\advance\textheight#1\footskip + \global\@colht\textheight + \global\@colroom\textheight + \global\vsize\textheight +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@adjusttomargin} +% Adjust text width parameters, |\oddsidemargin| or +% |\evensidemargin|. The second parameter specifies +% the mode of marginal notes: reverse (1) or normal (2) margins. +% \begin{macrocode} +\def\NCC@adjusttomargin#1#2{% + \@tempdima #1\marginparwidth + \advance\@tempdima #1\marginparsep + \@tempcnta#2% + \ifodd\@tempcnta + \global\advance\oddsidemargin -\@tempdima + \else + \global\advance\evensidemargin -\@tempdima + \fi + \global\advance\textwidth\@tempdima + \global\columnwidth\textwidth + \global\linewidth\textwidth + \global\hsize\textwidth +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\NCC@restoretextarea} +% Text area auto-restoration hook. +% \begin{macrocode} +\let\NCC@restoretextarea\@empty +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/tocenter.dtx b/macros/latex/contrib/ncctools/source/tocenter.dtx new file mode 100644 index 0000000000..21193964f7 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/tocenter.dtx @@ -0,0 +1,315 @@ +% \iffalse +%% +%% File: tocenter.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{tocenter} +% [2004/12/09 v1.1 Centering Page Layout (NCC)] +% +% \changes{v1.0}{2002/01/31}{This version was uploaded to CTAN} +% \changes{v1.1}{2004/12/09}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{tocenter} +\GetFileInfo{tocenter.sty} +\begin{document} +\title{The \textsf{tocenter} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{tocenter.dtx} +\end{document} +% +% \fi +% +% The package provides commands +% customizing the layout parameters of a documents. +% +% \section{User Interface} +% +% \DescribeMacro{\ToCenter} +% The |\ToCenter|\oarg{hfm}\marg{text-width}\marg{text-height} command +% calculates margins in such a way to center the specified text area +% together with header/footer/marginals areas on a sheet of paper. +% The optional \meta{hfm} parameter specifies what additional areas take into +% account while centering. It is a combination of three letters |h| (headers), +% |f| (footers), and |m| (marginal notes). If this parameters is omitted, +% additional areas are ignored while calculations. For example, +% the following command +% \begin{quote} +% |\ToCenter[h]{\textwidth}{\textheight}| +% \end{quote} +% centers the text+header area on the page. The text height and wight +% are not changed here. This command is useful in books without marginal +% notes. +% +% \DescribeMacro{\FromMargins} +% The |\FromMargins|\oarg{hfm}\marg{left}\marg{right}\marg{top}\marg{bottom} +% command calculates the page layout parameters in the MS Word-like style. +% It sets page margins to the values specified in the last four +% parameters and calculates the width and +% height of the text area in such a way to satisfy the requirements. +% For example, the command +% \begin{quote} +% |\FromMargins[hf]{20mm}{10mm}{25mm}{15mm}| +% \end{quote} +% calculates the text area dimensions and margins in such a way to +% provide 20~mm distance from the left edge of the page, 10~mm +% distance from the right edge, 25~mm distance from the top edge, and +% 15~mm distance from the bottom edge in assumption that header and +% footer are in use. +% +% If twoside mode is turned on, the left and right margins specified +% in the |\FromMargins| command are considered for odd pages. +% For even pages, their values are swapped. +% +% If |m|-letter is specified in the optional parameter, the margins are +% determined depending on two-side and two-column switches. In two-column mode, +% marginal notes are posed on both sides of paper, but in one-column mode +% the marginal notes are posed on the outer side of a page in two-side mode +% and to the right of the text area in one-side mode. All these specifics +% is taken into account while calculations of text margins. +% The reverse margin mode is also supported. +% +% \DescribeMacro{\ToCenter*} +% \DescribeMacro{\FromMargins*} +% The star-forms of these commands +% \begin{quote} +% |\ToCenter*|\marg{text-width}\marg{text-height}\\ +% |\FromMargins*|\marg{left}\marg{right}\marg{top}\marg{bottom} +% \end{quote} +% are intended for positioning of simple documents without headers, +% footers, marginal notes, cross-references, and table of contents. +% Additionally, the empty page style is set and the writing to aux-file +% is suppressed. +% +% \textit{All mentioned commands are allowed in the preamble only.} +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\NCC@pos} +% The |\NCC@pos|\marg{hfm} command parses the \meta{hfm} parameter +% and prepares |\NCC@h|\marg{register}, |\NCC@f|\marg{register}, +% and |\NCC@m|\marg{register} commands to adjust values of skip +% registers. The |\NCC@pos| command is also useful in the |cropmark| package. +% \begin{macrocode} +%<*package> +\def\NCC@pos#1{% + \let\NCC@h\@gobble \let\NCC@f\@gobble \let\NCC@m\@gobble + \@tfor\@tempa:=#1\do{% +% \end{macrocode} +% If |h|-letter appears, the |\NCC@h| hook will adjust the value of register +% on the header height and separation: +% \begin{macrocode} + \if h\@tempa + \def\NCC@h##1{\advance##1\headsep \advance##1\headheight}% + \else +% \end{macrocode} +% If |f|-letter appears, the |\NCC@f| hook will adjust the value of register +% on the footer skip distance: +% \begin{macrocode} + \if f\@tempa + \def\NCC@f##1{\advance##1\footskip}% + \else +% \end{macrocode} +% If |m|-letter appears, the |\NCC@m| hook will adjust the value of register +% on the width and separation of marginal paragraphs: +% \begin{macrocode} + \if m\@tempa + \def\NCC@m##1{\advance##1\marginparwidth + \advance##1\marginparsep}% + \fi + \fi + \fi + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\ToCenter} +% The star-form of this command differs in the omitted +% optional parameter, empty page style, and suppressed +% writing to external files: +% \begin{macrocode} +\newcommand{\ToCenter}{% + \@ifstar{\pagestyle{empty}\nofiles\NCC@center[]}{\NCC@center}% +} +\@onlypreamble\ToCenter +% \end{macrocode} +% At the first, we parse the \meta{hfm} parameter: +% \begin{macrocode} +\newcommand*{\NCC@center}[3][]{\NCC@pos{#1}% +% \end{macrocode} +% Start calculations from horizontal margins and width: +% set text width and calculate in |\@tempdima| the +% whole width of area to be centered. +% \begin{macrocode} + \setlength\textwidth{#2}% + \@tempdima\textwidth \NCC@m\@tempdima +% \end{macrocode} +% In two-column mode, margins appear on both sides of text. +% We must add the width of marginal area again to |\@tempdima|: +% \begin{macrocode} + \if@twocolumn + \NCC@m\@tempdima +% \end{macrocode} +% In two-column mode, we set the odd and even side margins to +% \begin{quote} +% |\NCC@m{(\paperwidth-\@tempdima)/2}|: +% \end{quote} +% \begin{macrocode} + \@tempdimb\paperwidth + \advance\@tempdimb -\@tempdima + \@tempdima .5\@tempdimb \NCC@m\@tempdima + \oddsidemargin\@tempdima + \evensidemargin\@tempdima +% \end{macrocode} +% In one-column mode with reverse margins, we set +% \begin{quote} +% |\evensidemargin:=(\paperwidth-\@tempdima)/2|\\ +% |\oddsidemargin:=\NCC@m{(\paperwidth-\@tempdima)/2}| +% \end{quote} +% and, with normal margins, we set +% \begin{quote} +% |\oddsidemargin:=(\paperwidth-\@tempdima)/2|\\ +% |\evensidemargin:=\NCC@m{(\paperwidth-\@tempdima)/2}| +% \end{quote} +% \begin{macrocode} + \else + \@tempdimb\paperwidth + \advance\@tempdimb -\@tempdima \@tempdima .5\@tempdimb + \if@reversemargin + \evensidemargin\@tempdima + \NCC@m\@tempdima + \oddsidemargin\@tempdima + \else + \oddsidemargin\@tempdima + \NCC@m\@tempdima + \evensidemargin\@tempdima + \fi + \fi +% \end{macrocode} +% Now we calculate the vertical layout parameters. +% Again, in the |\@tempdima| we calculate the full +% height of useful areas and set the top margin to +% \begin{quote} +% |(\paperwidth-\@tempdima)/2| +% \end{quote} +% if headers are in use. +% \begin{macrocode} + \setlength\textheight{#3}% + \@tempdima\textheight \NCC@h\@tempdima \NCC@f\@tempdima + \@tempdimb\paperheight + \advance\@tempdimb -\@tempdima + \topmargin .5\@tempdimb +% \end{macrocode} +% Otherwise, we decrease the value of top margin on the height +% and separation of header: +% \begin{macrocode} + \ifx\NCC@h\@gobble + \advance\topmargin -\headsep + \advance\topmargin -\headheight + \fi +% \end{macrocode} +% Do final correction of all margins: decrease their values +% on 1~inch. This compensates the default adjustment applied by +% dvi drivers. +% \begin{macrocode} + \advance \oddsidemargin -1in + \advance \evensidemargin -1in + \advance \topmargin -1in +} +\@onlypreamble\NCC@center +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\FromMargins} +% Finally, we implement the |\FromMargins| command. +% \begin{macrocode} +\newcommand{\FromMargins}{% + \@ifstar{\pagestyle{empty}\nofiles\NCC@margin[]}{\NCC@margin}% +} +\@onlypreamble\FromMargins +% \end{macrocode} +% Again, start from parsing the \meta{hfm} parameter: +% \begin{macrocode} +\newcommand*{\NCC@margin}[5][]{\NCC@pos{#1}% +% \end{macrocode} +% Calculate horizontal parameters at first. +% In two-side mode, the left margin is equal to the +% |\oddsidemargin| and the right margin is equal to the +% |\evensidemargin|. In one-side mode, the +% |\oddsidemargin| is calculated in the same manner +% and the |\evensidemargin| is useless. So, we need +% not distinguish one-side and two-side modes here +% and do all things as for two-side mode. +% \begin{macrocode} + \setlength\oddsidemargin{#2}% + \setlength\evensidemargin{#3}% +% \end{macrocode} +% Calculate in |\@tempdima| the amount of space occupied +% by horizontal margins and marginal notes. +% \begin{macrocode} + \@tempdima\oddsidemargin \advance\@tempdima\evensidemargin + \NCC@m\@tempdima +% \end{macrocode} +% In two-column mode, marginal notes should be counted twice +% and the values of odd and even margins must be adjusted +% on the marginal width. +% \begin{macrocode} + \if@twocolumn + \NCC@m\@tempdima + \textwidth\paperwidth + \advance\textwidth -\@tempdima + \NCC@m\oddsidemargin \NCC@m\evensidemargin +% \end{macrocode} +% In one-column mode, we must adjust only one margin +% depending on placement of marginal notes. +% \begin{macrocode} + \else + \textwidth\paperwidth + \advance\textwidth -\@tempdima + \if@reversemargin + \NCC@m\oddsidemargin + \else + \NCC@m\evensidemargin + \fi + \fi +% \end{macrocode} +% Now we calculate the vertical layout parameters. +% We set the |\@tempdima| to the sum of +% top margin, bottom margin, header, and footer. +% \begin{macrocode} + \setlength\topmargin{#4}% + \setlength\@tempdima{#5}\advance\@tempdima\topmargin + \NCC@h\@tempdima \NCC@f\@tempdima +% \end{macrocode} +% The rest of page is the text height: +% \begin{macrocode} + \textheight\paperheight + \advance\textheight -\@tempdima +% \end{macrocode} +% We must decrease the |\topmargin| on the header separation +% and height if headers are useless. +% \begin{macrocode} + \ifx\NCC@h\@gobble + \advance\topmargin -\headsep + \advance\topmargin -\headheight + \fi +% \end{macrocode} +% Do final correction of all margins: +% \begin{macrocode} + \advance \oddsidemargin -1in + \advance \evensidemargin -1in + \advance \topmargin -1in +} +\@onlypreamble\NCC@margin +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/topsection.dtx b/macros/latex/contrib/ncctools/source/topsection.dtx new file mode 100644 index 0000000000..905b702f94 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/topsection.dtx @@ -0,0 +1,133 @@ +% \iffalse +%% +%% File: topsection.dtx Copyright (C) 2005 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{topsection} +% [2005/12/24 v1.0 Top section definition (NCC)] +% +% \changes{v1.0}{2005/12/24}{Initial version} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{topsection} +\GetFileInfo{topsection.sty} +\begin{document} +\title{The \textsf{topsection} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{topsection.dtx} +\end{document} +% +% \fi +% \DescribeMacro\topsection +% This package implements an unnumbered top-level section +% (chapter in books and reports or section in articles): +% \begin{quote} +% |\topsection|\marg{title} +% \end{quote} +% Such a section is used when table of contents, index, or +% bibliography are prepared. So, the |\topsection| command can +% be used to make such definitions or redefinitions to be independent +% on class in use. The command definition is compatible with standard +% \textbf{article}, \textbf{book}, and \textbf{report} classes +% and also with the \textbf{ncc} class. +% +% \DescribeMacro\@iftopchapter +% To distinguish what type of top section is used, the following +% conditional command is also specified: +% \begin{quote} +% |\@iftopchapter|\marg{chapter-clause}\marg{section-clause} +% \end{quote} +% The \meta{chapter-clause} is executed if top section is the |\chapter|. +% Otherwise, the \meta{section-clause} is executed. +% +% If the \textbf{nccsect} +% package is used together with this package, the top-section title +% is also written to the aux-file. To avoid this, +% use |\skipwritingtoaux| modifier just before the top section. +% +% \StopEventually{} +% +% \section{The Implementation} +% +% At first, we provide |\@mkboth| command to be sure that +% it is defined (in \textbf{ncc} class |\@mkboth| useless and +% so it does not defined here). If it does not exist yet, its +% default value will be equal to \LaTeX's |\@gobbletwo| command. +% \begin{macrocode} +%<*package> +\providecommand\@mkboth[2]{} +% \end{macrocode} +% +% \begin{macro}{\NCC@topsection} +% \begin{macro}{\@iftopchapter} +% The |\NCC@topsection| macro contains a command to be used as a +% top section. To select an appropriate command, we test the +% |\chapter| command to be defined. The |\@iftopchapter| macro is +% also specified here. +% \begin{macrocode} +\newcommand\@iftopchapter[2]{} +\@ifundefined{chapter}{% + \def\NCC@topsection{\section}% + \let\@iftopchapter\@secondoftwo +}{% + \def\NCC@topsection{\chapter}% + \let\@iftopchapter\@firstoftwo +} +% \end{macrocode} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\topsection} +% Now we define the |\topsection| command. When the package is loaded, +% we specify the command to be a new one. Its real definition +% is done at the beginning of document when all packages are +% already loaded and an appropriate decision can be selected. +% \begin{macrocode} +\newcommand*\topsection[1]{} +\AtBeginDocument{% +% \end{macrocode} +% If the \textbf{nccsect} package is in use, we define the |\topsection| +% command using the basic form of the corresponding sectioning command. +% The |\noheadingtag| modifier turns off the top-section numbering. +% In the definition, we test the |\@mkboth| command to be equal to +% |\@gobbletwo|. This situation appears in two cases: when the page +% style other than |headings| is used or when the \textbf{ncc} class +% is loaded. In the last case, the appropriate page header is already +% specified in sectioning command with corresponding mark-command +% (|\chaptermark| or |\sectionmark| updates both headers by the same +% manner). So, in both these cases we need not use the |\@mkboth|. +% But in other cases we specify the header mark in standard way +% and use the |\norunninghead| modifier to skip updating headers +% inside the sectioning command. +% \begin{macrocode} + \@ifpackageloaded{nccsect}{% + \renewcommand*\topsection[1]{% + \ifx\@mkboth\@gobbletwo + \noheadingtag \NCC@topsection{#1}% + \else + \norunninghead + \noheadingtag \NCC@topsection{#1}% + \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}% + \fi + }% +% \end{macrocode} +% When the \textbf{nccsect} package does not loaded, the top-section +% definition uses just the same technique as in standard classes. +% \begin{macrocode} + }{% + \renewcommand*\topsection[1]{% + \NCC@topsection*{#1}% + \@mkboth{\MakeUppercase{#1}}{\MakeUppercase{#1}}% + }% + }% +} +% +% \end{macrocode} +% \end{macro} +\endinput diff --git a/macros/latex/contrib/ncctools/source/watermark.dtx b/macros/latex/contrib/ncctools/source/watermark.dtx new file mode 100644 index 0000000000..81f9404646 --- /dev/null +++ b/macros/latex/contrib/ncctools/source/watermark.dtx @@ -0,0 +1,217 @@ +% \iffalse +%% +%% File: watermark.dtx Copyright (C) 2002--2004 by Alexander I. Rozhenko +%% +%\NeedsTeXFormat{LaTeX2e} +%\ProvidesPackage{watermark} +% [2004/12/09 v1.1 Watermarks (NCC)] +% +% \changes{v1.00}{2002/01/29}{This version is uploaded to CTAN} +% \changes{v1.01}{2002/02/13}{Hbox underfull removed in empty |\thispageheading|} +% \changes{v1.02}{2003/04/04}{Hbox underfull removed in plain and empty styles} +% \changes{v1.1}{2004/12/09}{Simplify the implementation of |\thispageheading|} +% \changes{v1.1}{2004/12/09}{Documentation was prepared} +% +%<*driver> +\let\makeindex\relax +\documentclass{ltxdoc} +\usepackage{watermark,nccboxes} +\GetFileInfo{watermark.sty} +\begin{document} +\title{The \textsf{watermark} package\thanks{This file + has version number \fileversion, last + revised \filedate.}} +\author{Alexander I. Rozhenko\\rozhenko@oapmg.sscc.ru} +\date{\filedate} +\maketitle +\DocInput{watermark.dtx} +\end{document} +% +% \fi +% +% \thispageheading{This heading was prepared with the +% {\tt\string\thispageheading} command.\\ +% It allows long multi-line headings!} +% +% \section{User Interface} +% +% \DescribeMacro\watermark +% \DescribeMacro\leftwatermark +% \DescribeMacro\rightwatermark +% \DescribeMacro\thiswatermark +% The package provides watermarks on output pages. A watermark is +% some text or picture printed at the background of paper. +% A watermark is prepared in a picture box stored at the +% beginning of header. So, you should place +% the watermark material with LaTeX's |\put| and |\multiput| commands. +% Allowed watermark commands are shown in the table: +% \begin{center}\catcode`|=12 +% \small +% \renewcommand\cboxstyle{\footnotesize} +% \begin{tabular}{|l|l|}\hline +% \hfill\cbox{Command}\hfill\mbox{} & +% \hfill\cbox{Meaning}\hfill\mbox{}\\\hline +% \Strut/.8/ +% \verb+\watermark+\marg{body} & +% Set the same watermark for all pages\\ +% \verb+\leftwatermark+\marg{body} & +% Set the even-page watermark\\ +% \verb+\rightwatermark+\marg{body} & +% Set the odd-page watermark\\ +% \verb+\thiswatermark+\marg{body} & +% Set a watermark for the current page only \\ +% \hline +% \end{tabular} +% \end{center} +% In one-side mode, the |\leftwatermark| is ignored and the +% |\rightwatermark| is applied to all pages. +% +% \DescribeMacro\thispageheading +% The package also provides the command +% |\thispageheading|\marg{heading} +% which replaces a heading for the current page to the specified +% multi-line heading. The heading is prepared in the parbox +% of the |\textwidth| width aligned on the top line. This +% command does not suppress watermarks. +% +% Examples of using watermarks are shown in the |ncccropmark| +% package. +% \StopEventually{} +% +% \section{The Implementation} +% +% \begin{macro}{\@begindvi} +% To support watermarks, we use the |\@begindvi| hook from the output +% routine. This hook works only once at the beginning of dvi, +% but some packages (e.g. |hyperref|) also use it for their own needs. +% So, we redefine it at the beginning of document in such a way to +% accurately save its behaviour after the first call when it can be +% redefined by other packages. All the we need from this hook~--- +% to call the |\WMK@insert| command every time when the output +% routine composes a new page. +% \begin{macrocode} +%<*package> +\AtBeginDocument{ + \let\WMK@begindvi\@begindvi + \def\@begindvi{% +% \end{macrocode} +% Apply saved |\@begindvi| hook and then call the +% |\WMK@insert| command: +% \begin{macrocode} + \WMK@begindvi + \WMK@insert +% \end{macrocode} +% After that we must redefine the |\@begindvi| hook, +% because it is already redefined here to the |\@empty| value +% (or to something else if another package using this hook is loaded). +% We save its new meaning in the |\WMK@begindvi| command +% and redefine the |\@begindvi|: +% \begin{macrocode} + \global\let\WMK@begindvi\@begindvi + \gdef\@begindvi{\WMK@begindvi\WMK@insert}% + }% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\WMK@insert} +% The command redefines the current header and inserts the +% |\WMK@hook| at the beginning of header. +% A box produced by this hook has zero natural sizes. +% \begin{macrocode} +\def\WMK@insert{% + \let\WMK@head\@thehead + \def\@thehead{\WMK@hook\WMK@head}% +} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\WMK@hook} +% The command applies +% this watermark (|\WMK@this|), odd watermark (|\WMK@odd|), +% or even watermark (|\WMK@even|). The watermarks are prepared +% within the picture environment: +% \begin{macrocode} +\def\WMK@hook{% + \begin{picture}(0,0)\relax + \ifx\WMK@this\relax + \if@twoside + \ifodd\c@page\WMK@odd\else\WMK@even\fi + \else + \WMK@odd + \fi + \else + \WMK@this \global\let\WMK@this\relax + \fi + \end{picture}% +% \end{macrocode} +% After that we test the header. At the first, we test the +% |\WMK@thishead| command. If it is specified, we let +% |\WMK@head| to |\WMK@thishead|. +% \begin{macrocode} + \ifx\WMK@thishead\relax \else + \let\WMK@head\WMK@thishead + \global\let\WMK@thishead\relax + \fi +% \end{macrocode} +% The original |\@thehead| command +% saved in |\WMK@head| can be defined with |\@oddhead| content +% or can be let to |\@oddhead| or |\@evenhead|. +% We test all these cases to recognize when the head is really empty. +% A head prepared with |\thispageheading| can be also empty. +% If the empty case is recognized, we insert the |\hfil| command +% to avoid underfull. +% \begin{macrocode} + \ifx\WMK@head\@empty \hfil + \else + \def\@tempa{\@oddhead}% + \ifx\WMK@head\@tempa + \ifx\@oddhead\@empty \hfil \fi + \fi + \fi +} +% \end{macrocode} +% \end{macro} +% +% Set defaults for this heading and watermarks. +% \begin{macrocode} +\let\WMK@thishead\relax +\let\WMK@this\relax +\let\WMK@odd\@empty +\let\WMK@even\@empty +% \end{macrocode} +% +% \begin{macro}{\watermark} +% \begin{macro}{\leftwatermark} +% \begin{macro}{\rightwatermark} +% \begin{macro}{\thiswatermark} +% Define watermark producing commands: +% \begin{macrocode} +\newcommand{\watermark}[1]{\leftwatermark{#1}\rightwatermark{#1}} +\newcommand{\leftwatermark}[1]{\gdef\WMK@even{#1}} +\newcommand{\rightwatermark}[1]{\gdef\WMK@odd{#1}} +\newcommand{\thiswatermark}[1]{\gdef\WMK@this{#1}} +% \end{macrocode} +% \end{macro} +% \end{macro} +% \end{macro} +% \end{macro} +% +% \begin{macro}{\thispageheading} +% Finally, define the |\thispageheading|\marg{heading} command. +% We especially test the case of empty heading and +% set |\WMK@thishead| to the |\@empty| value in this case. +% This allows avoiding underfull in the |\WMK@hook|. +% \begin{macrocode} +\newcommand{\thispageheading}[1]{% + \def\@tempa{#1}% + \ifx\@tempa\@empty + \global\let\WMK@thishead\@empty + \else + \gdef\WMK@thishead{\parbox[t]\textwidth{#1}}% + \fi +} +% +% \end{macrocode} +% \end{macro} +\endinput -- cgit v1.2.3