1

I have my own letterclass using scrlttr2:

%mwe.cls
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{mwe}[2010/11/19 mwe.cls]

\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrlttr2}}
\ProcessOptions\relax

%\RequirePackage{graphicx}
\RequirePackage[english]{babel}

\LoadClass{scrlttr2}

that I want to customize with .lco-files, like:

%mweelco.lco
\setkomavar{date}{.lco read!!}

Now I want to use it in a letter:

\documentclass[mwelco]%
{mwe}%(1)
\begin{document}
\begin{letter}{--Im Hause--}
%\LoadLetterOptions{mwelco}%(2)
\opening{test}
Content
\end{letter}
\end{document}

I want to give (1) the mwelco-option as an option to the documentclass and would rather not want to (2) use later in the file a \LoadLetterOptions.

However, only (2) works but (1) does not.

More strangely, if I comment babel out, then (1) and (2) work. Also, if I comment babel out and require graphicx (for argument's sake) also (1) and (2) work.

So there is some interaction between DeclareOption* and babel, that gets into my way. (Last September, with older texlive, it worked. Just checked, with out-of-the-box teelive-2019 babel works with (1) and (2).) I am using up-todate-texlive-2020.

edit (let me explain ``doesn't work¨ better): I expected the behavior, that saying in the tex-file: \documentclass[mwelco]{mwe} would lead mwe.cls to (A) load scrlttr2, (B) make scrlttr2 load the mwelco.lco file. But this does not happen.

Two ways that make this work are: (C) comment out the required babel or (D) to \LoadLetterOptions{mwelco} in the letter.tex. Clearly, (C) is unacceptable and (D) is clumsy and spreads an option to the letter class to a location much later.

So it seems that requiring babel even after \DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrlttr2}} \ProcessOptions\relax in the package seems to have side effect on the option mwelco being passed to scrlttr2 or not. This is what I can not understand. I would appreciate help in avoiding this problem.

1
  • 1
    Please, what does “doesn't work“ mean exactly? – Javier Bezos Feb 24 at 16:09
2

Load package babel after class scrlttr2 in your wrapper class:

\begin{filecontents*}[overwrite]{testclass.cls}
\ProvidesClass{testclass}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{scrlttr2}}
\ProcessOptions\relax
\RequirePackage{graphicx}
\LoadClassWithOptions{scrlttr2}
\RequirePackage[english]{babel}% <- moved
\end{filecontents*}

\begin{filecontents*}{mwelco.lco}
\setkomavar{date}{.lco read!!}
\end{filecontents*}

\documentclass[mwelco]{testclass}
\begin{document}
\begin{letter}{--Im Hause--}
\opening{test}
Content
\end{letter}
\end{document}
2
  • Great, thanks for the change that fixes it! Please could you explain a bit, why this was wrong (until 8/2020 it worked in TeXLive nevertheless). Do you know which package's change triggered this, so that I can improve the headline (for posteriority)? – Sven Feb 26 at 9:28
  • Option processing in babel have been changed several times. And there were changes in the latex kernel. – esdd Feb 26 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.