semprag / tex

S&P LaTeX and BibTeX sources
The Unlicense
3 stars 1 forks source link

Make production vs. external build-process more interchangeable #16

Open chbrown opened 7 years ago

chbrown commented 7 years ago

Right now, for most of the production process, there are two major configuration differences between development and production builds:

  1. Font: Times in development (or Computer Roman), because Lucida is a commercially licensed font.
    • The lucida class option is only used in production.
  2. Bibliography compiler: usually BibTeX in development, since most people already have it set up or find it easier to use than BibLaTeX (BibLaTeX is the future but honestly it's not very stable so I don't blame them)
    • In production, the biblatex class option is added, and...
    • The single BibTeX \bibliography{myfile} is replaced with \printbibliography, along with a adding \addbibresource{myfile.bib} to the preamble.

Sometimes when we send document sources back to the author for revisions, we forget to switch the production flags off. This is unfortunate, because neither of these cases degrade gracefully when 1) Lucida, or 2) the required BibLaTeX styles / compiler, are not available.

  1. Recovering when Lucida is missing is close — we can simply set \@times to true in the \IfFileExists{lucimatx.sty}{}{ ... here ... } else clause in sp.cls, in addition to the current fallback of logging a warning saying "Requested fonts not present"
  2. Recovering from BibLaTeX is going to be harder. It's easy to define fake BibLaTeX API commands that call out to the BibTeX commands, but harder to go the other way around, since BibLaTeX insists on knowing what files are in going to be in the bibliography before the preamble ends. So I propose that we change the template + instructions to use \addbibresource{} and \printbibliography commands instead of the usual single BibTeX \bibliography{} command, and add shims for those commands to the \else side of the \if@biblatex conditional in sp.cls. My initial hack of a solution looks like this:

    \def\@bibresource{\relax}
    \newcommand{\addbibresource}[1]{\gdef\@bibresource{#1}}
    \newcommand{\printbibliography}{\bibliography{\@bibresource}}

I'm not sure how to check for BibLaTeX+biber and that the required bbx/cbx files are around when biblatex is used, and give some legible warning if anything is missing, but that would be nice in terms of user experience.

Even more simply, I'd like to propose that we replace the [lucida] and [biblatex] class options by hooking into the standard [final] option, which would effectively set both of those to true and degrade gracefully, but with blaring warnings, if it can't import and use them properly.

Then all we would have to do when turning around LaTeX sources would be to remove the final option, and even if we forgot to do that, it would just add a couple warnings to the author's logs, instead of breaking completely.

Checklist:

fintelkai commented 7 years ago

Sounds like a good plan.