2

In terms of the efficiency/speed of compiling which is the more effective place to put bibliography option changes: In the biblatex.cfg, a .cls file calling a new class or a .sty file.

Any insight would be appreciated.

  • 3
    Speed is the same: the question really is what sort of set up do you want. For example, if you are making a custom class then that's the right place. – Joseph Wright Mar 01 '16 at 12:08
  • 4
    tex is a macro expansion language not a compiler, all those things are just input text files with macros that are expanded at run time, the different file name extensions are more for humans to understand which file is which than any real effect on the processing. – David Carlisle Mar 01 '16 at 12:11

1 Answers1

6

There are several places where you can put your customisation and performance wise they should by and large be equivalent (save for the overhead of loading new files). So the choice should depend on the exact nature and aim of the modifications.

Document Preamble

  • Modifications are kept local
  • Reuse isn't as easy
  • You might amass quite some code in the preamble

The preamble is useful if you want to apply a one-off change to your document that does not take too many lines of code (of course you can externalise long code with \input).

\input

Externalise the code from your preamble to an external .tex file. You can then \input that file into your preamble.

  • Easier reuse
  • Slightly easier to handle than .sty files.

.sty Files

You can place biblatex code in .sty files just as you can place it in the preamble of your document. Keep in mind that you should probably load the .sty after you load biblatex to make sure all the commands are defined.

  • Easy reuse
  • The .sty might not work together with all bibliography styles, you should be aware of that and not load the fill without checking

This method might be useful if you want something more "permanent" than just an externalised preamble with \input. You can reuse this for other documents of a similar type.

.cls Files

If you plan on writing a custom .cls for this particular project (type of project with very specific rules of formatting: a thesis template for a particular university department, say) you might as well include the biblatex code there, but the caveats of the .sty file method apply as well.

In a multi-purpose .cls file bilatex code is certainly amiss, people should be able to decide which style and even which bibliography package to use and your class shouldn't interfere with that.

biblatex.cfg

  • Applies to all documents in scope (normally biblatex.cfg is placed in a shared folder such that it applies to all your documents, but you can also place it in the current directory to affect only the documents there)
  • Code doesn't appear in the document, but you don't even see that (and which!) biblatex.cfg was loaded until you consult the .log file

The configuration file biblatex.cfg is loaded after the style files (.bbx, .cbx) and can modify their behaviour.

Because of the scope issue I would only place style-independent modifications that you want to apply to all documents you write in biblatex.cfg.

Write Your Own Bibliography/Citation Style

You can build upon existing styles with \RequireBibliographyStyle, \RequireCitationStyle and just add your modifications. A good example is Joseph Wright's biblatex-phys that builds on numeric-comp: phys.cbx and phys.bbx. You can of course also roll your own from scratch.

  • Modifications apply only to documents that explicitly load the new style
  • There can only be one style active in your document, the new custom style will replace any other style

This method is especially suited for creating "new styles" you might want use more often and for several (types of) documents.

Because you could introduce additional loading of files via the rerouteing with \RequireBibliographyStyle, \RequireCitationStyle you might technically be a bit worse off speed wise, but that is certainly nothing to lose sleep over.


In conclusion: If you have a some lines of code you need for certain applications put them in the preamble, externalise them with \input, or write a .sty. (The three alternatives are ordered by easiness of reuse.) If you have a few lines of style-agnostic code you want to apply all the time, use biblatex.cfg. If you modify a specific style to meet certain guidelines write your own .bbx/.cbx file to be able to reuse the style document-independent.

moewe
  • 175,683