I could really use some help - I've been using LaTeX casually for several years, but have rarely had to dive into the details or problems, and I can't figure this out.
Problem
I am working with a .cls file given to me from my organization that has a (possibly) problematic line. It defines a macro that stores the second digit of the inputted point size, and then uses that to input a .clo file. A paired down MWE is as follows:
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}
\RequirePackage{etoolbox}
\newrobustcmd@ptsize{}
\DeclareOption{10pt}{\renewrobustcmd@ptsize{0}}
\DeclareOption{11pt}{\renewrobustcmd@ptsize{1}}
\DeclareOption{12pt}{\renewrobustcmd@ptsize{2}}
\ExecuteOptions{11pt}
\ProcessOptions
\input{size1@ptsize.clo}
I've also created a MWE .tex file to compile:
\documentclass[11pt]{mwe}
\begin{document}
\end{document}
However, when I compile this using latexmk -synctex=1 -interaction=nonstopmode -file-line-error -pdf -outdir=%OUTDIR% %DOC% (inside VSCode using LaTeX Workshop), I get this log file with a message saying
`File `size1@ptsize.clo' not found`
The log says:
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (MiKTeX 20.11) (preloaded format=pdflatex 2020.11.3) 3 NOV 2020 08:57
entering extended mode
**"path/to/mwe/mwe.tex"
("path/to/mwe/mwe.tex"
LaTeX2e <2020-10-01> patch level 2
L3 programming layer <2020-10-27> xparse <2020-03-03> ("path/to\mwe\mwe.cls" <-- In case it matters, these slashes
Document Class: mwe really do switch directions
(path\to\tex/latex/etoolbox\etoolbox.sty <-- Here as well
Package: etoolbox 2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
\etb@tempcnta=\count175
)
! LaTeX Error: File `size1@ptsize.clo' not found.
Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: clo)
Enter file name:
Potential Solution
Here's the thing: if I change the .cls file so that @ptsize is defined via \newcommand and \renewcommand instead of via \newrobustcmd and \renewrobustcmd, then the above MWE .tex file works just fine, generating a blank (two-page) PDF.
Could anybody a) explain why this is happening (as far as I know, this .cls file works fine for other people in my organization), and b) what the best-practices approach would be for this problem? Thank you in advance!
\renewcommandthere, instead of therobustversion. – Phelype Oleinik Nov 03 '20 at 14:25\newcommandand using\renewcommand(not defining with\newrobustcmdand using\renewcommand)? – Adam Kern Nov 03 '20 at 14:33\edef, or a\write---for example when you use\includegraphicsin a\caption, like here), so these commands are defined robust so that they do not expand in those places. But what you want with\@ptsizehere is precisely the opposite: you want it to expand to0or1or2, so robust is conceptually wrong here. I'll write an answer with a bit more detail (this change might affect other people too) – Phelype Oleinik Nov 03 '20 at 14:40