Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Consider a package (or class) which provides macros with two optional arguments. One could

(i) use twoopt. The code in the .sty-file is easy to read and, consequently, to understand.

(ii) handcode the macro. The code looks horrible, but does not bind the user to an additional package.

Also, sometimes there are several packages to achieve the same: ifthen, xifthen and ifthenx.

How do I choose which package to use? In which cases do I handcode stuff? Are there best practices? Please note, that the examples are exemplifying the general question.

share|improve this question

migrated from meta.tex.stackexchange.com Dec 23 '13 at 10:15

This question came from our discussion, support, and feature requests site for users of TeX, LaTeX, ConTeXt, and related typesetting systems.

2  
If I understand the question correctly: In this case, I would opt to use the newer syntax provided by expl3 and xparse. These are already included in the core distributions (to the best of my knowledge). –  Sean Allred Jan 2 at 2:50

2 Answers 2

up vote 6 down vote accepted

When in doubt, opt for the standard.

Even though it isn't entrenched yet (as ifthen is), the programming layer of the up-and-coming LaTeX3 kernel—expl3—is powerful and very stable. Even in the texlive-core package of the package repository of Arch Linux (think most minimal of the minimalist), the entire L3 kernel is included. It will always be available to your users.

From experience with related problems, do not hand-code things unless you have to—it becomes near impossible to maintain and, as you say, impossible to understand at face-value.

There might be a lack of convention here, but the best convention in any case is to use the official stuff.


From here: look up the following with texdoc:

  • expl3 explains the reasoning behind experimental LaTeX 3 syntax and introduces the component 'packages' (in practice, you just \usepackage{expl3}
  • interface3 serves as a reference for the entire expl3 library and interface
  • xparse invaluable resource in defining commands with a more complex syntax
share|improve this answer

If the twoopt package fulfills your needs there is nothing wrong with using it...

In general LaTeX is a constantly developing system. Packages are the engine of this process. By neglecting their usage universally or choosing to hard-code if there would have been a suitable package, you would refuse an important property of the LaTeX system.

Although the last statement sounds a little dramatic, there is truth in it. Apart from that, often it remains a matter of choice and habits (we are all humans!). But, if you have the opportunity to obtain a more readable code through package usage, go ahead. This criterion is, by the way, a major issue of the LaTeX3 project.

Being bound to a package in a .sty or .cls file is not limiting you in any way. Even if a package you used in your own package code will be deprecated in the future because of a newer package being better or whatever, it does not mean that the feature you used isn't viable anymore. Moreover, as a package writer you can maintain/update your package according to the state of play. Besides that, I'd like to recall the fact that LaTeX2e is very stable at the moment. So, "[using] the official stuff" (@Sean Allred, see above) is totally reasonable from this point of view.

And finally, if three packages do the exact same job for a particular issue, i refer to the above statement "we are all humans!": Use the one you like best or the one you are used to.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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