"""let a formula say how it is set on its line Display maths is centred by default, and that is what a paper wants almost every time — but not always. A derivation that continues a previous line, or a formula the writer wants against the right margin, is a layout decision about *that formula*, and there was nowhere to record it: the renderer centred everything. So the sentence carries it: ``formula_align`` is ``center`` (the default), ``left`` or ``right``, and it only means anything for a sentence that contains display maths (``$$ … $$``). The equation number is unaffected — ``\\tag{1}`` is always at the right margin, which is the convention in every style that numbers equations. Why the sentence rather than the template field ----------------------------------------------- A field (``template_title``) describes a *heading*: its text, level and typography. Alignment belongs to one formula, and one paragraph legitimately mixes them — a centred equation followed by a right-aligned continuation. A field-level setting would force every formula under that heading to look the same, and the writer would have no way to make an exception. Existing rows default to ``center``: today's documents render exactly as they do now. Revision ID: a1d47c6f2e58 Revises: f8c2d5a73b91 Create Date: 2026-09-23 """ from collections.abc import Sequence import sqlalchemy as sa from alembic import op # revision identifiers, used by Alembic. revision: str = "a1d47c6f2e58" down_revision: str | None = "f8c2d5a73b91" branch_labels: str | Sequence[str] | None = None depends_on: str | Sequence[str] | None = None def upgrade() -> None: op.add_column( "paper_sentence", sa.Column( "formula_align", sa.String(length=8), server_default=sa.text("'center'"), nullable=False, ), ) def downgrade() -> None: op.drop_column("paper_sentence", "formula_align")