| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% Copyright (C) 2015 by Ruben Giannotti |
| 4 |
% <ruben dot giannotti at gmx dot net> |
| 5 |
% ------------------------------------------------------- |
| 6 |
% |
| 7 |
% This work may be distributed and/or modified under the |
| 8 |
% conditions of the LaTeX Project Public License, either |
| 9 |
% version 1.3c of this license or (at your option) any |
| 10 |
% later version. The latest version of this license is in |
| 11 |
% http://www.latex-project.org/lppl.txt |
| 12 |
% and version 1.3 or later is part of all distributions |
| 13 |
% of LaTeX version 2005/12/01 or later. |
| 14 |
% |
| 15 |
% This work has the LPPL maintenance status `maintained'. |
| 16 |
% |
| 17 |
% The Current Maintainer of this work is Ruben Giannotti. |
| 18 |
% |
| 19 |
% This work consists of the files |
| 20 |
% fetchcls.dtx |
| 21 |
% fetchcls.ins |
| 22 |
% and the derived file fetchcls.sty. |
| 23 |
% |
| 24 |
% \fi |
| 25 |
% |
| 26 |
% \iffalse |
| 27 |
%<*driver> |
| 28 |
\ProvidesFile{fetchcls.dtx} |
| 29 |
%</driver> |
| 30 |
%<package>\NeedsTeXFormat{LaTeX2e}[2008/04/05] |
| 31 |
%<package>\ProvidesPackage{fetchcls} |
| 32 |
%<*package> |
| 33 |
[2015/08/11 v1.0 Fetch the class name (RG)] |
| 34 |
%</package> |
| 35 |
% |
| 36 |
%<*driver> |
| 37 |
\documentclass{ltxdoc} |
| 38 |
\usepackage{parskip} |
| 39 |
\setlength\parindent{0pt} |
| 40 |
\providecommand*\pkg{} |
| 41 |
\providecommand*\url{} |
| 42 |
\providecommand*\email{} |
| 43 |
\renewcommand\pkg{\textsf} |
| 44 |
\renewcommand\url{\texttt} |
| 45 |
\renewcommand\email{\texttt} |
| 46 |
\begin{document} |
| 47 |
\DocInput{fetchcls.dtx} |
| 48 |
\end{document} |
| 49 |
%</driver> |
| 50 |
% \fi |
| 51 |
% |
| 52 |
% \CheckSum{13} |
| 53 |
% |
| 54 |
% \CharacterTable |
| 55 |
% {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 |
| 56 |
% 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 |
| 57 |
% Digits \0\1\2\3\4\5\6\7\8\9 |
| 58 |
% Exclamation \! Double quote \" Hash (number) \# |
| 59 |
% Dollar \$ Percent \% Ampersand \& |
| 60 |
% Acute accent \' Left paren \( Right paren \) |
| 61 |
% Asterisk \* Plus \+ Comma \, |
| 62 |
% Minus \- Point \. Solidus \/ |
| 63 |
% Colon \: Semicolon \; Less than \< |
| 64 |
% Equals \= Greater than \> Question mark \? |
| 65 |
% Commercial at \@ Left bracket \[ Backslash \\ |
| 66 |
% Right bracket \] Circumflex \^ Underscore \_ |
| 67 |
% Grave accent \` Left brace \{ Vertical bar \| |
| 68 |
% Right brace \} Tilde \~} |
| 69 |
% |
| 70 |
% |
| 71 |
% \changes{v1.0}{2015/08/11}{Initial version} |
| 72 |
% |
| 73 |
% \GetFileInfo{fetchcls.dtx} |
| 74 |
% |
| 75 |
% \DoNotIndex{\newcommand,\newenvironment,\!,\@empty,\@gobble,\@gobbletwo} |
| 76 |
% \DoNotIndex{\@ifpackageloaded,\@ifpackagewith,\@ifundefined,\@namedef} |
| 77 |
% \DoNotIndex{\@nil,\@onlypreamble,\@tempa,\@tempb,\@tempswafalse,\def} |
| 78 |
% \DoNotIndex{\@tempswatrue,\^,\-,\active,\begingroup,\catcode,\@car,\@cdr} |
| 79 |
% \DoNotIndex{\edef,\else,\endgroup,\endinput,\expandafter,\fi,\if} |
| 80 |
% \DoNotIndex{\if@tempswa,\ifcase,\ifnum,\ifx,\lccode,\let,\lowercase} |
| 81 |
% \DoNotIndex{\MessageBreak,\next,\number,\numexpr,\or,\PackageError} |
| 82 |
% \DoNotIndex{\PackageWarning,\PackageWarningNoLine,\strip@prefix,\@@end} |
| 83 |
% \DoNotIndex{\relax,\space,\string,\DeclareOption,\ProcessOptions} |
| 84 |
% \DoNotIndex{\meaning,\ifdefined,\csname,\chardef,\endcsname,\protect} |
| 85 |
% \DoNotIndex{\input,\RequirePackage,\global,\ifcsname,\makeatother} |
| 86 |
% \DoNotIndex{\@makeother,\the,\toks@} |
| 87 |
% |
| 88 |
% \title{The \pkg{fetchcls} package\thanks{This document |
| 89 |
% corresponds to \pkg{fetchcls}~\fileversion, dated \filedate.}} |
| 90 |
% \author{Ruben Giannotti\thanks{\email{ruben dot giannotti at gmx dot net}}} |
| 91 |
% \date{August, 11 2015} |
| 92 |
% |
| 93 |
% \maketitle |
| 94 |
% |
| 95 |
% With standard \LaTeX\ you are able to check for the class in use |
| 96 |
% invoking the kernel command \cs{@ifclassloaded}. |
| 97 |
% However, doing so you can't get the explicit class name |
| 98 |
% (unless you want to loop over every possible class name |
| 99 |
% until \cs{@ifclassloaded} returns true -- don't do that!) |
| 100 |
% With the present package you can get the name with significantly less effort. |
| 101 |
% Just load the package as usual: |
| 102 |
% \begin{flushleft} |
| 103 |
% \cs{usepackage}\{fetchcls\} |
| 104 |
% \end{flushleft} |
| 105 |
% Then, the control sequence \cs{classname} will hold the name of the current class. |
| 106 |
% |
| 107 |
% \StopEventually{} |
| 108 |
% |
| 109 |
% Let's have a brief look on how the two code lines of this package tackle this task. |
| 110 |
% |
| 111 |
% We will use the \cs{@filelist} to retrive the class name |
| 112 |
% as it contains the class name as its first entry. |
| 113 |
% Since the class is captured with its extension we define a macro |
| 114 |
% with the explicit class extension of \LaTeX\ as delimiter. |
| 115 |
% Then the rest will be read until the end and thrown away. |
| 116 |
% Everything in front of the delimiter will be written into \cs{classname}. |
| 117 |
% \begin{macrocode} |
| 118 |
\def\f@tchcls#1.cls#2 {\def\classname{#1}} |
| 119 |
% \end{macrocode} |
| 120 |
% The next and alredy last step consists in |
| 121 |
% apllying \cs{f@tchcls} to the \cs{@filelist} |
| 122 |
% while ensuring that it gets expanded before \cs{f@tchcls} reads it. |
| 123 |
% \begin{macrocode} |
| 124 |
\begingroup\edef\x{\endgroup\noexpand\f@tchcls\@filelist\space}\x |
| 125 |
% \end{macrocode} |
| 126 |
% |
| 127 |
% \Finale |
| 128 |
\endinput |