github.com/krum110487/go-htaccess@v0.0.0-20240316004156-60641c8e7598/tests/data/apache_2_2_34/manual/style/latex/atbeginend.sty (about) 1 % atbeginend.sty 2 % 3 % Licensed to the Apache Software Foundation (ASF) under one or more 4 % contributor license agreements. See the NOTICE file distributed with 5 % this work for additional information regarding copyright ownership. 6 % The ASF licenses this file to You under the Apache License, Version 2.0 7 % (the "License"); you may not use this file except in compliance with 8 % the License. You may obtain a copy of the License at 9 % 10 % http://www.apache.org/licenses/LICENSE-2.0 11 % 12 % Unless required by applicable law or agreed to in writing, software 13 % distributed under the License is distributed on an "AS IS" BASIS, 14 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 % See the License for the specific language governing permissions and 16 % limitations under the License. 17 18 % defines 19 % \BeforeBegin{environment}{code-to-execute} 20 % \BeforeEnd {environment}{code-to-execute} 21 % \AfterBegin {environment}{code-to-execute} 22 % \AfterEnd {environment}{code-to-execute} 23 % 24 % Save \begin and \end to \BeginEnvironment and \EndEnvironment 25 \let\BeginEnvironment=\begin 26 \let\EndEnvironment=\end 27 28 \def\IfUnDef#1{\expandafter\ifx\csname#1\endcsname\relax} 29 30 % Null command needed to for \nothing{something}=.nothing. 31 \def\NullCom#1{} 32 33 \def\begin#1{% 34 % 35 % if defined \BeforeBeg for this environment, execute it 36 \IfUnDef{BeforeBeg#1}\else\csname BeforeBeg#1\endcsname\fi% 37 % 38 % 39 % 40 \IfUnDef{AfterBeg#1}% This is done to skip the command for environments 41 % which can take arguments, like multicols; YOU MUST NOT 42 % USE \AfterBegin{...}{...} for such environments! 43 \let\SaveBegEng=\BeginEnvironment% 44 \else% 45 % Start this environment 46 \BeginEnvironment{#1}% 47 % and execute code after \begin{environment} 48 \csname AfterBeg#1\endcsname% 49 % 50 \let\SaveBegEng=\NullCom% 51 \fi% 52 \SaveBegEng{#1}% 53 } 54 55 56 \def\end#1{% 57 % 58 % execute code before \end{environment} 59 \IfUnDef{BeforeEnd#1}\else\csname BeforeEnd#1\endcsname\fi% 60 % 61 % close this environment 62 \EndEnvironment{#1}% 63 % 64 % and execute code after \begin{environment} 65 \IfUnDef{AfterEnd#1}\else\csname AfterEnd#1\endcsname\fi% 66 } 67 68 69 %% Now, define commands 70 % \BeforeBegin{environment}{code-to-execute} 71 % \BeforeEnd {environment}{code-to-execute} 72 % \AfterBegin {environment}{code-to-execute} 73 % \AfterEnd {environment}{code-to-execute} 74 75 \def\BeforeBegin#1#2{\expandafter\gdef\csname BeforeBeg#1\endcsname 76 {#2}} 77 \def\BeforeEnd #1#2{\expandafter\gdef\csname BeforeEnd#1\endcsname 78 {#2}} 79 \def\AfterBegin #1#2{\expandafter\gdef\csname AfterBeg#1\endcsname {#2}} 80 \def\AfterEnd #1#2{\expandafter\gdef\csname AfterEnd#1\endcsname{#2}}