0

This question somehow extends the question "Package option vs setup command".

I'm currently writing a class dedicated to students reports for both academic projects and internships. This class provides a \reportsetup command that lets the user setting things up via keys/values.

For example, one thing that can be set up is the company's name of the internship. It appears that this could be done both:

  • via a command: \companyname{⟨name⟩},
  • via a key=value: \reportsetup{companyname = ⟨name⟩},

and this, whether the class considers the company's name mandatory or not: both commands and keys may be mandatory or optional.

This is just an example but potentially applies to all commands all classes (or packages) could provide.

What would be the best between these two practices?

  • 1
    Personally, I always use setup macro for mandatory (else it will not compile) definitions and key-value-interfaces for anything else (mandatory, if feature used, optional, etc.). But I think it also comes down to personal preference. – TeXnician Apr 5 at 9:27
  • @TeXnician How do you deal with commands with more than one mandatory argument? For instance, does a command such as \advisor{⟨first name⟩}{⟨last name⟩} become a key-value such as advisor = {⟨first name⟩}{⟨last name⟩}? – Denis Bitouzé Apr 8 at 13:48
  • 1
    If the advisor is not mandatory for compilation I would make it a key-value-option, yes. But with multiple mandatory arguments I have previously gone the subkeying route (something along the lines of advisor = {firstname=John, lastname=Doe}) which might not be optimal. That said, if there is no need to split these information I do not do it (if I know advisor will only be printed on title page then it is a user-formatted field, so only one), and I would recommend reducing the amount of multiple-mandatory-argument fields. – TeXnician Apr 8 at 13:53
  • advisor = {firstname=John, lastname=Doe}: non optimal because "too much"? I need to split the information (first vs last names) because, in French, it is common to typeset the last name in small caps. – Denis Bitouzé Apr 9 at 9:14
  • 1
    Non-optimal because too much and because names are hard (what about middle names etc.?). If I could, I would use biblatex's name detection on that. But still, if I had to do it, I would probably choose that way again. – TeXnician Apr 9 at 9:32

Your Answer

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

Browse other questions tagged or ask your own question.