In October 1806, he was scrambling to complete a long overdue manuscript when Napoleon’s army turned up outside Jena.