From e5d25989ee337ac9399ae9e50bed87559488814f Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sun, 24 Oct 2010 23:46:12 +0000 Subject: gmutils (24oct10) git-svn-id: svn://tug.org/texlive/trunk@20183 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/tex/latex/gmutils/gmmw.sty | 368 +++++++++++++++++++++++++++ 1 file changed, 368 insertions(+) create mode 100644 Master/texmf-dist/tex/latex/gmutils/gmmw.sty (limited to 'Master/texmf-dist/tex/latex/gmutils/gmmw.sty') diff --git a/Master/texmf-dist/tex/latex/gmutils/gmmw.sty b/Master/texmf-dist/tex/latex/gmutils/gmmw.sty new file mode 100644 index 00000000000..78adfffac76 --- /dev/null +++ b/Master/texmf-dist/tex/latex/gmutils/gmmw.sty @@ -0,0 +1,368 @@ +%% +%% \iffalse ^^A we skip the debug setting +\IfFileExists{\string~/bin/gen_and_xela}{\errorcontextlines=1000 }{} +%% \fi +%% ^^A $Id: TheUltimateMaster.gmd,v 0.250 2010/10/24 14:42:35 natror Exp natror $ +%% This is file “gmmw.sty” generated with the DocStrip utility. +%% +%% +%% The original source files were: +%% +%% gmutils/gmutils.gmd (with options: `mw') +%% +%% +%% Copyright © +%% by Grzegorz ‘Natror’ Murzynowski +%% natror (at) o2 (dot) pl +%% +%% This program 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. +%% +%% LPPL status: "author-maintained". +%% +%% +%% +%% For the documentation please refer to the file(s) +%% gmutils.{gmd,pdf}. +%% +%% +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{gmmw} + [2010/10/24 v0.993 improvements to the MWCLS classes (GM)] + + +%% +%% +%% ^^A\typeout{\unexpanded{#4}}%% +\RequirePackage{gmcommand} + + +\AtBeginDocument{% because we don't know when exactly \pk{hyperref} is + % loaded and maybe after this package. + \@ifpackageloaded{hyperref}{\newcounter{NoNumSecs}% + \setcounter{NoNumSecs}{617}% to make |\ref|ing to an unnumbered section + % visible (and funny?). + \def\gmu@hyperrefstepcounter{\refstepcounter{NoNumSecs}}% + \pdef\gmu@targetheading#1{% + \hypertarget{#1}{#1}}}% end of then + {\def\gmu@hyperrefstepcounter{}% + \def\gmu@targetheading#1{#1}}% end of else +}% of |\AtBeginDocument| + +\def\gmu@dontnumbersectionsoutofmainmatter{% + \if@mainmatter\else \HeadingNumberedfalse \fi} +\def\gmu@clearpagesduetoopenright{% + \if@openright\cleardoublepage\else \clearpage\fi} + +\long\def\@ifnotmw#1#2{\gmu@ifundefined{mw@sectionxx}{#1}{#2}} + +\@ifnotmw{}{% +\def\mw@sectionxx#1#2[#3]#4{% + \edef\mw@HeadingLevel{\csname #1@level\endcsname + \space}% space delimits level number! + \ifHeadingNumbered + \ifnum \mw@HeadingLevel>\c@secnumdepth \HeadingNumberedfalse \fi + % \nostanza line below is in |\gmu@ifundefined| to make it work in classes + % other than \pk{mwbk}\nostanza + \gmu@ifundefined{if@mainmatter}{}{\gmu@dontnumbersectionsoutofmainmatter} + \fi +%% \ifHeadingNumbered +%% \refstepcounter{#1}% +%% \protected@edef\HeadingNumber{\csname the#1\endcsname\relax}% +%% \else +%% \let\HeadingNumber\@empty +%% \fi + \def\HeadingRHeadText{#2}% + \def\HeadingTOCText{#3}% + \def\HeadingText{#4}% + \def\mw@HeadingType{#1}% + \if\mw@HeadingBreakBefore + \if@specialpage\else\thispagestyle{closing}\fi + \gmu@ifundefined{if@openright}{}{\gmu@clearpagesduetoopenright}% + \if\mw@HeadingBreakAfter + \thispagestyle{blank}\else + \thispagestyle{opening}\fi + \global\@topnum\z@ + \fi% of |\if\mw@HeadingBreakBefore| +%% + \ifHeadingNumbered + \refstepcounter{#1}% + \protected@edef\HeadingNumber{\csname the#1\endcsname\relax}% + \else + \let\HeadingNumber\@empty + \gmu@hyperrefstepcounter % we step an auxiliary counter to make a + % hyperref's label/target. + \fi% of |\ifHeadingNumbered| +%% + \if\mw@HeadingRunIn + \mw@runinheading + \else + \if\mw@HeadingWholeWidth + \if@twocolumn + \if\mw@HeadingBreakAfter + \onecolumn + \mw@normalheading + \pagebreak\relax + \if@twoside + \null + \thispagestyle{blank}% + \newpage + \fi% of |\if@twoside| + \twocolumn + \else + \@topnewpage[\mw@normalheading]% + \fi% of |\if\mw@HeadingBreakAfter| + \else + \mw@normalheading + \if\mw@HeadingBreakAfter\pagebreak\relax\fi + \fi% of |\if@twocolumn| + \else + \mw@normalheading + \if\mw@HeadingBreakAfter\pagebreak\relax\fi + \fi% of |\if\mw@HeadingWholeWidth| + \fi% of |\if\mw@HeadingRunIn| + } + + +\relaxen\SetSectionFormatting +\newcommand*\SetSectionFormatting[5][\empty]{% + \ifx\empty#1\relax\else% empty (not |\empty|!) |#1| also launches |\else|.\HideDef + \def\mw@HeadingRunIn{10}\def\mw@HeadingBreakBefore{10}% + \def\mw@HeadingBreakAfter{10}\def\mw@HeadingWholeWidth{10}% + \gmu@ifempty{#1}{}{\mw@processflags#1,\relax}% If |#1| is omitted, + % the flags are left unchanged. If |#1| is given, even as [], the + % flags are first cleared and then processed again. + \fi + \gmu@ifundefined{#2}{\@namedef{#2}{\mw@section{#2}}}{}% + \mw@secdef{#2}{@preskip} {#3}{2 oblig.}% + \mw@secdef{#2}{@head} {#4}{3 oblig.}% + \mw@secdef{#2}{@postskip}{#5}{4 oblig.}% + \ifx\empty#1\relax + \mw@secundef{#2@flags}{1 (optional)}% + \else\mw@setflags{#2}% \ResumeDef + \fi} + +\def\mw@secdef#1#2#3#4{% ^^B + \gmu@ifempty{#3} + {\mw@secundef{#1#2}{#4}} + {\@namedef{#1#2}{#3}}} + +\def\mw@secundef#1#2{% + \gmu@ifundefined{#1}{% + \ClassError{mwcls/gm}{% + command \bslash#1 undefined \MessageBreak + after \bslash SetSectionFormatting!!!\MessageBreak}{% + Provide the #2 argument of \bslash SetSectionFormatting.}}{}} + +\def\addtoheading#1#2{% + \n@melet{gmu@addtoheading@resa}{#1@head}% + \edef\gmu@addtoheading@resa{\unexpanded{#2}\@xa\unexpanded{\gmu@addtoheading@resa}}% + \n@melet{#1@head}{gmu@addtoheading@resa}% +} + +}% of |\@ifnotmw|'s else. + + +\@ifnotmw{}{% We proceed only in \acro{MWCLS}. + +\def\@afterheading{% + \@nobreaktrue + \xdef\gmu@prevsec{\mw@HeadingType}% added now + \everypar{% + \grelaxen\gmu@prevsec% added now. All the rest is original \LaTeX. + \if@nobreak + \@nobreakfalse + \clubpenalty \@M + \if@afterindent \else + {\setbox\z@\lastbox}% + \fi + \else + \clubpenalty \@clubpenalty + \everypar{}% + \fi}} + +\def\gmu@checkaftersec{% + \gmu@ifundefined{gmu@prevsec}{}{% + \ifgmu@postsec% an additional switch that is true by default but + % may be turned into an \cs{ifdim} in special + % cases, see line \ref{gmu@postsec}. + {\@xa\mw@getflags\@xa{\gmu@prevsec}% + \glet\gmu@checkaftersec@resa\mw@HeadingBreakAfter}% \UnDef + \if\mw@HeadingBreakBefore\def\gmu@checkaftersec@resa{11}\fi% if the + % current heading inserts page break before itself, all the play + % with vskips is irrelevant. + \if\gmu@checkaftersec@resa\else + \penalty10000\relax + \skip\z@=\csname\gmu@prevsec @postskip\endcsname\relax + \skip\tw@=\csname\mw@HeadingType @preskip\endcsname\relax + \gmu@ifundefined{\mw@HeadingType @twoheadskip}{% + \ifdim\skip\z@>\skip\tw@ + \vskip-\skip\z@% we strip off the post-skip of previous + % header if it's bigger than current pre-skip + \else + \vskip-\skip\tw@% we strip off the current pre-skip otherwise + \fi}{% But if the two-header-skip is defined, we put + % \emph{it} + \penalty10000 + \vskip-\skip\z@ + \penalty10000 + \vskip-\skip\tw@ + \penalty10000 + \vskip\csname\mw@HeadingType @twoheadskip\endcsname + \relax}% + \penalty10000 + \hrule height\z@\relax% to hide the last (un)skip before subsequent + % \incs{addvspace}s. \ilrr + \penalty10000 + \fi + \fi + }% of |\gmu@ifundefined{gmu@prevsec}| `else'. +}% of |\def\gmu@checkaftersec|. + +\def\ParanoidPostsec{% \label{gmu@postsec} this version of + % \inverb|\ifgmu@postsec| is intended for the special case of + % sections may contain no normal text, as while \pk{gmdoc}ing. + \def\ifgmu@postsec{% note this macro expands to an open \cs{if}. + \skip\z@=\csname\gmu@prevsec @postskip\endcsname\relax + \ifdim\lastskip=\skip\z@\relax% we play + % with the vskips only if the last skip is the previous + % heading's postskip (a~counter-example I~met while + % \pk{gmdoc}ing). + }} + +\let\ifgmu@postsec\iftrue + +\def\gmu@getaddvs#1\addvspace#2\gmu@getaddvs{% + \toks\z@={#1}% + \toks\tw@={#2}} + +\def\gmu@setheading#1{% + \@xa\gmu@getaddvs#1\gmu@getaddvs + \edef#1{% + \the\toks\z@\@nx\gmu@checkaftersec + \@nx\addvspace\the\toks\tw@}} + +\gmu@setheading\mw@normalheading +\gmu@setheading\mw@runinheading + +\def\SetTwoheadSkip#1#2{\@namedef{#1@twoheadskip}{#2}} + +}% of |\@ifnotmw|'s else. + + +\@ifnotmw{}{% We define this declaration only when in \pk{mwcls}. +\DeclareCommand\WPheadings{T{\chapter}}{% + \SetSectionFormatting[breakbefore,wholewidth] + {part}{\z@\@plus1fill}{}{\z@\@plus3fill}% + % + \IfValueF{#1}{% + \gmu@ifundefined{chapter}{}{% + \SetSectionFormatting[breakbefore,wholewidth] + {chapter} + {66\p@}% |{67\p@}|% for Adventor/Schola 0,95. + {\FormatHangHeading{\LARGE}} + {27\p@\@plus0,2\p@\@minus1\p@}% + }% + }% of unless |#1| + % + \SetTwoheadSkip{section}{27\p@\@plus0,5\p@}% + \SetSectionFormatting{section} + {24\p@\@plus0,5\p@\@minus5\p@}% ^^A {24\p@\@plus5\p@\@minus2\p@} + {\FormatHangHeading {\Large}} + {10\p@\@plus0,5\p@}% ed.\ Krajewska of ``Wiedza Powszechna'', as + % we understand her, wants the skip between a~heading and text + % to be rigid. + % + \SetTwoheadSkip{subsection}{11\p@\@plus0,5\p@\@minus1\p@}% + \SetSectionFormatting{subsection} + {19\p@\@plus0,4\p@\@minus6\p@} + {\FormatHangHeading {\large}}% 12/14 pt + {6\p@\@plus0,3\p@}% after-skip 6\,pt due to p.12, not to squeeze + % the before-skip too much. + % + \SetTwoheadSkip{subsubsection}{10\p@\@plus1,75\p@\@minus1\p@}% + \SetSectionFormatting{subsubsection} + {10\p@\@plus0,2\p@\@minus1\p@} + {\FormatHangHeading {\normalsize}} + {3\p@\@plus0,1\p@}% those little skips should be smaller than + % you calculate out of a~geometric progression, because the + % interline skip enlarges them. + % + \SetSectionFormatting[runin]{paragraph} + {7\p@\@plus0,15\p@\@minus1\p@} + {\FormatRunInHeading{\normalsize}} + {2\p@}% + % + \SetSectionFormatting[runin]{subparagraph} + {4\p@\@plus1\p@\@minus0,5\p@} + {\FormatRunInHeading{\normalsize}} + {\z@}% +}% of |\WPheadings| +}% of |\@ifnotmw| + +\@ifnotmw{% we are not in \pk{mwcls} and want to + % handle \pk{mwcls}-like sectionings i.e., those written with two + % optionals. + \def\gmu@secini{gm@la}% + \Store@Macros{% + \partmark \chaptermark \sectionmark \subsectionmark + \subsubsectionmark \paragraphmark}% + % \Define\gmu@secxx + \def\gmu@secxx#1#2[#3]#4{% + \ifx\gmu@secstar\@empty + % \nostanza a~little trick to allow + % a~special version of the heading just to the running head. + \@namedef{#1mark}##1{% we redefine \cs{\mark} to gobble its + % argument and to launch the stored true marking command on the + % appropriate argument. + \storedcsname{#1mark}{#2}% + \Restore@MacroSt{#1mark}% after we've done what we + % wanted we restore original |\#1mark|.\ilrr + }% + \def\gmu@secstar{[#3]}% if |\gmu@secstar| + % is empty, which means the sectioning command was written + % starless, we pass the `true' sectioning command |#3| as the + % optional argument. Otherwise the sectioning command was written + % with star so the `true' s.c.\ takes no optional. + \fi + \@xa\@xa\csname\gmu@secini#1\endcsname + \gmu@secstar{#4}}% +}{% we are in \pk{mwcls} and want to reverse MW's optionals order + % i.e., if there's just one optional, it should go both to toc and to + % running head. + \def\gmu@secini{gm@mw}% + % + \let\gmu@secmarkh\@gobble% in \pk{mwcls} there's no need to make + % tricks for special version to running headings. + % \Define\gmu@secxx + \def\gmu@secxx#1#2[#3]#4{% + \@xa\@xa\csname\gmu@secini#1\endcsname + \gmu@secstar[#2][#3]{#4}}% +} + +\def\gmu@sec#1{\@dblarg{\gmu@secx{#1}}} +\def\gmu@secx#1[#2]{% + \@ifnextchar[{\gmu@secxx{#1}{#2}}{\gmu@secxx{#1}{#2}[#2]}}% if + +\def\gmu@straightensec#1{% the parameter is for the command's name. + \gmu@ifundefined{#1}{}{% we don't change the ontological status of the + % command because someone may test it. + \n@melet{\gmu@secini#1}{#1}% + \@namedef{#1}{% + \gmu@ifstar{\def\gmu@secstar{*}\gmu@sec{#1}}{% + \def\gmu@secstar{}\gmu@sec{#1}}}}% +}% + +\let\do\gmu@straightensec +\do{part}\do{chapter}\do{section}\do{subsection}\do{subsubsection} +\@ifnotmw{}{\do{paragraph}}% this `straightening' of + +%%% (For my GNU Emacs:) +%%% Local Variables: +%%% mode: doctex +%%% coding: utf-8 +%%% End: +\endinput +%% +%% End of file `gmmw.sty'. -- cgit v1.2.3