1

I have a general question which I couldn't solve so far. It came up a few days ago, while I was trying to redefine the different parts of the footer of the scrlayer-scrpage package (this still isn't solved for me).

But i want to understand it in general. So far, I've read a lot of (basic) documentation (source2e, scrlayer-scrpage.dtx etc.) and still couldn't figure it out:

In some command/environment-definitons there appear "elements" which have no backslash at the start of the name. For example the elements even, left and foot in the definition of the \lefoot command from scrlayer-scrpage:

$ latexdef -p scrlayer-scrpage -f lefoot
\lefoot first defined in "scrlayer-scrpage.sty".

\lefoot: macro:->\sls@renewelement {even}{left}{foot}

or the element labelitem (inside the curly brackets, first word) in the general definition of the itemize environment:

$ latexdef -f itemize
\itemize is defined by (La)TeX.

\itemize: macro:->\ifnum @itemdepth >\thr@@ @toodeep \else \advance @itemdepth @ne \edef @itemitem {labelitem\romannumeral \the @itemdepth }\expandafter \list \csname @itemitem \endcsname {\def \makelabel ##1{\hss \llap {##1}}}\fi

How can i find out what they mean/how they are defined? So far, i have no real clue.

I'm aware that the answer may be really simple, but right now I am at a loss...

Thanks for all replies!

lukeflo
  • 1,555

1 Answers1

3

The labelitem in \itemize is literally just a string of characters. From latex.ltx you find

\def\itemize{%
  \ifnum \@itemdepth >\thr@@\@toodeep\else
    \advance\@itemdepth\@ne
    \edef\@itemitem{labelitem\romannumeral\the\@itemdepth}%
    \expandafter
    \list
      \csname\@itemitem\endcsname
      {\def\makelabel##1{\hss\llap{##1}}}%
  \fi}

The line \edef\@itemitem{labelitem\romannumeral\the\@itemdepth} sets the macro \@itemitem to take the value of the string labelitem followed by the lowercase Roman numeral representation of the current "depth" of the list. So if have a nested list and the second level is an itemize, you have \@itemdepth is equal to 2, in which case the line becomes \edef\@itemitem{labelitemii}. In other words, the macro \@itemitem is defined to be the string labelitemii.

Now this by itself is not that useful, but if you scan down a couple lines, you find that it issues \csname\@itemitem\endcsname which expands to \csname labelitemii\endcsname in our example, which is equivalent to calling \labelitemii (that's the purpose of \csname ... \endcsname).

This is an example of how you can build variable names programmatically in TeX (in many other programming languages something similar would perhaps be handled by using an "array" or a "dictionary", which concepts are absent in TeX).


The \sls@renewelement{even}{left}{foot} functions similarly; basically it makes \lefoot{SOMETHING} equal to \sls@renewelement{even}{left}{foot}{SOMETHING}, and the definition of \sls@renewelement{A}{B}{C}{SOMETHING} builds an internal variable/macro whose name incorporates the strings A, B, and C (more precisely, in the case of \lefoot you get a macro named \sls@ps@scrheadings@even@left@foot) and sets it equal to SOMETHING.

Willie Wong
  • 24,733
  • 8
  • 74
  • 106
  • Hi @Willie thanks for the explanation. It makes absolutely sense that expanding \@itemitem inside the \csname command results in \labelitemii. Latex is just so different from other programming languages... The foot thing also makes some sense, but i still don't fully understand how the standard layout of the commands \lefoot, \cefoot and \refoot are defined (e.g. as centered \mbox or something else) and where to find it. There has to be one. E.g. if i use the package without edits the pagenumber appears at the outside of the footer (which should be \rofoot or \lefoot). – lukeflo Jun 07 '23 at 08:32
  • But the second part belongs more to my particular question concerning the footer. I don't want to hijack my own question ;) – lukeflo Jun 07 '23 at 08:33
  • The commands \lefoot etc are just wrappers for commands to _re_define the pagestyle. Each of scrreprt.cls, scrartcl.cls, and scrbook.cls sets the footers using direct calls to those \<loc>foot commands; for example, they all have somewhere \cfoot[\pagemark]{} to have the page number appear centered in the footer. – Willie Wong Jun 07 '23 at 13:34
  • So to find out where the scrlayer-scrpage package sets the "defaults", you need to look for where those commands are called, and not where they are defined. For example, if your load the package not from one of the KOMA document classes, it will default to the standard page style; looking at where \sls@ps@style@standard is defined, you see that it calls \ohead{\pagemark} and \cfoot[\if@twoside\else\pagemark\fi]{}. Note that these just says what goes where; the actual formatting is done by whatever sets \pagemark. – Willie Wong Jun 07 '23 at 13:45