-1

Needing help of explainning the meaning of the following code for me, the code is in the file "PostDocRep.cls" that begins with

    \NeedsTeXFormat{LaTeX2e}[1995/12/01]
    \ProvidesClass{PostDocRep}
      [2009/09/23 v0.1e PostDocRep
       document class]
    ........
\def\PDR@getfileinfo#1 #2 #3\relax#4\relax{%
  \def\PDRfiledate{#1}%
  \def\PDRfileversion{#2}%
  \def\PDRfileinfo{#3}}%
\expandafter\ifx\csname ver@PostDocRep.cls\endcsname\relax
  \edef\reserved@a{\csname ver@ctextemp_PostDocRep.cls\endcsname}
\else
  \edef\reserved@a{\csname ver@PostDocRep.cls\endcsname}
\fi
\expandafter\PDR@getfileinfo\reserved@a\relax? ? \relax\relax

I do not know what is the result of statement

\expandafter\ifx\csname ver@PostDocRep.cls\endcsname\relax

if it ture or false and which branch it selects?

\edef\reserved@a{\csname ver@ctextemp_PostDocRep.cls\endcsname} 

or

  \edef\reserved@a{\csname ver@PostDocRep.cls\endcsname}

Moreover, I have no idea of how the statement

\expandafter\PDR@getfileinfo\reserved@a\relax? ? \relax\relax 

execute? why there are so many \relax,

David Carlisle
  • 757,742
  • 3
    this is the third question you have asked where you just pick one line out of context and ask what it means. I'm not sure it's a useful way to learn latex. – David Carlisle Apr 09 '22 at 22:22
  • the code depends on ver@ctextemp_PostDocRep.cls which is presumably defined somewhere in code you have not shown. – David Carlisle Apr 09 '22 at 22:33
  • \expandafter\ifx\csname ver@PostDocRep.cls\endcsname\relax should never be true as it follows \ProvidesClass{PostDocRep} that defines that command so it is hard to guess why this test is there without seeing the full context – David Carlisle Apr 09 '22 at 22:36
  • 3
    Why are you using a decade old document class that someone gave you but you don't understand? – Teepeemm Apr 09 '22 at 22:43
  • @DavidCarlisle can I upload the wholefile, and the name of the whole class file is PostDocRep.cls the begins with \NeedsTeXFormat{LaTeX2e}[1995/12/01] \ProvidesClass{PostDocRep} [2009/09/23 v0.1e PostDocRep document class] ........ meanwhile, there is no ver@ctextemp_PostDocRep.cls at all, only the file PostDocRep.cls – Peter Yang Apr 09 '22 at 23:27
  • well as I say that branch chould never be used as the test is pointless the command will always be defined in latex. the code probably predates latex. But anyway I already posted an answer. – David Carlisle Apr 09 '22 at 23:34
  • If you really want to learn LaTeX programming refer to package writing - Where do I start LaTeX programming? - TeX - LaTeX Stack Exchange. Otherwise, I think asking people to do work for you every time is not going to be very well-received – user202729 Apr 10 '22 at 04:09

1 Answers1

5

\reserved@a will be 2009/09/23 v0.1e PostDocRep document class

so \expandafter\PDR@getfileinfo\reserved@a\relax

is

\PDR@getfileinfo 2009/09/23 v0.1e PostDocRep document class\relax

which will do

  \def\PDRfiledate{2009/09/23}%
  \def\PDRfileversion{v0.1e}%
  \def\PDRfileinfo{PostDocRep document class}%

The trailing ? and \relax ensure that even if for some reason \reserved@a did not have the right form there would still be some space characters and \relax so that \PDR@getfileinfo will always see the arguments and not have a runaway argument error looking for a string delimited by a missing \relax

David Carlisle
  • 757,742