| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: protecteddef.dtx |
| 4 |
% Version: 2016/05/16 v1.1 |
| 5 |
% Info: Define protected commands |
| 6 |
% |
| 7 |
% Copyright (C) |
| 8 |
% 2011 Heiko Oberdiek |
| 9 |
% 2016-2019 Oberdiek Package Support Group |
| 10 |
% https://github.com/ho-tex/oberdiek/issues |
| 11 |
% |
| 12 |
% This work may be distributed and/or modified under the |
| 13 |
% conditions of the LaTeX Project Public License, either |
| 14 |
% version 1.3c of this license or (at your option) any later |
| 15 |
% version. This version of this license is in |
| 16 |
% https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 17 |
% and the latest version of this license is in |
| 18 |
% https://www.latex-project.org/lppl.txt |
| 19 |
% and version 1.3 or later is part of all distributions of |
| 20 |
% LaTeX version 2005/12/01 or later. |
| 21 |
% |
| 22 |
% This work has the LPPL maintenance status "maintained". |
| 23 |
% |
| 24 |
% The Current Maintainers of this work are |
| 25 |
% Heiko Oberdiek and the Oberdiek Package Support Group |
| 26 |
% https://github.com/ho-tex/oberdiek/issues |
| 27 |
% |
| 28 |
% The Base Interpreter refers to any `TeX-Format', |
| 29 |
% because some files are installed in TDS:tex/generic//. |
| 30 |
% |
| 31 |
% This work consists of the main source file protecteddef.dtx |
| 32 |
% and the derived files |
| 33 |
% protecteddef.sty, protecteddef.pdf, protecteddef.ins, protecteddef.drv, |
| 34 |
% protecteddef-test1.tex, protecteddef-test2.tex. |
| 35 |
% |
| 36 |
% Distribution: |
| 37 |
% CTAN:macros/latex/contrib/oberdiek/protecteddef.dtx |
| 38 |
% CTAN:macros/latex/contrib/oberdiek/protecteddef.pdf |
| 39 |
% |
| 40 |
% Unpacking: |
| 41 |
% (a) If protecteddef.ins is present: |
| 42 |
% tex protecteddef.ins |
| 43 |
% (b) Without protecteddef.ins: |
| 44 |
% tex protecteddef.dtx |
| 45 |
% (c) If you insist on using LaTeX |
| 46 |
% latex \let\install=y\input{protecteddef.dtx} |
| 47 |
% (quote the arguments according to the demands of your shell) |
| 48 |
% |
| 49 |
% Documentation: |
| 50 |
% (a) If protecteddef.drv is present: |
| 51 |
% latex protecteddef.drv |
| 52 |
% (b) Without protecteddef.drv: |
| 53 |
% latex protecteddef.dtx; ... |
| 54 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 55 |
% if available. Here you can specify further options, e.g. |
| 56 |
% use A4 as paper format: |
| 57 |
% \PassOptionsToClass{a4paper}{article} |
| 58 |
% |
| 59 |
% Program calls to get the documentation (example): |
| 60 |
% pdflatex protecteddef.dtx |
| 61 |
% makeindex -s gind.ist protecteddef.idx |
| 62 |
% pdflatex protecteddef.dtx |
| 63 |
% makeindex -s gind.ist protecteddef.idx |
| 64 |
% pdflatex protecteddef.dtx |
| 65 |
% |
| 66 |
% Installation: |
| 67 |
% TDS:tex/generic/oberdiek/protecteddef.sty |
| 68 |
% TDS:doc/latex/oberdiek/protecteddef.pdf |
| 69 |
% TDS:source/latex/oberdiek/protecteddef.dtx |
| 70 |
% |
| 71 |
%<*ignore> |
| 72 |
\begingroup |
| 73 |
\catcode123=1 % |
| 74 |
\catcode125=2 % |
| 75 |
\def\x{LaTeX2e}% |
| 76 |
\expandafter\endgroup |
| 77 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 78 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 79 |
\ifx\fmtname\x\else 1\fi\relax |
| 80 |
\else\csname fi\endcsname |
| 81 |
%</ignore> |
| 82 |
%<*install> |
| 83 |
\input docstrip.tex |
| 84 |
\Msg{************************************************************************} |
| 85 |
\Msg{* Installation} |
| 86 |
\Msg{* Package: protecteddef 2016/05/16 v1.1 Define protected commands (HO)} |
| 87 |
\Msg{************************************************************************} |
| 88 |
|
| 89 |
\keepsilent |
| 90 |
\askforoverwritefalse |
| 91 |
|
| 92 |
\let\MetaPrefix\relax |
| 93 |
\preamble |
| 94 |
|
| 95 |
This is a generated file. |
| 96 |
|
| 97 |
Project: protecteddef |
| 98 |
Version: 2016/05/16 v1.1 |
| 99 |
|
| 100 |
Copyright (C) |
| 101 |
2011 Heiko Oberdiek |
| 102 |
2016-2019 Oberdiek Package Support Group |
| 103 |
|
| 104 |
This work may be distributed and/or modified under the |
| 105 |
conditions of the LaTeX Project Public License, either |
| 106 |
version 1.3c of this license or (at your option) any later |
| 107 |
version. This version of this license is in |
| 108 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 109 |
and the latest version of this license is in |
| 110 |
https://www.latex-project.org/lppl.txt |
| 111 |
and version 1.3 or later is part of all distributions of |
| 112 |
LaTeX version 2005/12/01 or later. |
| 113 |
|
| 114 |
This work has the LPPL maintenance status "maintained". |
| 115 |
|
| 116 |
The Current Maintainers of this work are |
| 117 |
Heiko Oberdiek and the Oberdiek Package Support Group |
| 118 |
https://github.com/ho-tex/oberdiek/issues |
| 119 |
|
| 120 |
|
| 121 |
The Base Interpreter refers to any `TeX-Format', |
| 122 |
because some files are installed in TDS:tex/generic//. |
| 123 |
|
| 124 |
This work consists of the main source file protecteddef.dtx |
| 125 |
and the derived files |
| 126 |
protecteddef.sty, protecteddef.pdf, protecteddef.ins, protecteddef.drv, |
| 127 |
protecteddef-test1.tex, protecteddef-test2.tex. |
| 128 |
|
| 129 |
\endpreamble |
| 130 |
\let\MetaPrefix\DoubleperCent |
| 131 |
|
| 132 |
\generate{% |
| 133 |
\file{protecteddef.ins}{\from{protecteddef.dtx}{install}}% |
| 134 |
\file{protecteddef.drv}{\from{protecteddef.dtx}{driver}}% |
| 135 |
\usedir{tex/generic/oberdiek}% |
| 136 |
\file{protecteddef.sty}{\from{protecteddef.dtx}{package}}% |
| 137 |
% \usedir{doc/latex/oberdiek/test}% |
| 138 |
% \file{protecteddef-test1.tex}{\from{protecteddef.dtx}{test1}}% |
| 139 |
% \file{protecteddef-test2.tex}{\from{protecteddef.dtx}{test2}}% |
| 140 |
} |
| 141 |
|
| 142 |
\catcode32=13\relax% active space |
| 143 |
\let =\space% |
| 144 |
\Msg{************************************************************************} |
| 145 |
\Msg{*} |
| 146 |
\Msg{* To finish the installation you have to move the following} |
| 147 |
\Msg{* file into a directory searched by TeX:} |
| 148 |
\Msg{*} |
| 149 |
\Msg{* protecteddef.sty} |
| 150 |
\Msg{*} |
| 151 |
\Msg{* To produce the documentation run the file `protecteddef.drv'} |
| 152 |
\Msg{* through LaTeX.} |
| 153 |
\Msg{*} |
| 154 |
\Msg{* Happy TeXing!} |
| 155 |
\Msg{*} |
| 156 |
\Msg{************************************************************************} |
| 157 |
|
| 158 |
\endbatchfile |
| 159 |
%</install> |
| 160 |
%<*ignore> |
| 161 |
\fi |
| 162 |
%</ignore> |
| 163 |
%<*driver> |
| 164 |
\NeedsTeXFormat{LaTeX2e} |
| 165 |
\ProvidesFile{protecteddef.drv}% |
| 166 |
[2016/05/16 v1.1 Define protected commands (HO)]% |
| 167 |
\documentclass{ltxdoc} |
| 168 |
\usepackage{holtxdoc}[2011/11/22] |
| 169 |
\begin{document} |
| 170 |
\DocInput{protecteddef.dtx}% |
| 171 |
\end{document} |
| 172 |
%</driver> |
| 173 |
% \fi |
| 174 |
% |
| 175 |
% |
| 176 |
% |
| 177 |
% \GetFileInfo{protecteddef.drv} |
| 178 |
% |
| 179 |
% \title{The \xpackage{protecteddef} package} |
| 180 |
% \date{2016/05/16 v1.1} |
| 181 |
% \author{Heiko Oberdiek\thanks |
| 182 |
% {Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}} |
| 183 |
% |
| 184 |
% \maketitle |
| 185 |
% |
| 186 |
% \begin{abstract} |
| 187 |
% This packages provides \cs{ProtectedDef} for defining |
| 188 |
% robust macros for both \hologo{plainTeX} and \hologo{LaTeX}. |
| 189 |
% First \hologo{eTeX}'s \cs{protected} is tried, then |
| 190 |
% \hologo{LaTeX}'s \cs{DeclareRobustCommand} is used. |
| 191 |
% Otherwise the macro is not made robust. |
| 192 |
% \end{abstract} |
| 193 |
% |
| 194 |
% \tableofcontents |
| 195 |
% |
| 196 |
% \section{Documentation} |
| 197 |
% |
| 198 |
% Many of my packages work for both formats \hologo{plainTeX} |
| 199 |
% and \hologo{LaTeX}, even \hologo{iniTeX} is often supported. |
| 200 |
% It would be nice if fragile macros could be protected and |
| 201 |
% made robust. However the different format worlds offer different |
| 202 |
% solutions. |
| 203 |
% |
| 204 |
% \subsection{The \hologo{LaTeX}'s way} |
| 205 |
% |
| 206 |
% Usually \cs{newcommand} is used to define macros. It provides |
| 207 |
% a check if the command to be defined is already defined or |
| 208 |
% cannot be defined for other reasons. |
| 209 |
% |
| 210 |
% For making robust macros \hologo{LaTeX} provides \cs{DeclareRobustCommand}. |
| 211 |
% It shares the syntax with \cs{newcommand}. However it does not provide |
| 212 |
% latters check. Internally the check is available via \cs{@ifdefinable}. |
| 213 |
% |
| 214 |
% Internally the robust macro is using \cs{protect} with a nested |
| 215 |
% macro definition. The \cs{protect} infrastructure is a feature of |
| 216 |
% \cs{LaTeX} and usually not available in other formats. |
| 217 |
% |
| 218 |
% \subsection{The \hologo{eTeX}'s way} |
| 219 |
% |
| 220 |
% The need for robust macros is addressed in \cs{eTeX}. It provides |
| 221 |
% \cs{protected} that modifies the behaviour of \cs{def} in a similar |
| 222 |
% way as \cs{long}. A protected macro does not expand in |
| 223 |
% some expandable contexts like writing to a file or \cs{edef}. |
| 224 |
% |
| 225 |
% \subsection{The way of this package} |
| 226 |
% |
| 227 |
% The package tries to find the available protection mechanism. |
| 228 |
% First it looks for \cs{eTeX}'s \cs{protected}, then |
| 229 |
% it uses \hologo{LaTeX}'s \cs{DeclareRobustCommand}. |
| 230 |
% If both fails, then the macro remains unprotected. |
| 231 |
% |
| 232 |
% Additionally, \cs{LaTeX}'s check, if a macro is already defined |
| 233 |
% is added in all cases. First \hologo{LaTeX}'s \cs{@ifdefinable} |
| 234 |
% is tried to be compatible with \hologo{LaTeX}. |
| 235 |
% If \cs{@ifdefinable} is not available, then the test is implemented |
| 236 |
% by asserting that the macro is undefined or has the meaning of \cs{relax}. |
| 237 |
% If the test fails, then in all cases the macro is not defined |
| 238 |
% and an error is thrown. |
| 239 |
% |
| 240 |
% \subsection{Usage} |
| 241 |
% |
| 242 |
% \begin{declcs}{ProtectedDef} \* \M{cmd} [\meta{num}] \M{definition text} |
| 243 |
% \end{declcs} |
| 244 |
% Macro \cs{ProtectedDef} follows the syntax of \hologo{LaTeX}'s |
| 245 |
% \cs{newcommand} with the exception that an optional argument |
| 246 |
% is not supported. Macro \meta{cmd} is to be defined as |
| 247 |
% \cs{long} macro without star with \meta{num} arguments. |
| 248 |
% |
| 249 |
% The number of arguments \meta{num} must be given as explicit digit |
| 250 |
% |0| upto |9|. Otherwise the part between the argument \meta{cmd} and |
| 251 |
% the \meta{definition text} is taken as parameter text in the syntax |
| 252 |
% of vanilla \hologo{TeX}. Examples (with \cs{protected}): |
| 253 |
% \begin{quote} |
| 254 |
% \def\to{$\Rightarrow$ }% |
| 255 |
% |\ProtectedDef*{\foo}[1]{\message{#1}}|\\ |
| 256 |
% \to |\protected\def\foo#1{\message#1}}|\\[1ex] |
| 257 |
% |\ProtectedDef\foo{abc}|\\ |
| 258 |
% \to |\protected\def\foo{abc}|\\[1ex] |
| 259 |
% |\ProtectedDef*\foo(#1)<#2>{#1/#2}|\\ |
| 260 |
% \to |\protected\def\foo(#1)<#2>{#1/#2}| |
| 261 |
% \end{quote} |
| 262 |
% |
| 263 |
% \StopEventually{ |
| 264 |
% } |
| 265 |
% |
| 266 |
% \section{Implementation} |
| 267 |
% |
| 268 |
% \begin{macrocode} |
| 269 |
%<*package> |
| 270 |
% \end{macrocode} |
| 271 |
% |
| 272 |
% \subsection{Reload check and package identification} |
| 273 |
% Reload check, especially if the package is not used with \LaTeX. |
| 274 |
% \begin{macrocode} |
| 275 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 276 |
\catcode13=5 % ^^M |
| 277 |
\endlinechar=13 % |
| 278 |
\catcode35=6 % # |
| 279 |
\catcode39=12 % ' |
| 280 |
\catcode44=12 % , |
| 281 |
\catcode45=12 % - |
| 282 |
\catcode46=12 % . |
| 283 |
\catcode58=12 % : |
| 284 |
\catcode64=11 % @ |
| 285 |
\catcode123=1 % { |
| 286 |
\catcode125=2 % } |
| 287 |
\expandafter\let\expandafter\x\csname [email protected]\endcsname |
| 288 |
\ifx\x\relax % plain-TeX, first loading |
| 289 |
\else |
| 290 |
\def\empty{}% |
| 291 |
\ifx\x\empty % LaTeX, first loading, |
| 292 |
% variable is initialized, but \ProvidesPackage not yet seen |
| 293 |
\else |
| 294 |
\expandafter\ifx\csname PackageInfo\endcsname\relax |
| 295 |
\def\x#1#2{% |
| 296 |
\immediate\write-1{Package #1 Info: #2.}% |
| 297 |
}% |
| 298 |
\else |
| 299 |
\def\x#1#2{\PackageInfo{#1}{#2, stopped}}% |
| 300 |
\fi |
| 301 |
\x{protecteddef}{The package is already loaded}% |
| 302 |
\aftergroup\endinput |
| 303 |
\fi |
| 304 |
\fi |
| 305 |
\endgroup% |
| 306 |
% \end{macrocode} |
| 307 |
% Package identification: |
| 308 |
% \begin{macrocode} |
| 309 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 310 |
\catcode13=5 % ^^M |
| 311 |
\endlinechar=13 % |
| 312 |
\catcode35=6 % # |
| 313 |
\catcode39=12 % ' |
| 314 |
\catcode40=12 % ( |
| 315 |
\catcode41=12 % ) |
| 316 |
\catcode44=12 % , |
| 317 |
\catcode45=12 % - |
| 318 |
\catcode46=12 % . |
| 319 |
\catcode47=12 % / |
| 320 |
\catcode58=12 % : |
| 321 |
\catcode64=11 % @ |
| 322 |
\catcode91=12 % [ |
| 323 |
\catcode93=12 % ] |
| 324 |
\catcode123=1 % { |
| 325 |
\catcode125=2 % } |
| 326 |
\expandafter\ifx\csname ProvidesPackage\endcsname\relax |
| 327 |
\def\x#1#2#3[#4]{\endgroup |
| 328 |
\immediate\write-1{Package: #3 #4}% |
| 329 |
\xdef#1{#4}% |
| 330 |
}% |
| 331 |
\else |
| 332 |
\def\x#1#2[#3]{\endgroup |
| 333 |
#2[{#3}]% |
| 334 |
\ifx#1\@undefined |
| 335 |
\xdef#1{#3}% |
| 336 |
\fi |
| 337 |
\ifx#1\relax |
| 338 |
\xdef#1{#3}% |
| 339 |
\fi |
| 340 |
}% |
| 341 |
\fi |
| 342 |
\expandafter\x\csname [email protected]\endcsname |
| 343 |
\ProvidesPackage{protecteddef}% |
| 344 |
[2016/05/16 v1.1 Define protected commands (HO)]% |
| 345 |
% \end{macrocode} |
| 346 |
% |
| 347 |
% \subsection{Catcodes} |
| 348 |
% |
| 349 |
% \begin{macrocode} |
| 350 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 351 |
\catcode13=5 % ^^M |
| 352 |
\endlinechar=13 % |
| 353 |
\catcode123=1 % { |
| 354 |
\catcode125=2 % } |
| 355 |
\catcode64=11 % @ |
| 356 |
\def\x{\endgroup |
| 357 |
\expandafter\edef\csname ProDef@AtEnd\endcsname{% |
| 358 |
\endlinechar=\the\endlinechar\relax |
| 359 |
\catcode13=\the\catcode13\relax |
| 360 |
\catcode32=\the\catcode32\relax |
| 361 |
\catcode35=\the\catcode35\relax |
| 362 |
\catcode61=\the\catcode61\relax |
| 363 |
\catcode64=\the\catcode64\relax |
| 364 |
\catcode123=\the\catcode123\relax |
| 365 |
\catcode125=\the\catcode125\relax |
| 366 |
}% |
| 367 |
}% |
| 368 |
\x\catcode61\catcode48\catcode32=10\relax% |
| 369 |
\catcode13=5 % ^^M |
| 370 |
\endlinechar=13 % |
| 371 |
\catcode35=6 % # |
| 372 |
\catcode64=11 % @ |
| 373 |
\catcode123=1 % { |
| 374 |
\catcode125=2 % } |
| 375 |
\def\TMP@EnsureCode#1#2{% |
| 376 |
\edef\ProDef@AtEnd{% |
| 377 |
\ProDef@AtEnd |
| 378 |
\catcode#1=\the\catcode#1\relax |
| 379 |
}% |
| 380 |
\catcode#1=#2\relax |
| 381 |
} |
| 382 |
\TMP@EnsureCode{38}{4}% & |
| 383 |
\TMP@EnsureCode{40}{12}% ( |
| 384 |
\TMP@EnsureCode{41}{12}% ) |
| 385 |
\TMP@EnsureCode{42}{12}% * |
| 386 |
\TMP@EnsureCode{45}{12}% - |
| 387 |
\TMP@EnsureCode{46}{12}% . |
| 388 |
\TMP@EnsureCode{47}{12}% / |
| 389 |
\TMP@EnsureCode{91}{12}% [ |
| 390 |
\TMP@EnsureCode{93}{12}% ] |
| 391 |
\TMP@EnsureCode{96}{12}% ` |
| 392 |
\edef\ProDef@AtEnd{\ProDef@AtEnd\noexpand\endinput} |
| 393 |
% \end{macrocode} |
| 394 |
% |
| 395 |
% \subsection{Resources} |
| 396 |
% |
| 397 |
% \begin{macrocode} |
| 398 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 399 |
\expandafter\ifx\csname RequirePackage\endcsname\relax |
| 400 |
\def\TMP@RequirePackage#1[#2]{% |
| 401 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 402 |
\expandafter\ifx\csname ver@#1.sty\endcsname\relax |
| 403 |
\input #1.sty\relax |
| 404 |
\fi |
| 405 |
}% |
| 406 |
\else |
| 407 |
\let\TMP@RequirePackage\RequirePackage |
| 408 |
\fi |
| 409 |
\TMP@RequirePackage{ltxcmds}[2010/12/12]% |
| 410 |
\TMP@RequirePackage{infwarerr}[2010/04/08]% |
| 411 |
% \end{macrocode} |
| 412 |
% |
| 413 |
% \begin{macrocode} |
| 414 |
\def\ProDef@temp#1{% |
| 415 |
\expandafter\def\csname ProDef@param[#1]\endcsname % hash-ok |
| 416 |
} |
| 417 |
\expandafter\def\csname ProDef@param\endcsname{} |
| 418 |
\ProDef@temp0{} |
| 419 |
\ProDef@temp1{##1} |
| 420 |
\ProDef@temp2{##1##2} |
| 421 |
\ProDef@temp3{##1##2##3} |
| 422 |
\ProDef@temp4{##1##2##3##4} |
| 423 |
\ProDef@temp5{##1##2##3##4##5} |
| 424 |
\ProDef@temp6{##1##2##3##4##5##6} |
| 425 |
\ProDef@temp7{##1##2##3##4##5##7} |
| 426 |
\ProDef@temp8{##1##2##3##4##5##7##8} |
| 427 |
\ProDef@temp9{##1##2##3##4##5##7##8##9} |
| 428 |
% \end{macrocode} |
| 429 |
% |
| 430 |
% \begin{macro}{\ProDef@IfDefinable} |
| 431 |
% \begin{macrocode} |
| 432 |
\ltx@IfUndefined{@ifdefinable}{% |
| 433 |
\long\def\ProDef@IfDefinable#1{% |
| 434 |
\begingroup |
| 435 |
\escapechar=-1 % |
| 436 |
\ltx@ifundefined{\string#1}{% |
| 437 |
\endgroup |
| 438 |
\ltx@firstofone |
| 439 |
}{% |
| 440 |
\expandafter\endgroup |
| 441 |
\expandafter |
| 442 |
\edef\expandafter\ProDef@temp\expandafter{\string#1 }% |
| 443 |
\@PackageError{protecteddef}{% |
| 444 |
Command \ltx@backslashchar\ProDef@temp already defined% |
| 445 |
}\@ehc |
| 446 |
\ltx@gobbletwo |
| 447 |
}% |
| 448 |
}% |
| 449 |
}{% |
| 450 |
\long\def\ProDef@IfDefinable#1{% |
| 451 |
\let\ProDef@next\ltx@gobbletwo |
| 452 |
\@ifdefinable{#1}{% |
| 453 |
\let\ProDef@next\ltx@firstofone |
| 454 |
}% |
| 455 |
\ProDef@next |
| 456 |
}% |
| 457 |
} |
| 458 |
% \end{macrocode} |
| 459 |
% \end{macro} |
| 460 |
% |
| 461 |
% \begin{macrocode} |
| 462 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 463 |
\expandafter\ifx\csname protected\endcsname\relax |
| 464 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 465 |
\expandafter\ifx\csname DeclareRobustCommand\endcsname\relax |
| 466 |
\catcode`\&=14 % comment |
| 467 |
\else |
| 468 |
\newcommand*{\ProtectedDef}{% |
| 469 |
\ltx@ifnextchar*{% |
| 470 |
\ProDef@ProtectedDef |
| 471 |
}{% |
| 472 |
\ProDef@ProtectedDef{}% |
| 473 |
}% |
| 474 |
}% |
| 475 |
\long\def\ProDef@ProtectedDef#1#2#3#{% |
| 476 |
\ProDef@IfDefinable{#2}{% |
| 477 |
\ltx@IfUndefined{ProDef@param#3}{% |
| 478 |
\DeclareRobustCommand*{#2}{}% |
| 479 |
\begingroup |
| 480 |
\escapechar=-1 % |
| 481 |
\def\ProDef@temp{#1}% |
| 482 |
\edef\x{\endgroup |
| 483 |
\ifx\ProDef@temp\ltx@empty |
| 484 |
\noexpand\long |
| 485 |
\fi |
| 486 |
\noexpand\def |
| 487 |
\expandafter\noexpand\csname\string#2 \endcsname |
| 488 |
}% |
| 489 |
\x#3% |
| 490 |
}{% |
| 491 |
\DeclareRobustCommand#1{#2}#3% |
| 492 |
}% |
| 493 |
}% |
| 494 |
}% |
| 495 |
\expandafter\expandafter\expandafter\ProDef@AtEnd |
| 496 |
\fi |
| 497 |
\else |
| 498 |
\catcode`\&=9 % ignore |
| 499 |
\fi% |
| 500 |
\ProDef@IfDefinable\ProtectedDef{% |
| 501 |
& \protected |
| 502 |
\def\ProtectedDef% |
| 503 |
}{% |
| 504 |
\ltx@ifnextchar*{% |
| 505 |
\let\ProDef@long\ltx@empty |
| 506 |
\expandafter\ProDef@ProtectedDef\ltx@gobble |
| 507 |
}{% |
| 508 |
\let\ProDef@long\long |
| 509 |
\ProDef@ProtectedDef |
| 510 |
}% |
| 511 |
} |
| 512 |
\long\def\ProDef@ProtectedDef#1#2#{% |
| 513 |
\ProDef@IfDefinable{#1}{% |
| 514 |
\ltx@IfUndefined{ProDef@param#2}{% |
| 515 |
& \protected |
| 516 |
\ProDef@long |
| 517 |
\def#1#2% |
| 518 |
}{% |
| 519 |
& \protected |
| 520 |
\ProDef@long |
| 521 |
\expandafter\expandafter\expandafter\def |
| 522 |
\expandafter\expandafter\expandafter#1% |
| 523 |
\csname ProDef@param#2\endcsname |
| 524 |
}% |
| 525 |
}% |
| 526 |
} |
| 527 |
% \end{macrocode} |
| 528 |
% |
| 529 |
% \begin{macrocode} |
| 530 |
\ProDef@AtEnd% |
| 531 |
% \end{macrocode} |
| 532 |
% \begin{macrocode} |
| 533 |
%</package> |
| 534 |
% \end{macrocode} |
| 535 |
%% \section{Installation} |
| 536 |
% |
| 537 |
% \subsection{Download} |
| 538 |
% |
| 539 |
% \paragraph{Package.} This package is available on |
| 540 |
% CTAN\footnote{\CTANpkg{protecteddef}}: |
| 541 |
% \begin{description} |
| 542 |
% \item[\CTAN{macros/latex/contrib/oberdiek/protecteddef.dtx}] The source file. |
| 543 |
% \item[\CTAN{macros/latex/contrib/oberdiek/protecteddef.pdf}] Documentation. |
| 544 |
% \end{description} |
| 545 |
% |
| 546 |
% |
| 547 |
% \paragraph{Bundle.} All the packages of the bundle `oberdiek' |
| 548 |
% are also available in a TDS compliant ZIP archive. There |
| 549 |
% the packages are already unpacked and the documentation files |
| 550 |
% are generated. The files and directories obey the TDS standard. |
| 551 |
% \begin{description} |
| 552 |
% \item[\CTANinstall{install/macros/latex/contrib/oberdiek.tds.zip}] |
| 553 |
% \end{description} |
| 554 |
% \emph{TDS} refers to the standard ``A Directory Structure |
| 555 |
% for \TeX\ Files'' (\CTANpkg{tds}). Directories |
| 556 |
% with \xfile{texmf} in their name are usually organized this way. |
| 557 |
% |
| 558 |
% \subsection{Bundle installation} |
| 559 |
% |
| 560 |
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the |
| 561 |
% TDS tree (also known as \xfile{texmf} tree) of your choice. |
| 562 |
% Example (linux): |
| 563 |
% \begin{quote} |
| 564 |
% |unzip oberdiek.tds.zip -d ~/texmf| |
| 565 |
% \end{quote} |
| 566 |
% |
| 567 |
% \subsection{Package installation} |
| 568 |
% |
| 569 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 570 |
% \docstrip\ archive. The files are extracted by running the |
| 571 |
% \xfile{.dtx} through \plainTeX: |
| 572 |
% \begin{quote} |
| 573 |
% \verb|tex protecteddef.dtx| |
| 574 |
% \end{quote} |
| 575 |
% |
| 576 |
% \paragraph{TDS.} Now the different files must be moved into |
| 577 |
% the different directories in your installation TDS tree |
| 578 |
% (also known as \xfile{texmf} tree): |
| 579 |
% \begin{quote} |
| 580 |
% \def\t{^^A |
| 581 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 582 |
% protecteddef.sty & tex/generic/oberdiek/protecteddef.sty\\ |
| 583 |
% protecteddef.pdf & doc/latex/oberdiek/protecteddef.pdf\\ |
| 584 |
% protecteddef.dtx & source/latex/oberdiek/protecteddef.dtx\\ |
| 585 |
% \end{tabular}^^A |
| 586 |
% }^^A |
| 587 |
% \sbox0{\t}^^A |
| 588 |
% \ifdim\wd0>\linewidth |
| 589 |
% \begingroup |
| 590 |
% \advance\linewidth by\leftmargin |
| 591 |
% \advance\linewidth by\rightmargin |
| 592 |
% \edef\x{\endgroup |
| 593 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 594 |
% }\x |
| 595 |
% \def\lwbox{^^A |
| 596 |
% \leavevmode |
| 597 |
% \hbox to \linewidth{^^A |
| 598 |
% \kern-\leftmargin\relax |
| 599 |
% \hss |
| 600 |
% \usebox0 |
| 601 |
% \hss |
| 602 |
% \kern-\rightmargin\relax |
| 603 |
% }^^A |
| 604 |
% }^^A |
| 605 |
% \ifdim\wd0>\lw |
| 606 |
% \sbox0{\small\t}^^A |
| 607 |
% \ifdim\wd0>\linewidth |
| 608 |
% \ifdim\wd0>\lw |
| 609 |
% \sbox0{\footnotesize\t}^^A |
| 610 |
% \ifdim\wd0>\linewidth |
| 611 |
% \ifdim\wd0>\lw |
| 612 |
% \sbox0{\scriptsize\t}^^A |
| 613 |
% \ifdim\wd0>\linewidth |
| 614 |
% \ifdim\wd0>\lw |
| 615 |
% \sbox0{\tiny\t}^^A |
| 616 |
% \ifdim\wd0>\linewidth |
| 617 |
% \lwbox |
| 618 |
% \else |
| 619 |
% \usebox0 |
| 620 |
% \fi |
| 621 |
% \else |
| 622 |
% \lwbox |
| 623 |
% \fi |
| 624 |
% \else |
| 625 |
% \usebox0 |
| 626 |
% \fi |
| 627 |
% \else |
| 628 |
% \lwbox |
| 629 |
% \fi |
| 630 |
% \else |
| 631 |
% \usebox0 |
| 632 |
% \fi |
| 633 |
% \else |
| 634 |
% \lwbox |
| 635 |
% \fi |
| 636 |
% \else |
| 637 |
% \usebox0 |
| 638 |
% \fi |
| 639 |
% \else |
| 640 |
% \lwbox |
| 641 |
% \fi |
| 642 |
% \else |
| 643 |
% \usebox0 |
| 644 |
% \fi |
| 645 |
% \end{quote} |
| 646 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 647 |
% TDS installing feature, then some files can already be in the right |
| 648 |
% place, see the documentation of \docstrip. |
| 649 |
% |
| 650 |
% \subsection{Refresh file name databases} |
| 651 |
% |
| 652 |
% If your \TeX~distribution |
| 653 |
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh |
| 654 |
% these. For example, \TeX\,Live\ users run \verb|texhash| or |
| 655 |
% \verb|mktexlsr|. |
| 656 |
% |
| 657 |
% \subsection{Some details for the interested} |
| 658 |
% |
| 659 |
% \paragraph{Unpacking with \LaTeX.} |
| 660 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 661 |
% \begin{description} |
| 662 |
% \item[\plainTeX:] Run \docstrip\ and extract the files. |
| 663 |
% \item[\LaTeX:] Generate the documentation. |
| 664 |
% \end{description} |
| 665 |
% If you insist on using \LaTeX\ for \docstrip\ (really, |
| 666 |
% \docstrip\ does not need \LaTeX), then inform the autodetect routine |
| 667 |
% about your intention: |
| 668 |
% \begin{quote} |
| 669 |
% \verb|latex \let\install=y\input{protecteddef.dtx}| |
| 670 |
% \end{quote} |
| 671 |
% Do not forget to quote the argument according to the demands |
| 672 |
% of your shell. |
| 673 |
% |
| 674 |
% \paragraph{Generating the documentation.} |
| 675 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 676 |
% the documentation. The process can be configured by the |
| 677 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put this |
| 678 |
% line into this file, if you want to have A4 as paper format: |
| 679 |
% \begin{quote} |
| 680 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 681 |
% \end{quote} |
| 682 |
% An example follows how to generate the |
| 683 |
% documentation with pdf\LaTeX: |
| 684 |
% \begin{quote} |
| 685 |
%\begin{verbatim} |
| 686 |
%pdflatex protecteddef.dtx |
| 687 |
%makeindex -s gind.ist protecteddef.idx |
| 688 |
%pdflatex protecteddef.dtx |
| 689 |
%makeindex -s gind.ist protecteddef.idx |
| 690 |
%pdflatex protecteddef.dtx |
| 691 |
%\end{verbatim} |
| 692 |
% \end{quote} |
| 693 |
% |
| 694 |
% \begin{History} |
| 695 |
% \begin{Version}{2011/01/31 v1.0} |
| 696 |
% \item |
| 697 |
% First public version. |
| 698 |
% \end{Version} |
| 699 |
% \begin{Version}{2016/05/16 v1.1} |
| 700 |
% \item |
| 701 |
% Documentation updates. |
| 702 |
% \end{Version} |
| 703 |
% \end{History} |
| 704 |
% |
| 705 |
% \PrintIndex |
| 706 |
% |
| 707 |
% \Finale |
| 708 |
\endinput |