| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: eolgrab.dtx |
| 4 |
% Version: 2016/05/16 v1.1 |
| 5 |
% Info: Catch arguments delimited by end of line |
| 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 eolgrab.dtx |
| 32 |
% and the derived files |
| 33 |
% eolgrab.sty, eolgrab.pdf, eolgrab.ins, eolgrab.drv, |
| 34 |
% eolgrab-example-ltx.tex, eolgrab-example-env.tex, |
| 35 |
% eolgrab-example-sec.tex, eolgrab-test1.tex, |
| 36 |
% eolgrab-test2.tex. |
| 37 |
% |
| 38 |
% Distribution: |
| 39 |
% CTAN:macros/latex/contrib/oberdiek/eolgrab.dtx |
| 40 |
% CTAN:macros/latex/contrib/oberdiek/eolgrab.pdf |
| 41 |
% |
| 42 |
% Unpacking: |
| 43 |
% (a) If eolgrab.ins is present: |
| 44 |
% tex eolgrab.ins |
| 45 |
% (b) Without eolgrab.ins: |
| 46 |
% tex eolgrab.dtx |
| 47 |
% (c) If you insist on using LaTeX |
| 48 |
% latex \let\install=y\input{eolgrab.dtx} |
| 49 |
% (quote the arguments according to the demands of your shell) |
| 50 |
% |
| 51 |
% Documentation: |
| 52 |
% (a) If eolgrab.drv is present: |
| 53 |
% latex eolgrab.drv |
| 54 |
% (b) Without eolgrab.drv: |
| 55 |
% latex eolgrab.dtx; ... |
| 56 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 57 |
% if available. Here you can specify further options, e.g. |
| 58 |
% use A4 as paper format: |
| 59 |
% \PassOptionsToClass{a4paper}{article} |
| 60 |
% |
| 61 |
% Program calls to get the documentation (example): |
| 62 |
% pdflatex eolgrab.dtx |
| 63 |
% makeindex -s gind.ist eolgrab.idx |
| 64 |
% pdflatex eolgrab.dtx |
| 65 |
% makeindex -s gind.ist eolgrab.idx |
| 66 |
% pdflatex eolgrab.dtx |
| 67 |
% |
| 68 |
% Installation: |
| 69 |
% TDS:tex/generic/oberdiek/eolgrab.sty |
| 70 |
% TDS:doc/latex/oberdiek/eolgrab.pdf |
| 71 |
% TDS:doc/latex/oberdiek/example/eolgrab-example-ltx.tex |
| 72 |
% TDS:doc/latex/oberdiek/example/eolgrab-example-env.tex |
| 73 |
% TDS:doc/latex/oberdiek/example/eolgrab-example-sec.tex |
| 74 |
% TDS:source/latex/oberdiek/eolgrab.dtx |
| 75 |
% |
| 76 |
%<*ignore> |
| 77 |
\begingroup |
| 78 |
\catcode123=1 % |
| 79 |
\catcode125=2 % |
| 80 |
\def\x{LaTeX2e}% |
| 81 |
\expandafter\endgroup |
| 82 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 83 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 84 |
\ifx\fmtname\x\else 1\fi\relax |
| 85 |
\else\csname fi\endcsname |
| 86 |
%</ignore> |
| 87 |
%<*install> |
| 88 |
\input docstrip.tex |
| 89 |
\Msg{************************************************************************} |
| 90 |
\Msg{* Installation} |
| 91 |
\Msg{* Package: eolgrab 2016/05/16 v1.1 Catch arguments delimited by end of line (HO)} |
| 92 |
\Msg{************************************************************************} |
| 93 |
|
| 94 |
\keepsilent |
| 95 |
\askforoverwritefalse |
| 96 |
|
| 97 |
\let\MetaPrefix\relax |
| 98 |
\preamble |
| 99 |
|
| 100 |
This is a generated file. |
| 101 |
|
| 102 |
Project: eolgrab |
| 103 |
Version: 2016/05/16 v1.1 |
| 104 |
|
| 105 |
Copyright (C) |
| 106 |
2011 Heiko Oberdiek |
| 107 |
2016-2019 Oberdiek Package Support Group |
| 108 |
|
| 109 |
This work may be distributed and/or modified under the |
| 110 |
conditions of the LaTeX Project Public License, either |
| 111 |
version 1.3c of this license or (at your option) any later |
| 112 |
version. This version of this license is in |
| 113 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 114 |
and the latest version of this license is in |
| 115 |
https://www.latex-project.org/lppl.txt |
| 116 |
and version 1.3 or later is part of all distributions of |
| 117 |
LaTeX version 2005/12/01 or later. |
| 118 |
|
| 119 |
This work has the LPPL maintenance status "maintained". |
| 120 |
|
| 121 |
The Current Maintainers of this work are |
| 122 |
Heiko Oberdiek and the Oberdiek Package Support Group |
| 123 |
https://github.com/ho-tex/oberdiek/issues |
| 124 |
|
| 125 |
|
| 126 |
The Base Interpreter refers to any `TeX-Format', |
| 127 |
because some files are installed in TDS:tex/generic//. |
| 128 |
|
| 129 |
This work consists of the main source file eolgrab.dtx |
| 130 |
and the derived files |
| 131 |
eolgrab.sty, eolgrab.pdf, eolgrab.ins, eolgrab.drv, |
| 132 |
eolgrab-example-ltx.tex, eolgrab-example-env.tex, |
| 133 |
eolgrab-example-sec.tex, eolgrab-test1.tex, |
| 134 |
eolgrab-test2.tex. |
| 135 |
|
| 136 |
\endpreamble |
| 137 |
\let\MetaPrefix\DoubleperCent |
| 138 |
|
| 139 |
\generate{% |
| 140 |
\file{eolgrab.ins}{\from{eolgrab.dtx}{install}}% |
| 141 |
\file{eolgrab.drv}{\from{eolgrab.dtx}{driver}}% |
| 142 |
\usedir{tex/generic/oberdiek}% |
| 143 |
\file{eolgrab.sty}{\from{eolgrab.dtx}{package}}% |
| 144 |
\usedir{doc/latex/oberdiek/example}% |
| 145 |
\file{eolgrab-example-ltx.tex}{\from{eolgrab.dtx}{example-ltx}}% |
| 146 |
\file{eolgrab-example-env.tex}{\from{eolgrab.dtx}{example-env}}% |
| 147 |
\file{eolgrab-example-sec.tex}{\from{eolgrab.dtx}{example-sec}}% |
| 148 |
% \usedir{doc/latex/oberdiek/test}% |
| 149 |
% \file{eolgrab-test1.tex}{\from{eolgrab.dtx}{test1}}% |
| 150 |
% \file{eolgrab-test2.tex}{\from{eolgrab.dtx}{test2}}% |
| 151 |
} |
| 152 |
|
| 153 |
\catcode32=13\relax% active space |
| 154 |
\let =\space% |
| 155 |
\Msg{************************************************************************} |
| 156 |
\Msg{*} |
| 157 |
\Msg{* To finish the installation you have to move the following} |
| 158 |
\Msg{* file into a directory searched by TeX:} |
| 159 |
\Msg{*} |
| 160 |
\Msg{* eolgrab.sty} |
| 161 |
\Msg{*} |
| 162 |
\Msg{* To produce the documentation run the file `eolgrab.drv'} |
| 163 |
\Msg{* through LaTeX.} |
| 164 |
\Msg{*} |
| 165 |
\Msg{* Happy TeXing!} |
| 166 |
\Msg{*} |
| 167 |
\Msg{************************************************************************} |
| 168 |
|
| 169 |
\endbatchfile |
| 170 |
%</install> |
| 171 |
%<*ignore> |
| 172 |
\fi |
| 173 |
%</ignore> |
| 174 |
%<*driver> |
| 175 |
\NeedsTeXFormat{LaTeX2e} |
| 176 |
\ProvidesFile{eolgrab.drv}% |
| 177 |
[2016/05/16 v1.1 Catch arguments delimited by end of line (HO)]% |
| 178 |
\documentclass{ltxdoc} |
| 179 |
\usepackage{holtxdoc}[2011/11/22] |
| 180 |
\begin{document} |
| 181 |
\DocInput{eolgrab.dtx}% |
| 182 |
\end{document} |
| 183 |
%</driver> |
| 184 |
% \fi |
| 185 |
% |
| 186 |
% |
| 187 |
% |
| 188 |
% \GetFileInfo{eolgrab.drv} |
| 189 |
% |
| 190 |
% \title{The \xpackage{eolgrab} package} |
| 191 |
% \date{2016/05/16 v1.1} |
| 192 |
% \author{Heiko Oberdiek\thanks |
| 193 |
% {Please report any issues at \url{https://github.com/ho-tex/oberdiek/issues}}} |
| 194 |
% |
| 195 |
% \maketitle |
| 196 |
% |
| 197 |
% \begin{abstract} |
| 198 |
% This package implements a generic argument grabber |
| 199 |
% to catch an argument that is delimited by the line end. |
| 200 |
% \end{abstract} |
| 201 |
% |
| 202 |
% \tableofcontents |
| 203 |
% |
| 204 |
% \urldef\urltexhax\url{https://tug.org/mailman/listinfo/texhax} |
| 205 |
% \def\eol/{^^A |
| 206 |
% \meta{\texttt{EOL}}^^A |
| 207 |
% } |
| 208 |
% |
| 209 |
% \section{Documentation} |
| 210 |
% |
| 211 |
% The starting point for this package was a feature |
| 212 |
% request of Arno Trautmann in the mailing list |
| 213 |
% \texttt{texhax}\footnote{Info page for mailing list |
| 214 |
% \texttt{texhax}: \urltexhax} \cite{trautmann-request}. |
| 215 |
% A macro \cs{eolsection} should behave like \cs{section}, |
| 216 |
% but the argument should be delimited by the line end |
| 217 |
% instead of given in curly braces: |
| 218 |
% \begin{quote} |
| 219 |
% |\eolsection My Title| |
| 220 |
% \end{quote} |
| 221 |
% Phil Taylor answered this with an implementation for \cs{eolsection}. |
| 222 |
% Because this feature could be useful for other macros as well, |
| 223 |
% I answered with an implementation of \cs{eolgrab} as general solution |
| 224 |
% \cite{oberdiek-eolgrab}. |
| 225 |
% |
| 226 |
% Both formats \hologo{plainTeX} and \hologo{LaTeX} are supported |
| 227 |
% by the package, see the example for \cs{eolsection} below. |
| 228 |
% |
| 229 |
% \begin{declcs}{eolgrab} \M{code} \meta{argument} \eol/ |
| 230 |
% \end{declcs} |
| 231 |
% Macro \cs{eolgrab} takes two arguments. The first argument |
| 232 |
% is \meta{code}, a classical undelimited \hologo{TeX} macro argument. |
| 233 |
% The second argument is delimited by the line end \eol/. |
| 234 |
% The macro calls \meta{code} with \meta{argument} as argument |
| 235 |
% in curly braces. Because the catcode of the line end is changed, |
| 236 |
% \cs{eolgrab} will not work in the argument of other macros. |
| 237 |
% Macro \cs{eolgrab} is made robust if either \hologo{eTeX}'s |
| 238 |
% \cs{protected} or \hologo{LaTeX}'s \cs{DeclareRobustCommand} |
| 239 |
% is available. |
| 240 |
% |
| 241 |
% \begin{declcs}{eolgrabopt} \M{code} \meta{argument} \eol/ |
| 242 |
% \end{declcs} |
| 243 |
% Macro \cs{eolgrabopt} passes \meta{argument} as optional |
| 244 |
% argument to \meta{code} if \meta{argument} is not empty. |
| 245 |
% \begin{quote} |
| 246 |
% |\eolgrabopt\item foo| |
| 247 |
% \end{quote} |
| 248 |
% becomes to |
| 249 |
% \begin{quote} |
| 250 |
% |\item[{foo}]| |
| 251 |
% \end{quote} |
| 252 |
% The curly argument braces are added to support square brackets |
| 253 |
% inside \meta{argument}. |
| 254 |
% If the \meta{argument} is empty: |
| 255 |
% \begin{quote} |
| 256 |
% |\eolgrabopt\item| |
| 257 |
% \end{quote} |
| 258 |
% then |
| 259 |
% \begin{quote} |
| 260 |
% |\item| |
| 261 |
% \end{quote} |
| 262 |
% is called without optional argument. |
| 263 |
% |
| 264 |
% \subsection{Examples} |
| 265 |
% |
| 266 |
% \begin{itemize} |
| 267 |
% \item |
| 268 |
% The line |
| 269 |
% \begin{quote} |
| 270 |
% |\eolgrab\section My Title| |
| 271 |
% \end{quote} |
| 272 |
% is equivalent to |
| 273 |
% \begin{quote} |
| 274 |
% |\section{My Title}| |
| 275 |
% \end{quote} |
| 276 |
% \item |
| 277 |
% The next example uses the star form of \cs{section}. Then the |
| 278 |
% command to be called consists of two tokens. Therefore the |
| 279 |
% first argument of \cs{eolgrab} needs curly braces: |
| 280 |
% \begin{quote} |
| 281 |
% |\eolgrab{\section*}My Title| |
| 282 |
% \end{quote} |
| 283 |
% becomes |
| 284 |
% \begin{quote} |
| 285 |
% |\section*{My Title}| |
| 286 |
% \end{quote} |
| 287 |
% \item |
| 288 |
% Now \hologo{LaTeX}'s \cs{PackageError} is used. This macro |
| 289 |
% has three arguments, the package or class name, the message |
| 290 |
% text and the help text. A standard help text of \hologo{LaTeX} |
| 291 |
% is used as given in macro \cs{@ehc}. The second argument, |
| 292 |
% the message text is used as argument, delimited by line end: |
| 293 |
% \begin{quote} |
| 294 |
% |\eolgrab{\PackageError{foobar}}%|\\ |
| 295 |
% |Some error message text\MessageBreak%|\\ |
| 296 |
% |with several lines|\\ |
| 297 |
% |\@ehc| |
| 298 |
% \end{quote} |
| 299 |
% In the first two lines of the example, the line end is suppressed |
| 300 |
% by the comment character (percent), thus the argument is delimited |
| 301 |
% by the line end of the third line. The result is: |
| 302 |
% \begin{quote} |
| 303 |
% |\PackageError{foobar}{Some error message text\MessageBreak|\\ |
| 304 |
% |with several lines}\@ehc| |
| 305 |
% \end{quote} |
| 306 |
% \item |
| 307 |
% The original request for macro \cs{eolsection}, see above, |
| 308 |
% can be implemented easily with the help of \cs{eolgrab}. |
| 309 |
% Example for \hologo{LaTeX}: |
| 310 |
% \begin{quote} |
| 311 |
% |\usepackage{eolgrab}|\\ |
| 312 |
% |\newcommand*{\eolsection}{\eolgrab\section}| |
| 313 |
% \end{quote} |
| 314 |
% Example for \hologo{plainTeX}: |
| 315 |
% \begin{quote} |
| 316 |
% |\input eolgrab.sty\relax|\\ |
| 317 |
% |\def\eolsection{\eolgrab\section}| |
| 318 |
% \end{quote} |
| 319 |
% And a sophisticated variant for \hologo{LaTeX} that also supports |
| 320 |
% the star syntax and the optional argument: |
| 321 |
% \begin{macrocode} |
| 322 |
%<*example-sec> |
| 323 |
\documentclass{article} |
| 324 |
\usepackage{eolgrab} |
| 325 |
\makeatletter |
| 326 |
\newcommand*{\eolsection}{% |
| 327 |
\@ifstar{% |
| 328 |
\eolgrab{\section*}% |
| 329 |
}{% |
| 330 |
\@ifnextchar[{% |
| 331 |
\eoloptsection |
| 332 |
}{% |
| 333 |
\eolgrab\section |
| 334 |
}% |
| 335 |
}% |
| 336 |
} |
| 337 |
\newcommand*{\eoloptsection}[1][]{% |
| 338 |
\eolgrab{\section[{#1}]}% |
| 339 |
} |
| 340 |
\makeatother |
| 341 |
\begin{document} |
| 342 |
\tableofcontents |
| 343 |
\eolsection Section without star and optional argument |
| 344 |
\eolsection*Section with star |
| 345 |
\eolsection[Short section title]Long section title |
| 346 |
\end{document} |
| 347 |
%</example-sec> |
| 348 |
% \end{macrocode} |
| 349 |
% \end{itemize} |
| 350 |
% |
| 351 |
% \subsubsection{Small \hologo{LaTeX} document as example} |
| 352 |
% |
| 353 |
% \begin{macrocode} |
| 354 |
%<*example-ltx> |
| 355 |
\RequirePackage{eolgrab} |
| 356 |
\eolgrab\documentclass article |
| 357 |
\eolgrab\begin document |
| 358 |
\eolgrab\section Hello World |
| 359 |
\eolgrab\emph Some text |
| 360 |
\eolgrab\end document |
| 361 |
%</example-ltx> |
| 362 |
% \end{macrocode} |
| 363 |
% |
| 364 |
% \subsubsection{\hologo{LaTeX} document with environments} |
| 365 |
% |
| 366 |
% \begin{macrocode} |
| 367 |
%<*example-env> |
| 368 |
\documentclass{article} |
| 369 |
\usepackage{eolgrab} |
| 370 |
\newcommand*{\Begin}{\eolgrab \begin} |
| 371 |
\newcommand*{\End }{\eolgrab \end } |
| 372 |
\newcommand*{\Item }{\eolgrabopt\item } |
| 373 |
\Begin document |
| 374 |
\Begin itemize |
| 375 |
\Item |
| 376 |
first item |
| 377 |
\Item |
| 378 |
second item |
| 379 |
\End itemize |
| 380 |
\Begin description |
| 381 |
\Item foo |
| 382 |
is the first syllable of foobar. |
| 383 |
\Item bar |
| 384 |
is the second syllable of foobar. |
| 385 |
\End description |
| 386 |
\End document |
| 387 |
%</example-env> |
| 388 |
% \end{macrocode} |
| 389 |
% |
| 390 |
% \subsection{Limitations} |
| 391 |
% |
| 392 |
% Macro \cs{eolgrab} needs to catch the line end. |
| 393 |
% If \hologo{TeX} reads a line, then it throws away the line end |
| 394 |
% characters (carriage return, line feed) and removes spaces at the |
| 395 |
% end of the line. Then it adds the character with the character code |
| 396 |
% that is given by \cs{endlinechar} at the end of the line. The category |
| 397 |
% code of the inserted character is given by the current value of |
| 398 |
% its \cs{catcode}. If \cs{endlinechar} is not a valid character code |
| 399 |
% (especially if it is negative), then no character is added. |
| 400 |
% |
| 401 |
% In \hologo{plainTeX} and \hologo{LaTeX} the standard settings |
| 402 |
% of the inserted endline character is the character with code 13 |
| 403 |
% (or |^||^||M| in \hologo{TeX} notation) with catcode 5 (end of line). |
| 404 |
% That means the inserted end of line character behaves like a space |
| 405 |
% token. For example, it is removed after macro names. Therefore |
| 406 |
% \cs{eolgrab} changes the catcode. |
| 407 |
% |
| 408 |
% Therefore \cs{eolgrab} has some limitations: |
| 409 |
% \begin{itemize} |
| 410 |
% \item |
| 411 |
% Like other verbatim stuff, the macro \cs{eolgrab} cannot be |
| 412 |
% used in the argument of other macros. \cs{eolgrab} want to |
| 413 |
% change the catcode of the end of line character. If this |
| 414 |
% character is read before, because it is processed as argument |
| 415 |
% of another macro, the catcode is already set and is not reassigned |
| 416 |
% later if \cs{eolgrab} changes the category code for this character |
| 417 |
% code. |
| 418 |
% \item |
| 419 |
% The argument must not contain the end of line character. |
| 420 |
% Otherwise the first end of line character is already taken |
| 421 |
% as delimiter, leaving the rest of the line outside the argument. |
| 422 |
% \item |
| 423 |
% Because \cs{eolgrab} is probably mostly used in the line with |
| 424 |
% the delimited argument. Therefore changes of \cs{endlinechar} |
| 425 |
% will not affect the current line. |
| 426 |
% \end{itemize} |
| 427 |
% |
| 428 |
% \StopEventually{ |
| 429 |
% } |
| 430 |
% |
| 431 |
% \section{Implementation} |
| 432 |
% |
| 433 |
% \begin{macrocode} |
| 434 |
%<*package> |
| 435 |
% \end{macrocode} |
| 436 |
% |
| 437 |
% \subsection{Reload check and package identification} |
| 438 |
% Reload check, especially if the package is not used with \LaTeX. |
| 439 |
% \begin{macrocode} |
| 440 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 441 |
\catcode13=5 % ^^M |
| 442 |
\endlinechar=13 % |
| 443 |
\catcode35=6 % # |
| 444 |
\catcode39=12 % ' |
| 445 |
\catcode44=12 % , |
| 446 |
\catcode45=12 % - |
| 447 |
\catcode46=12 % . |
| 448 |
\catcode58=12 % : |
| 449 |
\catcode64=11 % @ |
| 450 |
\catcode123=1 % { |
| 451 |
\catcode125=2 % } |
| 452 |
\expandafter\let\expandafter\x\csname [email protected]\endcsname |
| 453 |
\ifx\x\relax % plain-TeX, first loading |
| 454 |
\else |
| 455 |
\def\empty{}% |
| 456 |
\ifx\x\empty % LaTeX, first loading, |
| 457 |
% variable is initialized, but \ProvidesPackage not yet seen |
| 458 |
\else |
| 459 |
\expandafter\ifx\csname PackageInfo\endcsname\relax |
| 460 |
\def\x#1#2{% |
| 461 |
\immediate\write-1{Package #1 Info: #2.}% |
| 462 |
}% |
| 463 |
\else |
| 464 |
\def\x#1#2{\PackageInfo{#1}{#2, stopped}}% |
| 465 |
\fi |
| 466 |
\x{eolgrab}{The package is already loaded}% |
| 467 |
\aftergroup\endinput |
| 468 |
\fi |
| 469 |
\fi |
| 470 |
\endgroup% |
| 471 |
% \end{macrocode} |
| 472 |
% Package identification: |
| 473 |
% \begin{macrocode} |
| 474 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 475 |
\catcode13=5 % ^^M |
| 476 |
\endlinechar=13 % |
| 477 |
\catcode35=6 % # |
| 478 |
\catcode39=12 % ' |
| 479 |
\catcode40=12 % ( |
| 480 |
\catcode41=12 % ) |
| 481 |
\catcode44=12 % , |
| 482 |
\catcode45=12 % - |
| 483 |
\catcode46=12 % . |
| 484 |
\catcode47=12 % / |
| 485 |
\catcode58=12 % : |
| 486 |
\catcode64=11 % @ |
| 487 |
\catcode91=12 % [ |
| 488 |
\catcode93=12 % ] |
| 489 |
\catcode123=1 % { |
| 490 |
\catcode125=2 % } |
| 491 |
\expandafter\ifx\csname ProvidesPackage\endcsname\relax |
| 492 |
\def\x#1#2#3[#4]{\endgroup |
| 493 |
\immediate\write-1{Package: #3 #4}% |
| 494 |
\xdef#1{#4}% |
| 495 |
}% |
| 496 |
\else |
| 497 |
\def\x#1#2[#3]{\endgroup |
| 498 |
#2[{#3}]% |
| 499 |
\ifx#1\@undefined |
| 500 |
\xdef#1{#3}% |
| 501 |
\fi |
| 502 |
\ifx#1\relax |
| 503 |
\xdef#1{#3}% |
| 504 |
\fi |
| 505 |
}% |
| 506 |
\fi |
| 507 |
\expandafter\x\csname [email protected]\endcsname |
| 508 |
\ProvidesPackage{eolgrab}% |
| 509 |
[2016/05/16 v1.1 Catch arguments delimited by end of line (HO)]% |
| 510 |
% \end{macrocode} |
| 511 |
% |
| 512 |
% \subsection{Catcodes} |
| 513 |
% |
| 514 |
% \begin{macrocode} |
| 515 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 516 |
\catcode13=5 % ^^M |
| 517 |
\endlinechar=13 % |
| 518 |
\catcode123=1 % { |
| 519 |
\catcode125=2 % } |
| 520 |
\catcode64=11 % @ |
| 521 |
\def\x{\endgroup |
| 522 |
\expandafter\edef\csname eolgrab@AtEnd\endcsname{% |
| 523 |
\endlinechar=\the\endlinechar\relax |
| 524 |
\catcode13=\the\catcode13\relax |
| 525 |
\catcode32=\the\catcode32\relax |
| 526 |
\catcode35=\the\catcode35\relax |
| 527 |
\catcode61=\the\catcode61\relax |
| 528 |
\catcode64=\the\catcode64\relax |
| 529 |
\catcode123=\the\catcode123\relax |
| 530 |
\catcode125=\the\catcode125\relax |
| 531 |
}% |
| 532 |
}% |
| 533 |
\x\catcode61\catcode48\catcode32=10\relax% |
| 534 |
\catcode13=5 % ^^M |
| 535 |
\endlinechar=13 % |
| 536 |
\catcode35=6 % # |
| 537 |
\catcode64=11 % @ |
| 538 |
\catcode123=1 % { |
| 539 |
\catcode125=2 % } |
| 540 |
\def\TMP@EnsureCode#1#2{% |
| 541 |
\edef\eolgrab@AtEnd{% |
| 542 |
\eolgrab@AtEnd |
| 543 |
\catcode#1=\the\catcode#1\relax |
| 544 |
}% |
| 545 |
\catcode#1=#2\relax |
| 546 |
} |
| 547 |
\TMP@EnsureCode{40}{12}% ( |
| 548 |
\TMP@EnsureCode{41}{12}% ) |
| 549 |
\TMP@EnsureCode{42}{12}% * |
| 550 |
\TMP@EnsureCode{46}{12}% . |
| 551 |
\TMP@EnsureCode{47}{12}% / |
| 552 |
\TMP@EnsureCode{91}{12}% [ |
| 553 |
\TMP@EnsureCode{93}{12}% ] |
| 554 |
\TMP@EnsureCode{94}{7}% ^ |
| 555 |
\edef\eolgrab@AtEnd{\eolgrab@AtEnd\noexpand\endinput} |
| 556 |
% \end{macrocode} |
| 557 |
% |
| 558 |
% \subsection{Resources} |
| 559 |
% |
| 560 |
% \begin{macrocode} |
| 561 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 562 |
\expandafter\ifx\csname RequirePackage\endcsname\relax |
| 563 |
\input ltxcmds.sty\relax |
| 564 |
\input infwarerr.sty\relax |
| 565 |
\else |
| 566 |
\RequirePackage{ltxcmds}[2010/12/04]% |
| 567 |
\RequirePackage{infwarerr}[2010/04/08]% |
| 568 |
\fi |
| 569 |
% \end{macrocode} |
| 570 |
% |
| 571 |
% \begin{macro}{\eolgrab@ifdefinable} |
| 572 |
% \begin{macrocode} |
| 573 |
\ltx@IfUndefined{@ifdefinable}{% |
| 574 |
\def\eolgrab@ifdefinable#1#2{% |
| 575 |
\ltx@ifundefined{#1}{#2}{% |
| 576 |
\@PackageError{eolgrab}{% |
| 577 |
Command \ltx@backslashchar#1 already defined% |
| 578 |
}\@ehc |
| 579 |
}% |
| 580 |
}% |
| 581 |
}{% |
| 582 |
\def\eolgrab@ifdefinable#1{% |
| 583 |
\expandafter\@ifdefinable\csname#1\endcsname |
| 584 |
}% |
| 585 |
} |
| 586 |
% \end{macrocode} |
| 587 |
% \end{macro} |
| 588 |
% |
| 589 |
% \subsection{Macro \cs{eolgrab}} |
| 590 |
% |
| 591 |
% \begin{macro}{\eolgrab} |
| 592 |
% \begin{macrocode} |
| 593 |
\eolgrab@ifdefinable{eolgrab}{% |
| 594 |
\ltx@IfUndefined{protected}{% |
| 595 |
\ltx@IfUndefined{DeclareRobustCommand}{% |
| 596 |
\def\eolgrab#1% |
| 597 |
}{% |
| 598 |
\newcommand\eolgrab{}% |
| 599 |
\DeclareRobustCommand*\eolgrab |
| 600 |
}% |
| 601 |
}{% |
| 602 |
\protected\def\eolgrab#1% |
| 603 |
}{% |
| 604 |
\begingroup |
| 605 |
\endlinechar=13 % |
| 606 |
\catcode13=\ltx@active |
| 607 |
\eolgrab@{#1}% |
| 608 |
}% |
| 609 |
} |
| 610 |
% \end{macrocode} |
| 611 |
% \end{macro} |
| 612 |
% |
| 613 |
% \begin{macro}{\eolgrabopt} |
| 614 |
% \begin{macrocode} |
| 615 |
\eolgrab@ifdefinable{eolgrabopt}{% |
| 616 |
\ltx@IfUndefined{protected}{% |
| 617 |
\ltx@IfUndefined{DeclareRobustCommand}{% |
| 618 |
\def\eolgrabopt#1% |
| 619 |
}{% |
| 620 |
\newcommand\eolgrabopt{}% |
| 621 |
\DeclareRobustCommand*\eolgrabopt |
| 622 |
}% |
| 623 |
}{% |
| 624 |
\protected\def\eolgrabopt#1% |
| 625 |
}{% |
| 626 |
\begingroup |
| 627 |
\endlinechar=13 % |
| 628 |
\catcode13=\ltx@active |
| 629 |
\eolgrab@opt{#1}% |
| 630 |
}% |
| 631 |
} |
| 632 |
% \end{macrocode} |
| 633 |
% \end{macro} |
| 634 |
% |
| 635 |
% \begin{macrocode} |
| 636 |
\begingroup |
| 637 |
\catcode13=\ltx@active % |
| 638 |
\ltx@firstofone{\endgroup % |
| 639 |
% \end{macrocode} |
| 640 |
% \begin{macro}{\eolgrab@} |
| 641 |
% \begin{macrocode} |
| 642 |
\def\eolgrab@#1#2^^M{% |
| 643 |
\endgroup % |
| 644 |
#1{#2}% |
| 645 |
}% |
| 646 |
% \end{macrocode} |
| 647 |
% \end{macro} |
| 648 |
% \begin{macro}{\eolgrab@opt} |
| 649 |
% \begin{macrocode} |
| 650 |
\def\eolgrab@opt#1#2^^M{% |
| 651 |
\endgroup % |
| 652 |
\ltx@ifempty{#2}{% |
| 653 |
#1% |
| 654 |
}{% |
| 655 |
#1[{#2}]% |
| 656 |
}% |
| 657 |
}% |
| 658 |
% \end{macrocode} |
| 659 |
% \end{macro} |
| 660 |
% \begin{macrocode} |
| 661 |
}% |
| 662 |
% \end{macrocode} |
| 663 |
% |
| 664 |
% \begin{macrocode} |
| 665 |
\eolgrab@AtEnd% |
| 666 |
% \end{macrocode} |
| 667 |
% \begin{macrocode} |
| 668 |
%</package> |
| 669 |
% \end{macrocode} |
| 670 |
%% \section{Installation} |
| 671 |
% |
| 672 |
% \subsection{Download} |
| 673 |
% |
| 674 |
% \paragraph{Package.} This package is available on |
| 675 |
% CTAN\footnote{\CTANpkg{eolgrab}}: |
| 676 |
% \begin{description} |
| 677 |
% \item[\CTAN{macros/latex/contrib/oberdiek/eolgrab.dtx}] The source file. |
| 678 |
% \item[\CTAN{macros/latex/contrib/oberdiek/eolgrab.pdf}] Documentation. |
| 679 |
% \end{description} |
| 680 |
% |
| 681 |
% |
| 682 |
% \paragraph{Bundle.} All the packages of the bundle `oberdiek' |
| 683 |
% are also available in a TDS compliant ZIP archive. There |
| 684 |
% the packages are already unpacked and the documentation files |
| 685 |
% are generated. The files and directories obey the TDS standard. |
| 686 |
% \begin{description} |
| 687 |
% \item[\CTANinstall{install/macros/latex/contrib/oberdiek.tds.zip}] |
| 688 |
% \end{description} |
| 689 |
% \emph{TDS} refers to the standard ``A Directory Structure |
| 690 |
% for \TeX\ Files'' (\CTANpkg{tds}). Directories |
| 691 |
% with \xfile{texmf} in their name are usually organized this way. |
| 692 |
% |
| 693 |
% \subsection{Bundle installation} |
| 694 |
% |
| 695 |
% \paragraph{Unpacking.} Unpack the \xfile{oberdiek.tds.zip} in the |
| 696 |
% TDS tree (also known as \xfile{texmf} tree) of your choice. |
| 697 |
% Example (linux): |
| 698 |
% \begin{quote} |
| 699 |
% |unzip oberdiek.tds.zip -d ~/texmf| |
| 700 |
% \end{quote} |
| 701 |
% |
| 702 |
% \subsection{Package installation} |
| 703 |
% |
| 704 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 705 |
% \docstrip\ archive. The files are extracted by running the |
| 706 |
% \xfile{.dtx} through \plainTeX: |
| 707 |
% \begin{quote} |
| 708 |
% \verb|tex eolgrab.dtx| |
| 709 |
% \end{quote} |
| 710 |
% |
| 711 |
% \paragraph{TDS.} Now the different files must be moved into |
| 712 |
% the different directories in your installation TDS tree |
| 713 |
% (also known as \xfile{texmf} tree): |
| 714 |
% \begin{quote} |
| 715 |
% \def\t{^^A |
| 716 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 717 |
% eolgrab.sty & tex/generic/oberdiek/eolgrab.sty\\ |
| 718 |
% eolgrab.pdf & doc/latex/oberdiek/eolgrab.pdf\\ |
| 719 |
% example/eolgrab-example-ltx.tex & doc/latex/oberdiek/example/eolgrab-example-ltx.tex\\ |
| 720 |
% example/eolgrab-example-env.tex & doc/latex/oberdiek/example/eolgrab-example-env.tex\\ |
| 721 |
% example/eolgrab-example-sec.tex & doc/latex/oberdiek/example/eolgrab-example-sec.tex\\ |
| 722 |
% eolgrab.dtx & source/latex/oberdiek/eolgrab.dtx\\ |
| 723 |
% \end{tabular}^^A |
| 724 |
% }^^A |
| 725 |
% \sbox0{\t}^^A |
| 726 |
% \ifdim\wd0>\linewidth |
| 727 |
% \begingroup |
| 728 |
% \advance\linewidth by\leftmargin |
| 729 |
% \advance\linewidth by\rightmargin |
| 730 |
% \edef\x{\endgroup |
| 731 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 732 |
% }\x |
| 733 |
% \def\lwbox{^^A |
| 734 |
% \leavevmode |
| 735 |
% \hbox to \linewidth{^^A |
| 736 |
% \kern-\leftmargin\relax |
| 737 |
% \hss |
| 738 |
% \usebox0 |
| 739 |
% \hss |
| 740 |
% \kern-\rightmargin\relax |
| 741 |
% }^^A |
| 742 |
% }^^A |
| 743 |
% \ifdim\wd0>\lw |
| 744 |
% \sbox0{\small\t}^^A |
| 745 |
% \ifdim\wd0>\linewidth |
| 746 |
% \ifdim\wd0>\lw |
| 747 |
% \sbox0{\footnotesize\t}^^A |
| 748 |
% \ifdim\wd0>\linewidth |
| 749 |
% \ifdim\wd0>\lw |
| 750 |
% \sbox0{\scriptsize\t}^^A |
| 751 |
% \ifdim\wd0>\linewidth |
| 752 |
% \ifdim\wd0>\lw |
| 753 |
% \sbox0{\tiny\t}^^A |
| 754 |
% \ifdim\wd0>\linewidth |
| 755 |
% \lwbox |
| 756 |
% \else |
| 757 |
% \usebox0 |
| 758 |
% \fi |
| 759 |
% \else |
| 760 |
% \lwbox |
| 761 |
% \fi |
| 762 |
% \else |
| 763 |
% \usebox0 |
| 764 |
% \fi |
| 765 |
% \else |
| 766 |
% \lwbox |
| 767 |
% \fi |
| 768 |
% \else |
| 769 |
% \usebox0 |
| 770 |
% \fi |
| 771 |
% \else |
| 772 |
% \lwbox |
| 773 |
% \fi |
| 774 |
% \else |
| 775 |
% \usebox0 |
| 776 |
% \fi |
| 777 |
% \else |
| 778 |
% \lwbox |
| 779 |
% \fi |
| 780 |
% \else |
| 781 |
% \usebox0 |
| 782 |
% \fi |
| 783 |
% \end{quote} |
| 784 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 785 |
% TDS installing feature, then some files can already be in the right |
| 786 |
% place, see the documentation of \docstrip. |
| 787 |
% |
| 788 |
% \subsection{Refresh file name databases} |
| 789 |
% |
| 790 |
% If your \TeX~distribution |
| 791 |
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh |
| 792 |
% these. For example, \TeX\,Live\ users run \verb|texhash| or |
| 793 |
% \verb|mktexlsr|. |
| 794 |
% |
| 795 |
% \subsection{Some details for the interested} |
| 796 |
% |
| 797 |
% \paragraph{Unpacking with \LaTeX.} |
| 798 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 799 |
% \begin{description} |
| 800 |
% \item[\plainTeX:] Run \docstrip\ and extract the files. |
| 801 |
% \item[\LaTeX:] Generate the documentation. |
| 802 |
% \end{description} |
| 803 |
% If you insist on using \LaTeX\ for \docstrip\ (really, |
| 804 |
% \docstrip\ does not need \LaTeX), then inform the autodetect routine |
| 805 |
% about your intention: |
| 806 |
% \begin{quote} |
| 807 |
% \verb|latex \let\install=y\input{eolgrab.dtx}| |
| 808 |
% \end{quote} |
| 809 |
% Do not forget to quote the argument according to the demands |
| 810 |
% of your shell. |
| 811 |
% |
| 812 |
% \paragraph{Generating the documentation.} |
| 813 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 814 |
% the documentation. The process can be configured by the |
| 815 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put this |
| 816 |
% line into this file, if you want to have A4 as paper format: |
| 817 |
% \begin{quote} |
| 818 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 819 |
% \end{quote} |
| 820 |
% An example follows how to generate the |
| 821 |
% documentation with pdf\LaTeX: |
| 822 |
% \begin{quote} |
| 823 |
%\begin{verbatim} |
| 824 |
%pdflatex eolgrab.dtx |
| 825 |
%makeindex -s gind.ist eolgrab.idx |
| 826 |
%pdflatex eolgrab.dtx |
| 827 |
%makeindex -s gind.ist eolgrab.idx |
| 828 |
%pdflatex eolgrab.dtx |
| 829 |
%\end{verbatim} |
| 830 |
% \end{quote} |
| 831 |
% |
| 832 |
% \begin{thebibliography}{9} |
| 833 |
% \raggedright |
| 834 |
% \bibitem{trautmann-request} |
| 835 |
% Arno Trautmann, |
| 836 |
% \textit{[texhax] read argument until EOL}; |
| 837 |
% mailing list \texttt{[email protected]}, |
| 838 |
% 2011-01-06; |
| 839 |
% \url{https://tug.org/pipermail/texhax/2011-January/016517.html}. |
| 840 |
% |
| 841 |
% \bibitem{taylor} |
| 842 |
% Philip Taylor, |
| 843 |
% \textit{Re: [texhax] read argument until EOL}; |
| 844 |
% mailing list \texttt{[email protected]}, |
| 845 |
% 2011-01-06; |
| 846 |
% \url{https://tug.org/pipermail/texhax/2011-January/016519.html}. |
| 847 |
% |
| 848 |
% \bibitem{oberdiek-eolgrab} |
| 849 |
% Heiko Oberdiek, |
| 850 |
% \textit{Re: [texhax] read argument until EOL}; |
| 851 |
% mailing list \texttt{[email protected]}, |
| 852 |
% 2011-01-06; |
| 853 |
% \url{https://tug.org/pipermail/texhax/2011-January/016526.html}. |
| 854 |
% |
| 855 |
% \end{thebibliography} |
| 856 |
% |
| 857 |
% \begin{History} |
| 858 |
% \begin{Version}{2011/01/12 v1.0} |
| 859 |
% \item |
| 860 |
% First public version. |
| 861 |
% \end{Version} |
| 862 |
% \begin{Version}{2016/05/16 v1.1} |
| 863 |
% \item |
| 864 |
% Documentation updates. |
| 865 |
% \end{Version} |
| 866 |
% \end{History} |
| 867 |
% |
| 868 |
% \PrintIndex |
| 869 |
% |
| 870 |
% \Finale |
| 871 |
\endinput |