% \iffalse %% File: everysel.dtx Copyright (C) 1996 Martin Schr\"oder % %\NeedsTeXFormat{LaTeX2e}[1995/12/01] %\ProvidesPackage{everysel} % [1996/05/30 v1.00 EverySelectfont Package (MS)] % %<*driver> \NeedsTeXFormat{LaTeX2e}[1995/12/01] \documentclass{ltxdoc} \usepackage{everysel} \GetFileInfo{everysel.sty} \RecordChanges % Gather update information \EnableCrossrefs %%\DisableCrossrefs% Say \DisableCrossrefs if index is ready \CodelineIndex % Index code by line number \OnlyDescription % comment out for implementation details %%\OldMakeIndex % use if your MakeIndex is pre-v2.9 \setcounter{IndexColumns}{2} \setlength{\IndexMin}{40ex} \setlength{\columnseprule}{.4pt} \addtolength{\oddsidemargin}{1cm} \addtolength{\textwidth}{-1cm} \begin{document} \DocInput{everysel.dtx} \PrintIndex\PrintChanges % Make sure that the index is not printed twice % (ltxdoc.cfg might have a second \PrintIndex command) \let\PrintChanges\relax \let\PrintIndex\relax \end{document} % % % Copyright (C) 1996 by Martin Schr\"oder. All rights reserved. % % IMPORTANT NOTICE: % % You are not allowed to change this file. You may however copy % this file to a file with a different name and then change the % copy if you obey the restrictions on file changes described in % everysel.ins. % % You are NOT ALLOWED to distribute this file alone. You are NOT % ALLOWED to take money for the distribution or use of this file % (or a changed version) except for a nominal charge for copying % etc. % % You are allowed to distribute this file under the condition that % it is distributed together with all files mentioned in % everysel.ins. % % If you receive only some of these files from someone, complain! % % However, if these files are distributed by established suppliers % as part of a complete TeX distribution, and the structure of the % distribution would make it difficult to distribute the whole set % of files, *those parties* are allowed to distribute only some of % the files provided that it is made clear that the user will get % a complete distribution-set upon request to that supplier (not % me). Notice that this permission is not granted to the end % user. % % % For error reports in case of UNCHANGED versions see everysel.ins % % \fi % % \CheckSum{105} % %% \CharacterTable %% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z %% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z %% Digits \0\1\2\3\4\5\6\7\8\9 %% Exclamation \! Double quote \" Hash (number) \# %% Dollar \$ Percent \% Ampersand \& %% Acute accent \' Left paren \( Right paren \) %% Asterisk \* Plus \+ Comma \, %% Minus \- Point \. Solidus \/ %% Colon \: Semicolon \; Less than \< %% Equals \= Greater than \> Question mark \? %% Commercial at \@ Left bracket \[ Backslash \\ %% Right bracket \] Circumflex \^ Underscore \_ %% Grave accent \` Left brace \{ Vertical bar \| %% Right brace \} Tilde \~} %% % \iffalse meta-comment % ==================================================================== % @LaTeX-style-file{ % author = {Martin Schr\"oder}, % version = "1.00", % date = "30 May 1996", % filename = "everysel.sty", % address = {Martin Schr\"oder % Friedrich-Humbert-Stra\ss{}e 124 % D-28759 Bremen}, % telephone = "+49-421-628813", % email = "MS@Dream.HB.North.DE (INTERNET)", % codetable = "ISO/ASCII", % keywords = "LaTeX, NFSS", % supported = "yes", % docstring = "LaTeX package which provides hooks into % \cs{selectfont})." % } % ==================================================================== %\fi % % \changes{v1.00}{1996-05-24}{New} % % % ^^A ----------------------------- % % \IndexPrologue{^^A % \section*{\indexname}^^A % \markboth{\indexname}{\indexname}^^A % Numbers written in \emph{italic} refer to the page where the % corresponding entry is described, the ones % \underline{underlined} to the definition, the rest to the places % where the entry is used.} % % \pagestyle{headings} % % \newcommand*{\file}[1]{\texttt{#1}} % \newcommand*{\package}[1]{\textsf{#1}} % \hyphenation{every-select-font} % % % ^^A ----------------------------- % % \title{\unskip % The \textsf{EverySel} package^^A % \thanks{^^A % The version number of this file is \fileversion, % last revised \filedate.\newline % The name \textsf{EverySel} is a tribute to the $8+3$ % file-naming convention of certain ``operating % systems'' and their ``file systems''; strictly % speaking it should be \textsf{EverySelectfont}.}^^A % } % \author{Martin Schr\"oder\\[0.5ex] % \normalsize Friedrich-Humbert-Stra\ss{}e 124\\ % \normalsize D-28759 Bremen\\ % \normalsize MS@Dream.HB.North.DE (Internet)} % \date{\filedate, \LaTeX{}ed \today} % \maketitle % % % ^^A ----------------------------- % % % \begin{abstract} % This packages provides hooks into the NFSS-command % \cs{selectfont} called \cs{EverySelectfont} and % \cs{AtNextSelectfont} analogous to \cs{AtBeginDocument}. % \end{abstract} % % \pagestyle{headings} % % % ^^A ----------------------------- % % \tableofcontents % % % ^^A ----------------------------- % % \section{Introduction} % ^^A % This package provides the hooks \cs{EverySelectfont} and % \cs{AtNextSelectfont} whose arguments are executed just after % \LaTeX{} has loaded a new font using \cs{selectfont} (which means % that it will be executed after \emph{every} font loaded via NFSS). % % An example application would be a package for setting ragged text % which needs to distiguinsh between monospaced and proportional % fonts. % Such a package exists: \package{ragged2e}. % % % ^^A ----------------------------- % % \section{Usage} % ^^A % \DescribeMacro{\EverySelectfont} % \cs{EverySelectfont}\marg{code} declares % \mbox{$\langle$\emph{code}$\rangle$} that is saved internally % and executed just after \emph{each} \cs{selectfont}. % % \emph{Warning:} The \mbox{$\langle$\emph{code}$\rangle$} is saved % globally; there is currently no way to remove it. % % \DescribeMacro{\AtNextSelectfont} % \cs{AtNextSelectfont}\marg{code} declares % \mbox{$\langle$\emph{code}$\rangle$} that is saved internally % and executed just after \emph{and only the next} \cs{selectfont}. % % Repeated use of the commands is permitted: the code in their % argument is stored (and executed) in the order of their % declarations. % % The argument of \cs{AtNextSelectfont} is executed \emph{after} % the argument of \cs{EverySelectfont}. % % % ^^A ----------------------------- % % \section{Options} % ^^A % The package has no options. % % % ^^A ----------------------------- % % \section{Required packages} % ^^A % The package requires no further packages. % % % ^^A ----------------------------- % % \StopEventually{^^A % % % ^^A ----------------------------- % % \section{Acknowledgements} % ^^A % David Carlisle provided the solution for my problems with \cs{CheckCommand}. % } % % % ^^A ----------------------------- % % \section{The implementation} % ^^A % \begin{macrocode} %<*package> % \end{macrocode} % % % ^^A ----------------------------- % % \subsection{Allocations} % ^^A % First we allocate the hooks % \begin{macro}{\@EverySelectfont@EveryHook} % The code to be executed just after the normal \cs{selectfont}. % \begin{macrocode} \newcommand*{\@EverySelectfont@EveryHook}{} % \end{macrocode} % \end{macro} % % \begin{macro}{\@EverySelectfont@AtNextHook} % The code to be executed just after the normal \cs{selectfont} % and \cs{@EverySelectfont@EveryHook}. % \begin{macrocode} \newcommand*{\@EverySelectfont@AtNextHook}{} % \end{macrocode} % \end{macro} % % % ^^A ----------------------------- % % \subsection{The user-visible commands} % ^^A % \begin{macro}{\EverySelectfont} % \begin{macro}{\AtNextSelectfont} % These commands are modeled after \cs{AtBeginDocument}. % \begin{macrocode} \newcommand*{\EverySelectfont}[1] {\g@addto@macro\@EverySelectfont@EveryHook{#1}} \newcommand*{\AtNextSelectfont}[1] {\g@addto@macro\@EverySelectfont@AtNextHook{#1}} % \end{macrocode} % \end{macro} % \end{macro} % % % ^^A ----------------------------- % % \subsection{Inserting the hooks} % ^^A % The hooks are placed \emph{inside} \cs{selectfont}. % Unfortunately for us there are \emph{two} versions of % \cs{selectfont} in normal \LaTeX: One is defined in the kernel and % the other by the package \package{tracefnt}. % So we have to check for two versions. % \begin{macro}{\@EverySelectfont@Init} % We do this in the macro \cs{@EverySelectfont@Init}, which is % executed just after \cs{begin\{document\}} (with the aid of % \cs{AtBeginDocument}), when we know for sure which version of % \cs{selectfont} we have to overload. % \begin{macrocode} \newcommand*{\@EverySelectfont@Init}{% % \end{macrocode} % We have to distinguish two cases: \package{tracefnt} and % no \package{tracefnt}. % \begin{macrocode} \@ifpackageloaded{tracefnt}{% % \end{macrocode} % And we have a problem: \cs{selectfont} is defined using % \cs{DeclareRobustCommand}, which really defines % \cs{selectfont\textvisiblespace}. % So instead of simply using \cs{CheckCommand} we also have to use % \cs{expandafter} and \cs{csname}\ldots\cs{endcsname}. % \begin{macrocode} \expandafter\CheckCommand\csname selectfont \endcsname{% \ifx\f@linespread\baselinestretch \else \set@fontsize\baselinestretch\f@size\f@baselineskip \fi \xdef\font@name{% \csname\curr@fontshape/\f@size\endcsname}% \pickup@font \font@name \ifnum \tracingfonts>\tw@ \@font@info{Switching to \font@name}\fi \size@update \enc@update }% }{% % \end{macrocode} % Now the case without \package{tracefnt}. % \begin{macrocode} \expandafter\CheckCommand\csname selectfont \endcsname{% \ifx\f@linespread\baselinestretch \else \set@fontsize\baselinestretch\f@size\f@baselineskip \fi \xdef\font@name{% \csname\curr@fontshape/\f@size\endcsname}% \pickup@font \font@name \size@update \enc@update }% }% % \end{macrocode} % After the checks we can be sure we have the correct version of % \cs{selectfont}, so we redefine it with our hooks. % \begin{macrocode} \DeclareRobustCommand{\selectfont}% {% \ifx\f@linespread\baselinestretch \else \set@fontsize\baselinestretch\f@size\f@baselineskip \fi \xdef\font@name{% \csname\curr@fontshape/\f@size\endcsname}% \pickup@font \font@name \@EverySelectfont@EveryHook \@EverySelectfont@AtNextHook % \end{macrocode} % We have to reset \cs{@EverySelectfont@AtNextHook} after each use. % \begin{macrocode} \gdef\@EverySelectfont@AtNextHook{}% \size@update \enc@update }% % \end{macrocode} % The additions of \package{tracefnt} to \cs{selectfont} can be % implemented using \cs{EverySelectfont}. % \begin{macrocode} \@ifpackageloaded{tracefnt}{% \EverySelectfont{% \ifnum \tracingfonts>\tw@ \@font@info{Switching to \font@name}\fi}% }{}% % \end{macrocode} % Since \cs{@EverySelectfont@Init} should only be used once it is % self-destructing. % \begin{macrocode} \let\@EverySelectfont@Init\undefined } % \end{macrocode} % Finally we insert \cs{EverySelectfont@Init} into \cs{begin\{document\}}. % \begin{macrocode} \AtBeginDocument{\@EverySelectfont@Init} % \end{macrocode} % \end{macro} % % % ^^A ----------------------------- % % \begin{macrocode} % % \end{macrocode} % % % ^^A ----------------------------- % % \Finale